RSA_GenerateKeys
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 theIppsBigNumStatecontext 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 theRSA_GetBufferSizePrivateKeyfunction.
- nTrials
- Security parameter specified for the Miller-Rabin test for probable primality.
- pPrimeGen
- Pointer to the prime number generator.
- 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 numberspandqusing the specified pseudorandom number generatorrndFunc.
- Computes the RSA composite modulusn = (p*q).
- Based on the generatedpandqfactors, computes all the other CRT-related RSA components:dP=dmod (p-1),dQ=pmod (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 and prime number generator.
- Define the RSA private key type 2 in successive calls to theRSA_GetSizePrivateKeyType2andRSA_InitPrivateKeyType2functions with desired values offactorPBitSizeandfactorQBitSizeparameters.
- Allocate a temporary buffer of a suitable size.
- Set up the initial value of the public exponentpSrcPublicExp.
- CallRSA_GenerateKeys.IfRSA_GenerateKeysreturnsIppNoErr, the key pair is generated.
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 isNULL.
- 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 bypModulus,pPublicExporpPrivateExpis not sufficient to hold the value or the prime number generator, specified bypPrimeGen, is not sufficient to generate suitable values.
- ippStsOutOfRangeErr
- Indicates an error condition if the initial value for searching the public exponent, specified bypSrcPublicExp, is not positive.
- ippStsBadArgErr
- Indicates an error condition in cases not explicitly mentioned above.
- ippStsInsufficientEntropy
- Indicates a warning condition if the prime number generation fails due to a poor choice of entropy.