TrustCore SDK NanoCrypto API reference  version 7.0
key_utils.h File Reference

Header file for Digicert SSH key utilities API. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS KEY_UTILS_CreateKeyBlobFromPEM (MOC_DSA(hwAccelDescr hwAccelCtx) ubyte *passphrase, ubyte *pPrivKey, ubyte4 privKeyLength, ubyte **pRetKeyBlob, ubyte4 *pRetKeyBlobLength, ubyte4 *retVal)
 Create a keyblob from a PEM-encoded private key. More...
 
MOC_EXTERN void KEY_UTILS_PEMKeyIsEncrypted (ubyte *pPrivKey, ubyte4 privKeyLength, ubyte4 *retVal)
 Determine whether a PEM key is encrypted. More...
 
MOC_EXTERN MSTATUS KEY_UTILS_PEMKeyIsValid (MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte *passphrase, ubyte *pPrivKey, ubyte4 privKeyLength, ubyte4 *retVal)
 Determine whether a PEM-encoded private key is valid. More...
 

Detailed Description

Header file for Digicert SSH key utilities API.

The following flags are required to enable this file's functions:

  • __ENABLE_MOCANA_KEY_UTILS__
  • __ENABLE_MOCANA_DSA__

Function Documentation

◆ KEY_UTILS_CreateKeyBlobFromPEM()

MOC_EXTERN MSTATUS KEY_UTILS_CreateKeyBlobFromPEM ( MOC_DSA(hwAccelDescr hwAccelCtx) ubyte *  passphrase,
ubyte *  pPrivKey,
ubyte4  privKeyLength,
ubyte **  pRetKeyBlob,
ubyte4 *  pRetKeyBlobLength,
ubyte4 *  retVal 
)

This function checks a passphrase to determine if a password exists. If a password exists, this function decodes the key and converts it to a keyblob. If the passphrase is NULL, this function tries to convert the private key as-is.

Note
This function is thread-safe.

To enable this function, the following flag must be defined:

  • __ENABLE_MOCANA_KEY_UTILS__

key_utils.h

Parameters
passphrasePassword for decrypting the private key.
pPrivKeyPrivate key to be convert to keyblob.
privKeyLengthLength of the private key, pPrivKey.
pRetKeyBlobOn return, pointer to resultant keyblob.
pRetKeyBlobLengthOn return, length of resultant keyblob, pRetKeyBlob.
retValOn return, "1" if the key is converted; otherwise "0".
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

key_utils.h

◆ KEY_UTILS_PEMKeyIsEncrypted()

MOC_EXTERN void KEY_UTILS_PEMKeyIsEncrypted ( ubyte *  pPrivKey,
ubyte4  privKeyLength,
ubyte4 *  retVal 
)

This function searches the entire private key to determine whether it contains the word "ENCRYPTED".

To enable this function, the following flag must be defined:

  • __ENABLE_MOCANA_KEY_UTILS__

key_utils.h

Parameters
pPrivKeyPrivate key to examine.
privKeyLengthLength of the private key, pPrivKey.
retValOn return, "1" if the key is encrypted; otherwise "0".
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

key_utils.h

◆ KEY_UTILS_PEMKeyIsValid()

MOC_EXTERN MSTATUS KEY_UTILS_PEMKeyIsValid ( MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte *  passphrase,
ubyte *  pPrivKey,
ubyte4  privKeyLength,
ubyte4 *  retVal 
)

Determine whether a PEM-encoded private key is valid.

Warning
To use function correctly, you must confirm that it returns OK (0) and that the retVal is "1". Otherwise the key is not valid.

To enable this function, the following flag must be defined:

  • __ENABLE_MOCANA_KEY_UTILS__

key_utils.h

Parameters
passphrasePassword for decrypting the private key.
pPrivKeyPrivate key to validate.
privKeyLengthLength of the private key, pPrivKey.
retValOn return, "1" if the key is valid; otherwise "0".
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

key_utils.h