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

Header file for the Nanocrypto RSA API. More...

Go to the source code of this file.

Typedefs

typedef struct MRsaKeyTemplate * MRsaKeyTemplatePtr
 

Functions

MOC_EXTERN MSTATUS RSA_applyPrivateKey (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pPrivateKey, RNGFun rngFun, void *rngFunArg, ubyte *pInput, ubyte4 inputLen, ubyte **ppOutput, vlong **ppVlongQueue)
 This function performs an RSA private key operation with no padding. More...
 
MOC_EXTERN MSTATUS RSA_applyPublicKey (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pPublicKey, ubyte *pInput, ubyte4 inputLen, ubyte **ppOutput, vlong **ppVlongQueue)
 This function performs an RSA public key operation with no padding. More...
 
MOC_EXTERN MSTATUS RSA_byteStringFromKey (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey, ubyte *pBuffer, ubyte4 *pRetLen)
 Convert RSA key to a string of (PKCS #1) bytes. More...
 
MOC_EXTERN MSTATUS RSA_cloneKey (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey **ppNew, const RSAKey *pSrc, vlong **ppVlongQueue)
 Clone (copy) an RSA key. More...
 
MOC_EXTERN MSTATUS RSA_createKey (RSAKey **pp_RetRSAKey)
 Create memory storage for an RSA key pair. More...
 
MOC_EXTERN MSTATUS RSA_decrypt (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey, const ubyte *cipherText, ubyte *plainText, ubyte4 *plainTextLen, RNGFun rngFun, void *rngFunArg, vlong **ppVlongQueue)
 Decrypt ciphertext using PKCS #1. More...
 
MOC_EXTERN MSTATUS RSA_encrypt (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey, const ubyte *plainText, ubyte4 plainTextLen, ubyte *cipherText, RNGFun rngFun, void *rngFunArg, vlong **ppVlongQueue)
 Encrypt plaintext using PKCS #1. More...
 
MOC_EXTERN MSTATUS RSA_equalKey (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey1, const RSAKey *pKey2, byteBoolean *pResult)
 Determine whether two RSA keys are equal. More...
 
MOC_EXTERN MSTATUS RSA_freeKey (RSAKey **ppFreeRSAKey, vlong **ppVlongQueue)
 Free (delete) an RSA key. More...
 
MOC_EXTERN MSTATUS RSA_freeKeyTemplate (RSAKey *pKey, MRsaKeyTemplatePtr pTemplate)
 Free the RSA standard key template structure previouslly allocated by RSA_getKeyParametersAlloc. More...
 
MOC_EXTERN MSTATUS RSA_generateKey (MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *pRandomContext, RSAKey *p_rsaKey, ubyte4 keySize, vlong **ppVlongQueue)
 Generate RSA key pair (private and public keys). More...
 
MOC_EXTERN MSTATUS RSA_getCipherTextLength (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey, sbyte4 *pCipherTextLen)
 Get an RSA public key's ciphertext length. More...
 
MOC_EXTERN MSTATUS RSA_getKeyParametersAlloc (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, MRsaKeyTemplatePtr pTemplate, ubyte keyType)
 Retrieve the following components from an RSA key as byte string buffers: More...
 
MOC_EXTERN MSTATUS RSA_getPrivateExponent (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pRSAKey, vlong **ppRetD, vlong **ppVlongQueue)
 
MOC_EXTERN MSTATUS RSA_keyFromByteString (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey **ppKey, const ubyte *byteString, ubyte4 len, vlong **ppVlongQueue)
 Convert byte string to RSA key, using PKCS #1. More...
 
MOC_EXTERN MSTATUS RSA_prepareKey (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pRSAKey, vlong **ppVlongQueue)
 Compute RSA private key. More...
 
MOC_EXTERN MSTATUS RSA_setAllKeyData (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, ubyte *pPubExpo, ubyte4 pubExpoLen, const ubyte *pModulus, ubyte4 modulusLen, const ubyte *pPrime1, ubyte4 prime1Len, const ubyte *pPrime2, ubyte4 prime2Len, vlong **ppVlongQueue)
 This is the same as RSA_setAllKeyParameters, except the public exponent is passed in as a canonical int. More...
 
MOC_EXTERN MSTATUS RSA_setAllKeyParameters (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, ubyte4 exponent, const ubyte *modulus, ubyte4 modulusLen, const ubyte *prime1, ubyte4 prime1Len, const ubyte *prime2, ubyte4 prime2Len, vlong **ppVlongQueue)
 Set RSA public key parameters. More...
 
MOC_EXTERN MSTATUS RSA_setPublicKeyData (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, ubyte *pPubExpo, ubyte4 pubExpoLen, const ubyte *pModulus, ubyte4 modulusLen, vlong **ppVlongQueue)
 This is the same as RSA_setPublicKeyParameters, except the public exponent is passed in as a canonical int. More...
 
MOC_EXTERN MSTATUS RSA_setPublicKeyParameters (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, ubyte4 exponent, const ubyte *modulus, ubyte4 modulusLen, vlong **ppVlongQueue)
 Set RSA public key parameters: exponent and modulus. More...
 
MOC_EXTERN MSTATUS RSA_signMessage (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey, const ubyte *plainText, ubyte4 plainTextLen, ubyte *cipherText, vlong **ppVlongQueue)
 Generate signature for plaintext buffer, using provided RSA private key and PKCS #1. More...
 
MOC_EXTERN MSTATUS RSA_verifyDigest (MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *pKey, ubyte *pMsgDigest, ubyte4 digestLen, ubyte *pSignature, ubyte4 sigLen, intBoolean *pIsValid, vlong **ppVlongQueue)
 Verify the digest of a message. More...
 
MOC_EXTERN MSTATUS RSA_verifySignature (MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *pKey, const ubyte *cipherText, ubyte *plainText, ubyte4 *plainTextLen, vlong **ppVlongQueue)
 Verify decrypted buffer's signature. More...
 

Detailed Description

RSA public key encryption

Whether the following flags are defined determines which additional header files are included:

  • __ENABLE_MOCANA_FIPS_MODULE__
  • __ENABLE_MOCANA_PKCS11_CRYPTO__
  • __ENABLE_MOCANA_HW_SECURITY_MODULE__
  • __RSA_HARDWARE_ACCELERATOR__

Whether the following flags are defined determines which function declarations are enabled:

  • __CUSTOM_RSA_BLINDING__
  • __DISABLE_MOCANA_KEY_GENERATION__
  • __DISABLE_MOCANA_RSA_CLIENT_CODE__
  • __DISABLE_MOCANA_RSA_DECRYPTION__
  • __DISABLE_MOCANA_RSA_SIGN__
  • __DISABLE_MOCANA_RSA_VERIFY__
  • __DISABLE_MOCANA_RSA_VERIFY_CERTIFICATE__
  • __DISABLE_PKCS1_KEY_READ__
  • __ENABLE_ALL_TESTS__
  • __ENABLE_MOCANA_FIPS_MODULE__
  • __ENABLE_MOCANA_PKCS11_CRYPTO__
  • __ENABLE_MOCANA_VERIFY_RSA_SIGNATURE__
  • __MOCANA_BLIND_FACTOR_SIZE__
  • __RSAINT_HARDWARE__

Copyright 2019-2024 DigiCert, Inc. All Rights Reserved. Proprietary and Confidential Material.

Function Documentation

◆ RSA_applyPrivateKey()

MOC_EXTERN MSTATUS RSA_applyPrivateKey ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pPrivateKey,
RNGFun  rngFun,
void *  rngFunArg,
ubyte *  pInput,
ubyte4  inputLen,
ubyte **  ppOutput,
vlong **  ppVlongQueue 
)

