Block Ciphers

been allocated:

B_DestroyAlgorithmObject (&rc6Encrypter);

if (rc6KeyItem.data != NULL_PTR) {

T_memset (rc6KeyItem.data, 0, rc6KeyItem.len); T_free (rc6KeyItem.data);

rc6KeyItem.data = NULL_PTR; rc6KeyItem.len = 0;

}

Decrypting

As in the “Introductory Example” on page 9, decrypting is similar to encrypting. Use the same AI, IV, and key data. Use the proper decrypting AM and call B_DecryptInit, B_DecryptUpdate, and B_DecryptFinal.

The AES Cipher

The AES Cipher, Rijndael, is the replacement for the Data Encryption Standard (DES). The example in this section corresponds to the file aes.c.

Step 1: Create

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

/* Create an algorithm object. */

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

Step 2: Set

For this example, you will perform an AES operation in CBC mode using PKCS V#5 padding. To do this, use AI_AES_CBCPad in the call to B_SetAlgorithmInfo. Notice that, as specified in the Reference Manual entry for AI_AES_CBCPad, this AI requires an initialization vector. This is due to using CBC. This AI requires an unsigned char *iv as its parameters.

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

2 0 1

Page 223
Image 223
RSA Security 5.2.2 manual AES Cipher, Been allocated