![]() |
TrustCore SDK NanoCrypto API reference
version 7.0
|
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... | |
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.
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.
pPrivateKey | Pointer to the private key to be applied. |
rngFun | Function pointer for generating random bytes, RSA blinding will be used if this is provided. |
rngFunArg | Argument to the rngFun. |
pInput | Buffer containing the input data. |
inputLen | Length in bytes of the input material, must be less than the modulus length. |
ppOutput | Pointer to the location that will recieve the allocated buffer with exactly modulus length bytes of processed data. |
ppVlongQueue | On 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. |
OK
(0) if successful, otherwise a negative number error code from merrors.h 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.
pPublicKey | Pointer to the public key to be applied. |
pInput | Buffer containing the input data. |
inputLen | Length in bytes of the input material, must be less than the modulus length. |
ppOutput | Pointer to the location that will recieve the allocated buffer with exactly modulus length bytes of processed data. |
ppVlongQueue | On 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. |
OK
(0) if successful, otherwise a negative number error code from merrors.h 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
pBuffer
parameter is large enough; otherwise, buffer overflow will occur.[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pKey | Pointer to RSA key to convert. |
[out] | pBuffer | Pointer 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] | pRetLen | On input, pointer to the size of the pBuffer parameter. On return, pointer to number of bytes written to the buffer buffer. |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[out] | ppNew | On return, pointer to address of cloned RSA key. |
[in] | pSrc | Pointer to RSA key to clone. |
[in,out] | ppVlongQueue | On 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.) |
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. 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.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[out] | pp_RetRSAKey | On return, pointer to address of allocated memory (for an RSA key). |
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. 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.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
To enable this function, the following flag must #not# be defined:
[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pKey | Pointer to RSA private key. |
[in] | cipherText | Pointer to ciphertext to decrypt. |
[out] | plainText | On return, pointer to decrypted plaintext. (The calling function must allocate sufficient memory for the resulting plainText ; otherwise, buffer overflow will occur.) |
[out] | plainTextLen | On return, pointer to number of bytes in the plaintext buffer (plainText ). |
[in] | rngFun | Pointer 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] | rngFunArg | Pointer 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] | ppVlongQueue | On 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.) |
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. 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.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
cipherText
parameter is large enough; otherwise, buffer overflow will occur. (To determine the ciphertext length, call the RSA_getCipherTextLength() function).[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pKey | Pointer to RSA public key. |
[in] | plainText | Pointer to plaintext buffer to encrypt. |
[in] | plainTextLen | Number of bytes in the plaintext buffer (plainText ). |
[out] | cipherText | On return, pointer to encrypted ciphertext. (The calling function must allocate sufficient memory for the resulting cipherText ; otherwise, buffer overflow will occur.) |
[in] | rngFun | Pointer 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] | rngFunArg | Pointer 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] | ppVlongQueue | On 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.) |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in] | pKey1 | Pointer to first RSA key. |
[in] | pKey2 | Pointer to second RSA key. |
[out] | pResult | On return, pointer to TRUE if the two keys are equal; otherwise pointer to FALSE . |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in,out] | ppFreeRSAKey | Pointer to address of RSA key to free (delete). |
[in,out] | ppVlongQueue | On 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.) |
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. MOC_EXTERN MSTATUS RSA_freeKeyTemplate | ( | RSAKey * | pKey, |
MRsaKeyTemplatePtr | pTemplate | ||
) |
[in] | pKey | Pointer to the original key the data was retrieved from. |
[in,out] | pTemplate | Pointer to the RSA standard key template structure. |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pRandomContext | Pointer to RNG context. |
[in,out] | p_rsaKey | Pointer to RSA key memory, previously allocated by calling RSA_createKey(). |
[in] | keySize | Number 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] | ppVlongQueue | On 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.) |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
pKey | Pointer to RSA public key. |
pCipherTextLen | On return, pointer to number of bytes in key's ciphertext. |
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. MOC_EXTERN MSTATUS RSA_getKeyParametersAlloc | ( | MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey * | pKey, |
MRsaKeyTemplatePtr | pTemplate, | ||
ubyte | keyType | ||
) |
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.
[in] | pKey | Pointer to an RSA key. |
[in,out] | pTemplate | Pointer to the RSA standard key template structure. |
[in] | keyType | Instructs 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 |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[out] | ppKey | On return, pointer to address of new RSA key. |
[in] | byteString | Pointer to buffer containing RSA key as a string of PKCS #1 bytes. |
[in] | len | Number of bytes in RSA key buffer (byteString ). |
[out] | ppVlongQueue | On 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.) |
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. MOC_EXTERN MSTATUS RSA_prepareKey | ( | MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey * | pRSAKey, |
vlong ** | ppVlongQueue | ||
) |
This function computes an RSA private key.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in] | hwAccelCtx | (Reserved for future use.) |
[out] | pRSAKey | On 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] | ppVlongQueue | On return, pointer to location in the vlong queue |
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. 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 | ||
) |
[in,out] | pKey | Pointer to RSA public key. |
[in] | pPubExpo | RSA 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] | pubExpoLen | Number of bytes in pPubExpo . |
[in] | pModulus | Pointer to buffer containing the desired modulus, represented as a buffer of bytes in big endian format. |
[in] | modulusLen | Number of bytes in pModulus . |
[in] | pPrime1 | Pointer to buffer containing first prime number for RSA key calculation. |
[in] | prime1Len | Number of bytes in the first prime number buffer (prime1 ). |
[in] | pPrime2 | Pointer to buffer containing second prime number for RSA key calculation. |
[in] | prime2Len | Number of bytes in the second prime number buffer (prime2 ). |
[in,out] | ppVlongQueue | On 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.) |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable the functions in this header file.
[in] | hwAccelCtx | (Reserved for future use.) |
[in,out] | pKey | Pointer to RSA public key. |
[in] | exponent | RSA public key exponent. |
[in] | modulus | Pointer to buffer containing modulus, represented as a buffer of bytes in big endian format. |
[in] | modulusLen | Number of bytes in modulus . |
[in] | prime1 | Pointer to buffer containing first prime number for RSA key calculation. |
[in] | prime1Len | Number of bytes in the first prime number buffer (prime1 ). |
[in] | prime2 | Pointer to buffer containing second prime number for RSA key calculation. |
[in] | prime2Len | Number of bytes in the second prime number buffer (prime2 ). |
[out] | ppVlongQueue | On 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.) |
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. MOC_EXTERN MSTATUS RSA_setPublicKeyData | ( | MOC_RSA(hwAccelDescr hwAccelCtx) RSAKey * | pKey, |
ubyte * | pPubExpo, | ||
ubyte4 | pubExpoLen, | ||
const ubyte * | pModulus, | ||
ubyte4 | modulusLen, | ||
vlong ** | ppVlongQueue | ||
) |
[in,out] | pKey | Pointer to RSA public key. |
[in] | pPubExpo | RSA 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] | pubExpoLen | Number of bytes in pPubExpo . |
[in] | pModulus | Pointer to buffer containing the desired modulus, represented as a buffer of bytes in big endian format. |
[in] | modulusLen | Number of bytes in pModulus . |
[in,out] | ppVlongQueue | On 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.) |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in,out] | pKey | Pointer to RSA public key. |
[in] | exponent | RSA 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] | modulus | Pointer to buffer containing the desired modulus, represented as a buffer of bytes in big endian format. |
[in] | modulusLen | Number of bytes in modulus . |
[in,out] | ppVlongQueue | On 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.) |
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. 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 | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pKey | Pointer to RSA private key. |
[in] | plainText | Pointer to plaintext buffer to encrypt. |
[in] | plainTextLen | Number of bytes in the plaintext buffer (plainText ). |
[out] | cipherText | On 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] | ppVlongQueue | On 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.) |
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. 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.
[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pKey | Pointer to RSA public key. |
[in] | pMsgDigest | Pointer to Msg Digest to be verified. |
[in] | digestLen | The length of the message digest in bytes. |
[in] | pSignature | Pointer to the signature to be verified. |
[in] | sigLen | The length of the signature in bytes. |
[out] | pIsValid | Contents will be set with TRUE if the signature is valid and FALSE if otherwise. |
[out] | ppVlongQueue | On 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.) |
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.OK
and a pIsValid
of TRUE
before accepting that a signature is valid. 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).
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | RSA |
There are no flag dependencies to enable this function.
[in] | hwAccelCtx | (Reserved for future use.) |
[in] | pKey | Pointer to RSA public key. |
[in] | cipherText | Pointer to ciphertext to decrypt. |
[out] | plainText | On return, pointer to decrypted plaintext. (The calling function must allocate sufficient memory for the resulting plainText ; otherwise, buffer overflow will occur.) |
[out] | plainTextLen | On return, pointer to number of bytes in the plaintext buffer (plainText ). |
[out] | ppVlongQueue | On 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.) |
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.