Chapter 6 Symmetric-Key Operations 201
Block Ciphers
been allocated:
Decrypting
As in the Introductory Example on page9, 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.

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.
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;
}
/* Create an algorithm object. */
if ((status = B_CreateAlgorithmObject (&aesEncrypter)) != 0)
break;