System Considerations In Crypto-C

RC5, or RSA encryption. So we could have built an algorithm chooser that included only one AM, the one we used for RC4 encryption.

To find the AM we need, look at the Reference Manual, Chapter 2, for the entry on the AI in use. We used AI_RC4. The Reference Manual states that for this AI, the possible AMs are AM_RC4_ENCRYPT for encrypting and AM_RC4_DECRYPT for decrypting. Because we did not decrypt, our algorithm chooser only needs to include AM_RC4_ENCRYPT:

B_ALGORITHM_METHOD *INTRODUCTORY_CHOOSER[] = { &AM_RC4_ENCRYPT,

(B_ALGORITHM_METHOD *)NULL_PTR

};

The last entry of an algorithm chooser must be (B_ALGORITHM_METHOD *)NULL_PTR.

As an argument in a Crypto-C function call, it would look like this.

if ((status = B_<function> ( <arguments>, INTRODUCTORY_CHOOSER, <other arguments>)) != 0)

break;

An RSA Algorithm Chooser

In this example, we will build an algorithm chooser for the example in “Performing RSA Operations” on page 214. We want to include all the AMs for generating an RSA key pair, encrypting, and decrypting. We need the following: a random number generator, a key pair generator, an RSA public encryption algorithm, and an RSA private decryption algorithm. (Although the example doesn’t directly include a random-number generator, it calls on the one from “Generating Random Numbers” on page 165.)

The AIs used in the example are: AI_X962Random_V0 (also known as AI_SHA1Random), AI_RSAKeyGen, AI_PKCS_RSAPublic, and AI_PKCS_RSAPrivate.

Note: AI_SHA1Random is identical to AI_X962Random_V0. The name AI_SHA1Random is used in the demo applications; however, AI_SHA1Random may change in future versions of Crypto-C. For forward compatibility, we recommend that you do not use the name AI_SHA1Random in your applications; use AI_X962Random_V0 instead.

From the corresponding entries in Chapter 2 of the Reference Manual, you can construct the following algorithm chooser. Note that you should reference the

C h a p t e r 4 U s i n g C r y p t o - C

1 1 7

Page 139
Image 139
RSA Security 5.2.2 manual An RSA Algorithm Chooser, Break