RSA Security 5.2.2 manual Block Ciphers, DES with CBC

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 200
Image 200

Block Ciphers

Block Ciphers

DES with CBC

The example in this section corresponds to the file descbc.c.

Step 1: Creating an Algorithm Object

Declare a variable to be a B_ALGORITHM_OBJ. As defined in the function prototype in Chapter 4 of the Reference Manual, its address is the argument for B_CreateAlgorithmObject:

B_ALGORITHM_OBJ encryptionObject = (B_ALGORITHM_OBJ)NULL_PTR;

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

Step 2: Setting the Algorithm Object

There are a number of DES AIs from which to choose. See Table 4-6 on page 105 for a summary. For this example, choose AI_FeedbackCipher. AI_FeedbackCipher is a general-purpose AI that allows you to choose different block cipher methods, such as DES, the RC2 cipher, and the RC5 cipher. It also allows you to choose different feedback methods for your cipher. This makes updating your program to use a different block cipher or feedback method easy: you simply have to replace the arguments.

See “Block Ciphers” on page 37 of this manual for an overview of block cipher algorithms and feedback methods. We will implement DES in CBC mode using the padding scheme defined in PKCS V#5.

The description of AI_FeedbackCipher in Chapter 2 of the Reference Manual says that the format of the info supplied to B_SetAlgorithmInfo is a pointer to a B_BLK_CIPHER_W_FEEDBACK_PARAMS structure:

1 7 8

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 200
Image 200
RSA Security 5.2.2 manual Block Ciphers, DES with CBC, Example in this section corresponds to the file descbc.c