RSA Security 5 manual Bdemo Algorithm Chooser, Defining an Algorithm Chooser

Models: 5

1 376
Download 376 pages 51.16 Kb
Page 20
Image 20

The Algorithm Chooser

The Algorithm Chooser

The algorithm chooser lists all the algorithm methods that Crypto-C will use in the application. In this way, you only link in the code you need, and thereby reduce the executable size.

The BDEMO Algorithm Chooser

The BDEMO demonstration application supplied with Crypto-C defines an algorithm chooser called DEMO_ALGORITHM_CHOOSER. To use the BDEMO algorithm chooser, compile and link the module that defines DEMO_ALGORITHM_CHOOSER (as it is done for BDEMO) and specify DEMO_ALGORITHM_CHOOSER as the algorithmChooser argument.

Defining an Algorithm Chooser

The main reason for an application to define its own algorithm chooser is to make the executable image smaller. The linker links in the object code for all algorithm methods listed in the algorithm chooser. To illustrate, an application that only uses MD5 and DES-CBC may define an algorithm chooser with only the MD5 and DES-CBC methods. In this way, the linker will only link in the object code related to MD5 and DES-CBC.

An algorithm chooser is an array of pointers to B_ALGORITHM_METHOD values. The last element of the array must be (B_ALGORITHM_METHOD *)NULL_PTR. The following is an example that defines an algorithm chooser called MD5_DES_CBC_CHOOSER for the MD5 and DES-CBC algorithm methods needed when using the AI_MD5WithDES_CBCPad algorithm info type:

B_ALGORITHM_METHOD *MD5_DES_CBC_CHOOSER[] = { &AM_MD5,

&AM_DES_CBC_ENCRYPT,

&AM_DES_CBC_DECRYPT,

(B_ALGORITHM_METHOD *)NULL_PTR };

For additional examples of algorithm choosers, see “Algorithm Choosers” on page 118 of the User’s Manual.

Notice that encryption/decryption algorithm methods (AMs) such as DES-CBC, have separate entries for encryption and decryption. This separation of methods enables a

1 0

R S A B S A F E C r y p t o - C L i b r a r y R e f e r e n c e M a n u a l

Page 20
Image 20
RSA Security 5 manual Bdemo Algorithm Chooser, Defining an Algorithm Chooser