B_BLK_CIPHER_W_FEEDBACK_PARAMS

Block Ciphers

The RC2 Cipher

The RC2 cipher is a variable-key-size block cipher. Whereas a DES key requires eight bytes — no more, no less — an RC2 key can be anywhere between one and 128 bytes. The larger the key, the greater the security. The RC2 cipher is called a block cipher because it encrypts 8-byte blocks. Recall that DES also is a block cipher that encrypts 8-byte blocks. That means the RC2 cipher can serve as a drop-in replacement for DES. The steps for using AI_FeedbackCipher with the RC2 cipher are almost identical to those for DES.

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

Step 1: Creating An Algorithm Object

Declare a variable to be 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 rc2Encrypter = (B_ALGORITHM_OBJ)NULL_PTR;

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

Step 2: Setting The Algorithm Object

There are a number of RC2 AIs from which to choose. Table 4-6 on page 105 gives a summary of AIs. Choose AI_FeedbackCipher; as in the previous example, the format of the info supplied to B_SetAlgorithmInfo is a pointer to a

structure:

typedef struct {

 

 

unsigned char *encryptionMethodName;

/* examples include “des”, “rc5” */

POINTER

encryptionParams;

/* e.g., RC5 parameters */

unsigned char *feedbackMethodName;

 

POINTER

feedbackParams;

/* Points at init vector ITEM */

 

 

/* for all feedback modes except cfb */

unsigned char *paddingMethodName;

 

POINTER

paddingParams;

/* Ignored for now, but may be used */

 

 

/* for new padding schemes */

} B_BLK_CIPHER_W_FEEDBACK_PARAMS;

 

 

 

 

1 8 4

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 206
Image 206
RSA Security 5.2.2 manual RC2 Cipher, Creating An Algorithm Object