RSA Security 5.2.2 manual Break

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 341
Image 341

The X9.31 Sample Program

/* ======================================================== */ printf ("\n Generating a Keypair \n");

printf (" ==================== \n");

if ((status = B_CreateAlgorithmObject (&keypairGenerator)) != 0) break;

keygenParams.modulusBits = RSA_MODULUS_BITS; keygenParams.publicExponent.data = f4Data; keygenParams.publicExponent.len = 3;

/* For this example, AI_RSAStrongKeyGen is used, rather than AI_RSAKeyGen. AI_RSAStrongKeyGen allows you to

specify the parameters for generating an RSA public/private key pair as defined in PKCS#1. The moduli generated

are in conformance with the strength criteria of the ANSI X9.31 standard.*/

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

break;

if ((status = B_GenerateInit (keypairGenerator, X931_SAMPLE_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

if ((status = B_CreateKeyObject (&publicKey)) != 0) break;

if ((status = B_CreateKeyObject (&privateKey)) != 0) break;

/* generalFlag is for the surrender function */ generalFlag = 0;

if ((status = B_GenerateKeypair (keypairGenerator, publicKey, privateKey, randomAlgorithm, &generalSurrenderContext)) != 0)

break;

C h a p t e r 9 P u t t i n g I t A l l To g e t h e r : A n X 9 . 3 1 E x a m p l e

3 1 9

Page 341
Image 341
RSA Security 5.2.2 manual Break