B_SetKeyInfo

Block Ciphers

unsigned char initVector[8]; A_RC5_CBC_PARAMS rc5Params;

/* Complete steps 1 - 4 of Generating Random Numbers, then call B_GenerateRandomBytes. */

if ((status = B_GenerateRandomBytes (randomAlgorithm, (unsigned char *)initVector, 8, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

rc5Params.version = 0x10; rc5Params.rounds = 12; rc5Params.wordSizeInBits = 32; rc5Params.iv = (unsigned char *)initVector;

if ((status = B_SetAlgorithmInfo

(rc5Encrypter, AI_RC5_CBCPad, (POINTER)&rc5Params)) != 0) break;

Step 3: Init

You need a key before you can initialize the algorithm object for encryption. You will first create a key object, then set the key object.

Step 3a: Creating A Key Object

B_KEY_OBJ rc5Key = (B_KEY_OBJ)NULL_PTR;

if ((status = B_CreateKeyObject (&rc5Key)) != 0) break;

Step 3b: Setting The Key Object

For this example, you will use 10 key bytes (80 bits). In the Reference Manual Chapter 2 entry for AI_RC5_CBCPad, you see you must use KI_Item. Looking up KI_Item in Chapter 3 of the Reference Manual, you find that the info you supply to

is a pointer to an ITEM struct, defined in algobal.h:

1 9 2

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 214
Image 214
RSA Security 5.2.2 manual Unsigned char initVector8 ARC5CBCPARAMS rc5Params