KI_PKCS_RSAPrivateBER

MultiPrime

unsigned char f4Data[] = {0x01, 0x00, 0x01}; A_RSA_MULTI_PRIME_KEY_GEN_PARAMS keygenParams;

keygenParams.modulusBits = keyBits; keygenParams.numberOfPrimes = numPrimes; keygenParams.publicExponent.data = f4Data; keygenParams.publicExponent.len = sizeof(f4Data);

if ((status = B_SetAlgorithmInfo (keypairGenerator, AI_RSAMultiPrimeKeyGen, (POINTER)&keygenParams)) != 0)

break;

Step 3: Init

Now, make the appropriate adjustments to the algorithm chooser so that the algorithm methods correspond to the AI chosen:

B_ALGORITHM_METHOD *RSA_KEYGEN_CHOOSER[] = { &AM_RSA_KEY_GEN, (B_ALGORITHM_METHOD *)NULL_PTR

};

if ((status = B_GenerateInit (keypairGenerator,

RSA_KEYGEN_CHOOSER,

(A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Following this step, you will call B_GenerateKeypair in the same manner as was done for standard RSA key pair generation. The public and private B_KEY_OBJs will then be suitable for signing/verifying or encrypting/decrypting in exactly the same way as the standard RSA key objects are used. This includes using

to obtain the BER-encoded RSA MultiPrime key. KI_PKCSMultiPrimeRSAPrivate can also be used with B_GetKeyInfo or B_SetKeyInfo to view or manipulate the data in a private key object. See the samples/pkalg/rsa/rsamultp.c sample for further details.

Distributing an RSA Public Key

After generating a key pair, you need to make the public key available to the public.

C h a p t e r 7 P u b l i c - K e y O p e r a t i o n s

2 2 3

Page 245
Image 245
RSA Security 5.2.2 manual Distributing an RSA Public Key, If status = BGenerateInit keypairGenerator