If a RNGFun is provided, RSA blinding will be used. The output of this operation will always be exactly modulus length bytes.

Parameters
pPrivateKeyPointer to the private key to be applied.
rngFunFunction pointer for generating random bytes, RSA blinding will be used if this is provided.
rngFunArgArgument to the rngFun.
pInputBuffer containing the input data.
inputLenLength in bytes of the input material, must be less than the modulus length.
ppOutputPointer to the location that will recieve the allocated buffer with exactly modulus length bytes of processed data.
ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ RSA_applyPublicKey()

MOC_EXTERN MSTATUS RSA_applyPublicKey ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pPublicKey,
ubyte *  pInput,
ubyte4  inputLen,
ubyte **  ppOutput,
vlong **  ppVlongQueue 
)

The output of this operation will always be exactly modulus length bytes.

Parameters
pPublicKeyPointer to the public key to be applied.
pInputBuffer containing the input data.
inputLenLength in bytes of the input material, must be less than the modulus length.
ppOutputPointer to the location that will recieve the allocated buffer with exactly modulus length bytes of processed data.
ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h

◆ RSA_byteStringFromKey()

MOC_EXTERN MSTATUS RSA_byteStringFromKey ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey,
ubyte *  pBuffer,
ubyte4 *  pRetLen 
)

