Block Ciphers
192 RSA BSAFE Crypto-C Developers Guide
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
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 B_SetKeyInfo
is a pointer to an ITEM struct, defined in algobal.h:
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;
B_KEY_OBJ rc5Key = (B_KEY_OBJ)NULL_PTR;
if ((status = B_CreateKeyObject (&rc5Key)) != 0)
break;