RSA Security 5.2.2 manual 0x10 Unsigned int, Initialization vector

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 213
Image 213

Block Ciphers

B_ALGORITHM_OBJ rc5Encrypter = (B_ALGORITHM_OBJ)NULL_PTR;

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

Step 2: Setting The Algorithm Object

There are a number of RC5 AIs from which to choose. Table 4-6 on page 105 describes the AIs. For this example, you will use a different cipher from AI_FeedbackCipher. Choose AI_RC5_CBCPad. The Reference Manual Chapter 2 entry for this AI indicates that the format of info supplied to B_SetAlgorithmInfo is:

typedef struct {

 

 

 

 

unsigned int

version;

/* currently 1.0 defined

0x10

*/

unsigned int

rounds;

/* number of rounds (0 -

255)

*/

unsigned int

wordSizeInBits;

/* AI_RC5_CBCPad requires 32 */

unsigned char

*iv;

/* initialization vector */

} A_RC5_CBC_PARAMS;

As a provision for future revisions of the RC5 algorithm, Crypto-C includes a version number. So that the version number can be one byte, it is two hex digits. Version 1.0 is therefore 0x10. Version 3.8, if there ever is one, would be 0x38. The hex number 0x10 is the decimal number 16. Both are valid, but it is probably better to use 0x10 because it is easier to see as a version number.

For this example, you will use 12 rounds with a word size of 32.

Because you have chosen an AI that uses Cipher Block Chaining (CBC), you need an initialization vector. Use a random number generator to produce an IV. Because the word size is 32, the block size is 64 bits or eight bytes, and your IV must be eight bytes long. Remember, the IV is not secret and will not assist anyone in breaking the encryption. Its size will be eight bytes, because the RC5 cipher encrypts blocks of eight bytes. Remember, the IV is related to the block, not the key:

C h a p t e r 6 S y m m e t r i c - K e y O p e r a t i o n s

1 9 1

Page 213
Image 213
RSA Security 5.2.2 manual 0x10 Unsigned int, Initialization vector