This function converts an RSA key to a string of (PKCS #1) bytes.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Warning
Before calling this function, be sure that the buffer pointed to by the pBuffer parameter is large enough; otherwise, buffer overflow will occur.
Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pKeyPointer to RSA key to convert.
[out]pBufferPointer to the address of a previously allocated buffer. On return, the buffer contains a byte-string representation of the RSA key. (The calling function must allocate sufficient memory for the resulting key. Otherwise, buffer overflow will occur.)
[out]pRetLenOn input, pointer to the size of the pBuffer parameter. On return, pointer to number of bytes written to the buffer buffer.
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.

◆ RSA_cloneKey()

MOC_EXTERN MSTATUS RSA_cloneKey ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey **  ppNew,
const RSAKey *  pSrc,
vlong **  ppVlongQueue 
)

This function clones (copies) an RSA key. To avoid memory leaks, your application should call RSA_freeKey() when it is done using the cloned key.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[out]ppNewOn return, pointer to address of cloned RSA key.
[in]pSrcPointer to RSA key to clone.
[in,out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_createKey()

MOC_EXTERN MSTATUS RSA_createKey ( RSAKey **  pp_RetRSAKey)

This function creates storage (allocates memory) for an RSA key pair. After the memory is allocated, applications can use the RSA_generateKey() function to generate the RSA key pair.

Note
This function does not generate actual RSA key values; to generate an RSA key pair, call the RSA_generateKey() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[out]pp_RetRSAKeyOn return, pointer to address of allocated memory (for an RSA key).
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.

◆ RSA_decrypt()

MOC_EXTERN MSTATUS RSA_decrypt ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey,
const ubyte *  cipherText,
ubyte *  plainText,
ubyte4 *  plainTextLen,
RNGFun  rngFun,
void *  rngFunArg,
vlong **  ppVlongQueue 
)

This function decrypts a ciphertext buffer, using PKCS #1 and the provided RSA private key.

Note
This function uses a private key. To use a public key, call the RSA_verifySignature() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

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

  • $__DISABLE_MOCANA_RSA_DECRYPTION__$
Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pKeyPointer to RSA private key.
[in]cipherTextPointer to ciphertext to decrypt.
[out]plainTextOn return, pointer to decrypted plaintext. (The calling function must allocate sufficient memory for the resulting plainText; otherwise, buffer overflow will occur.)
[out]plainTextLenOn return, pointer to number of bytes in the plaintext buffer (plainText).
[in]rngFunPointer to a function that generates random numbers suitable for cryptographic use. To be FIPS-compliant, reference RANDOM_rngFun() (defined in random.c), and make sure that __ENABLE_MOCANA_FIPS_MODULE__ is defined in moptions.h
[in]rngFunArgPointer to arguments that are required by the function referenced in rngFun. If you use RANDOM_rngFun(), you must supply a randomContext structure, which you can create by calling RANDOM_acquireContext().
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_encrypt()

MOC_EXTERN MSTATUS RSA_encrypt ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey,
const ubyte *  plainText,
ubyte4  plainTextLen,
ubyte *  cipherText,
RNGFun  rngFun,
void *  rngFunArg,
vlong **  ppVlongQueue 
)

