Chapter 7 Public-Key Operations 221

MultiPrime
B_ALGORITHM_METHOD *RSA_GEN_CHOOSER[] = {
&AM_RSA_KEY_GEN,
(B_ALGORITHM_METHOD *)NULL_PTR
};
A_RSA_MULTI_PRIME_KEY_GEN_PARAMS genParams;
ITEM *privateKeyBER = (ITEM *)NULL_PTR;
unsigned char expo[1] = {
3
};
do {
if ((status = B_CreateKeyObject (&pubKey)) != 0)
break;
if ((status = B_CreateKeyObject (&priKey)) != 0)
break;
if ((status = B_CreateAlgorithmObject (&rsaGen)) != 0)
break;
genParams.modulusBits = 1024;
genParams.numberOfPrimes = 3;
genParams.publicExponent.data = expo;
genParams.publicExponent.len = sizef (expo);
if ((status = B_SetAlgorithmInfo
(rsaGen, AI_RSAMultiPrimeKeyGen,
(POINTER)&genParams)) != 0)
break;
if ((status = B_GenerateInit
(rsaGen, RSA_GEN_CHOOSER, NULL_SURR)) != 0)
break;
if ((status = B_GenerateKeypair
(rsaGen, pubKey, priKey, rand, NULL_SURR)) != 0)
break;
if ((status = B_GetKeyInfo
((POINTER *)&privateKeyBER, priKey,
KI_PKCS_RSAPrivateBER)) != 0)
break;
} while (0);