RSA_GenerateKeys#
Generates key components for the desired RSA cryptographic system.
Syntax#
IppStatus ippsRSA_GenerateKeys(const IppsBigNumState* pSrcPublicExp, IppsBigNumState* pModulus, IppsBigNumState* pPublicExp, IppsBigNumState* pPrivateExp, IppsRSAPrivateKeyState* pPrivateKeyType2, Ipp8u* pScratchBuffer, int nTrials, IppsPrimeState* pPrimeGen, IppBitSupplier rndFunc, void* pRndParam);
Include Files#
ippcp.h
Parameters#
pSrcPublicExp |
Pointer to the IppsBigNumState context of the initial value for searching an RSA public exponent. |
pModulus |
Pointer to the generated RSA modulus. |
pPublicExp |
Pointer to the generated RSA public exponent. |
pPrivateExp |
Pointer to the generated RSA private exponent. |
pPrivateKeyType2 |
Pointer to the generated RSA private key type 2. |
pScratchBuffer |
Pointer to the temporary buffer of size not less than returned by the RSA_GetBufferSizePrivateKey function. |
nTrials |
Security parameter specified for the Miller-Rabin test for probable primality. |
pPrimeGen |
Ignored (pass NULL). Prime number generation uses rndFunc directly. |
rndFunc |
Pseudorandom number generator. |
pRndParam |
Pointer to the context of the pseudorandom number generator. |
Description#
This function generates public and private keys of the desired RSA cryptographic system.
This function sequentially performs the following computations:
Generates random probable prime numbers
pandqusing the specified pseudorandom number generator rndFunc.Computes the RSA composite modulus
n = (p*q).Based on the generated
pandqfactors, computes all the other CRT-related RSA components:dP=dmod (p-1),dQ=dmod (q-1) andqInv= 1/qmodp.
To generate RSA keys using the RSA_GenerateKeys function, call it in the following sequence of steps:
Establish the pseudorandom number generator.
Define the RSA private key type 2 in successive calls to the RSA_GetSizePrivateKeyType2 and RSA_InitPrivateKeyType2 functions with desired values of factorPBitSize and factorQBitSize parameters.
Allocate a temporary buffer of a suitable size.
Set up the initial value of the public exponent pSrcPublicExp.
Call RSA_GenerateKeys.
If RSA_GenerateKeys returns IppNoErr, the key pair is generated.
If RSA_GenerateKeys returns ippStsInsufficientEntropy, repeat this step.
Return Values#
ippStsNoErr |
Indicates no error. Any other value indicates an error or warning. |
ippStsNullPtrErr |
Indicates an error condition if any of the specified pointers is NULL. |
ippStsContextMatchErr |
Indicates an error condition if the context parameter does not match the operation. |
ippStsSizeErr |
Indicates an error condition if the bit length of any key component specified by pModulus, pPublicExp or pPrivateExp is not sufficient to hold the value. |
ippStsOutOfRangeErr |
Indicates an error condition if the initial value for searching the public exponent, specified by pSrcPublicExp, is not positive. |
ippStsBadArgErr |
Indicates an error condition if the public exponent specified by pSrcPublicExp is an even value or is less than 3. |
ippStsErr |
Indicates an internal error condition. |
ippStsInsufficientEntropy |
Indicates a warning condition if the prime number generation fails due to a poor choice of entropy. |
Related Information