Chapter 7 Public-Key Operations 223
MultiPrime
Step 3: Init
Now, make the appropriate adjustments to the algorithm chooser so that the
algorithm methods correspond to the AI chosen:
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 KI_PKCS_RSAPrivateBER
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.
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;
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;