Chapter 4 Using Crypto-C 117
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:
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.
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 th e 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 doesnt directly include a
random-number generator, it calls on the one from Generating Random Numbers
on page165.)
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
B_ALGORITHM_METHOD *INTRODUCTORY_CHOOSER[] = {
&AM_RC4_ENCRYPT,
(B_ALGORITHM_METHOD *)NULL_PTR
};
if ((status = B_<function> (
<arguments>, INTRODUCTORY_CHOOSER,
<other arguments>)) != 0)
break;