RSA Security 5.2.2 Projection Television User Manual


 
Chapter 2 Quick Start 15
Introductory Example
Now we can complete the call to B_SetKeyInfo:
As with algorithm objects, once you have set a key object, you should not set it again.
If you need another key object, you should create a new one.
Note: In a real application, for security reasons, you might want to zeroize and free
your key data immediately after setting the key.
Now that we have created and set our key object,
rc4Key
, we can pass it as the second
argument to
B_EncryptInit.
Selecting an Algorithm Chooser
The third argument to B_EncryptInit is an algorithm chooser; this is a structure that
specifies which algorithm methods to link in. An algorithm method (AM) is the
underlying code that actually performs the cryptographic operation. Because many
AIs can perform more than one cryptographic function (for example,
AI_RC4 can
perform encryption and decryption), an application often has a choice of which
underlying algorithm methods need to be linked in.
An algorithm chooser lists all the AMs the application will use; only these AMs will
be linked in. Crypto-C comes with a demonstration application containing the
algorithm chooser
DEMO_ALGORITHM_CHOOSER. You can use this algorithm chooser in
any Crypto-C application as long as the module which defines it (
choosc.c) is
compiled and linked in. However,
DEMO_ALGORITHM_CHOOSER will link in all the
algorithm methods available, even though an application might use only two or three.
A developer can write an algorithm chooser for the specific application to make the
executable image smaller. See Algorithm Choosers on page 116 in this manual for
static unsigned char rc4KeyData[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10
};
ITEM rc4KeyItem;
rc4KeyItem.data = rc4KeyData;
rc4KeyItem.len = sizeof(rc4keyData);
if ((status = B_SetKeyInfo
(rc4Key, KI_Item, (POINTER)&rc4KeyItem)) != 0)
break;