This function encrypts a plaintext buffer, using PKCS #1 and the provided RSA public key.

Note
This function uses a public key. To use a private key, call the RSA_signMessage() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Warning
Before calling this function, be sure that the buffer pointed to by the cipherText parameter is large enough; otherwise, buffer overflow will occur. (To determine the ciphertext length, call the RSA_getCipherTextLength() function).
Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pKeyPointer to RSA public key.
[in]plainTextPointer to plaintext buffer to encrypt.
[in]plainTextLenNumber of bytes in the plaintext buffer (plainText).
[out]cipherTextOn return, pointer to encrypted ciphertext. (The calling function must allocate sufficient memory for the resulting cipherText; otherwise, buffer overflow will occur.)
[in]rngFunPointer to a function that generates random numbers suitable for cryptographic use. To be FIPS-compliant, reference RANDOM_rngFun() (defined in random.c), and make sure that __ENABLE_MOCANA_FIPS_MODULE__ is defined in moptions.h
[in]rngFunArgPointer to arguments that are required by the function referenced in rngFun. If you use RANDOM_rngFun(), you must supply a randomContext structure, which you can create by calling RANDOM_acquireContext().
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_equalKey()

MOC_EXTERN MSTATUS RSA_equalKey ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey1,
const RSAKey *  pKey2,
byteBoolean *  pResult 
)

This function determines whether two RSA keys are equal, and returns the result through the pResult parameter.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[in]pKey1Pointer to first RSA key.
[in]pKey2Pointer to second RSA key.
[out]pResultOn return, pointer to TRUE if the two keys are equal; otherwise pointer to FALSE.
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.

◆ RSA_freeKey()

MOC_EXTERN MSTATUS RSA_freeKey ( RSAKey **  ppFreeRSAKey,
vlong **  ppVlongQueue 
)

This function frees (deletes) an RSA key. To avoid memory leaks, applications should call this function when an allocated RSA key is no longer needed.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[in,out]ppFreeRSAKeyPointer to address of RSA key to free (delete).
[in,out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_freeKeyTemplate()

MOC_EXTERN MSTATUS RSA_freeKeyTemplate ( RSAKey *  pKey,
MRsaKeyTemplatePtr  pTemplate 
)
Parameters
[in]pKeyPointer to the original key the data was retrieved from.
[in,out]pTemplatePointer to the RSA standard key template structure.
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.

◆ RSA_generateKey()

MOC_EXTERN MSTATUS RSA_generateKey ( MOC_RSA(hwAccelDescr hwAccelCtx) randomContext *  pRandomContext,
RSAKey *  p_rsaKey,
ubyte4  keySize,
vlong **  ppVlongQueue 
)

This function generates an RSA key pair (private and public keys). Typically, your application calls this function after calling the RSA_createKey() function.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pRandomContextPointer to RNG context.
[in,out]p_rsaKeyPointer to RSA key memory, previously allocated by calling RSA_createKey().
[in]keySizeNumber of bits for generated RSA key; for example, 1024). (For details, refer to the appropriate FIPS Publication, accessible from the following Web page: http://www.nist.gov/itl/fips.cfm.)
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_getCipherTextLength()

MOC_EXTERN MSTATUS RSA_getCipherTextLength ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey,
sbyte4 *  pCipherTextLen 
)

This function gets an RSA public key's ciphertext length, and returns it through the cipherTextLen parameter.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
pKeyPointer to RSA public key.
pCipherTextLenOn return, pointer to number of bytes in key's ciphertext.
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.

◆ RSA_getKeyParametersAlloc()

MOC_EXTERN MSTATUS RSA_getKeyParametersAlloc ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
MRsaKeyTemplatePtr  pTemplate,
ubyte  keyType 
)
  • Public Exponent (E)
  • Modulus (N)
  • Components of N (For private keys):
    • Prime P
    • Prime Q

This function allocates the buffers onto the heap, therefore a call to the free function RSA_freeKeyTemplate is required in order to properly free these buffers.

Parameters
[in]pKeyPointer to an RSA key.
[in,out]pTemplatePointer to the RSA standard key template structure.
[in]keyTypeInstructs the function whether to return public or private key data. Value may either be MOC_GET_PUBLIC_KEY_DATA or MOC_GET_PRIVATE_KEY_DATA
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.

◆ RSA_keyFromByteString()

MOC_EXTERN MSTATUS RSA_keyFromByteString ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey **  ppKey,
const ubyte *  byteString,
ubyte4  len,
vlong **  ppVlongQueue 
)

This function converts a byte string to an RSA key, using PKCS #1, and returns the resultant RSA key through the ppKey parameter.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Note
To avoid memory leaks, be sure to free the resultant RSA key by calling RSA_freeKey().
Parameters
[out]ppKeyOn return, pointer to address of new RSA key.
[in]byteStringPointer to buffer containing RSA key as a string of PKCS #1 bytes.
[in]lenNumber of bytes in RSA key buffer (byteString).
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_prepareKey()

MOC_EXTERN MSTATUS RSA_prepareKey ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pRSAKey,
vlong **  ppVlongQueue 
)

This function computes an RSA private key.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[in]hwAccelCtx(Reserved for future use.)
[out]pRSAKeyOn return, pointer to RSA private key. that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
[out]ppVlongQueueOn return, pointer to location in the vlong queue
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.

◆ RSA_setAllKeyData()

MOC_EXTERN MSTATUS RSA_setAllKeyData ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
ubyte *  pPubExpo,
ubyte4  pubExpoLen,
const ubyte *  pModulus,
ubyte4  modulusLen,
const ubyte *  pPrime1,
ubyte4  prime1Len,
const ubyte *  pPrime2,
ubyte4  prime2Len,
vlong **  ppVlongQueue 
)
Parameters
[in,out]pKeyPointer to RSA public key.
[in]pPubExpoRSA public key exponent. (For details, refer to the appropriate FIPS Publication, accessible from the following Web page: http://www.nist.gov/itl/fips.cfm.)
[in]pubExpoLenNumber of bytes in pPubExpo.
[in]pModulusPointer to buffer containing the desired modulus, represented as a buffer of bytes in big endian format.
[in]modulusLenNumber of bytes in pModulus.
[in]pPrime1Pointer to buffer containing first prime number for RSA key calculation.
[in]prime1LenNumber of bytes in the first prime number buffer (prime1).
[in]pPrime2Pointer to buffer containing second prime number for RSA key calculation.
[in]prime2LenNumber of bytes in the second prime number buffer (prime2).
[in,out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_setAllKeyParameters()

MOC_EXTERN MSTATUS RSA_setAllKeyParameters ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
ubyte4  exponent,
const ubyte *  modulus,
ubyte4  modulusLen,
const ubyte *  prime1,
ubyte4  prime1Len,
const ubyte *  prime2,
ubyte4  prime2Len,
vlong **  ppVlongQueue 
)

This function sets an RSA public key's parameters. The modulus is a string of bytes in big endian format.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable the functions in this header file.

Parameters
[in]hwAccelCtx(Reserved for future use.)
[in,out]pKeyPointer to RSA public key.
[in]exponentRSA public key exponent.
[in]modulusPointer to buffer containing modulus, represented as a buffer of bytes in big endian format.
[in]modulusLenNumber of bytes in modulus.
[in]prime1Pointer to buffer containing first prime number for RSA key calculation.
[in]prime1LenNumber of bytes in the first prime number buffer (prime1).
[in]prime2Pointer to buffer containing second prime number for RSA key calculation.
[in]prime2LenNumber of bytes in the second prime number buffer (prime2).
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_setPublicKeyData()

MOC_EXTERN MSTATUS RSA_setPublicKeyData ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
ubyte *  pPubExpo,
ubyte4  pubExpoLen,
const ubyte *  pModulus,
ubyte4  modulusLen,
vlong **  ppVlongQueue 
)
Parameters
[in,out]pKeyPointer to RSA public key.
[in]pPubExpoRSA public key exponent. (For details, refer to the appropriate FIPS Publication, accessible from the following Web page: http://www.nist.gov/itl/fips.cfm.)
[in]pubExpoLenNumber of bytes in pPubExpo.
[in]pModulusPointer to buffer containing the desired modulus, represented as a buffer of bytes in big endian format.
[in]modulusLenNumber of bytes in pModulus.
[in,out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_setPublicKeyParameters()

MOC_EXTERN MSTATUS RSA_setPublicKeyParameters ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
ubyte4  exponent,
const ubyte *  modulus,
ubyte4  modulusLen,
vlong **  ppVlongQueue 
)

This function sets an RSA public key's exponent and modulus parameters. The modulus is a string of bytes in big endian format.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[in,out]pKeyPointer to RSA public key.
[in]exponentRSA public key exponent. (For details, refer to the appropriate FIPS Publication, accessible from the following Web page: http://www.nist.gov/itl/fips.cfm.)
[in]modulusPointer to buffer containing the desired modulus, represented as a buffer of bytes in big endian format.
[in]modulusLenNumber of bytes in modulus.
[in,out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_signMessage()

MOC_EXTERN MSTATUS RSA_signMessage ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey,
const ubyte *  plainText,
ubyte4  plainTextLen,
ubyte *  cipherText,
vlong **  ppVlongQueue 
)

This function generates a signature for a plaintext buffer, using the provided RSA private key and PKCS #1 (essentially encrypting the plaintext).

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA
Note
This function uses a private key. To use a public key, call the RSA_encrypt() function.

There are no flag dependencies to enable this function.

Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pKeyPointer to RSA private key.
[in]plainTextPointer to plaintext buffer to encrypt.
[in]plainTextLenNumber of bytes in the plaintext buffer (plainText).
[out]cipherTextOn return, pointer to encrypted ciphertext containing the signature. (The calling function must allocate sufficient memory for the resulting cipherText; otherwise, buffer overflow will occur.)
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.

◆ RSA_verifyDigest()

MOC_EXTERN MSTATUS RSA_verifyDigest ( MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey *  pKey,
ubyte *  pMsgDigest,
ubyte4  digestLen,
ubyte *  pSignature,
ubyte4  sigLen,
intBoolean *  pIsValid,
vlong **  ppVlongQueue 
)

This function verifies the digest of a message, using the provided RSA public key.

There are no flag dependencies to enable this function.

Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pKeyPointer to RSA public key.
[in]pMsgDigestPointer to Msg Digest to be verified.
[in]digestLenThe length of the message digest in bytes.
[in]pSignaturePointer to the signature to be verified.
[in]sigLenThe length of the signature in bytes.
[out]pIsValidContents will be set with TRUE if the signature is valid and FALSE if otherwise.
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.
Warning
Be sure to check for both a return status of OK and a pIsValid of TRUE before accepting that a signature is valid.

◆ RSA_verifySignature()

MOC_EXTERN MSTATUS RSA_verifySignature ( MOC_RSA(hwAccelDescr hwAccelCtx) const RSAKey *  pKey,
const ubyte *  cipherText,
ubyte *  plainText,
ubyte4 *  plainTextLen,
vlong **  ppVlongQueue 
)

This function verifies the signature of a PKCS #1-encrypted data buffer, using the provided RSA public key (essentially decrypting the ciphertext).

Note
This function uses a public key. To use a private key, call the RSA_decrypt() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart RSA

There are no flag dependencies to enable this function.

Parameters
[in]hwAccelCtx(Reserved for future use.)
[in]pKeyPointer to RSA public key.
[in]cipherTextPointer to ciphertext to decrypt.
[out]plainTextOn return, pointer to decrypted plaintext. (The calling function must allocate sufficient memory for the resulting plainText; otherwise, buffer overflow will occur.)
[out]plainTextLenOn return, pointer to number of bytes in the plaintext buffer (plainText).
[out]ppVlongQueueOn return, pointer to location in the vlong queue that contains this function's intermediate value, which can subsequently be used and eventually discarded. (Before ending, your application should be sure to free the entire queue.)
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.