Block Ciphers

/*

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

/*

call B_GenerateRandomBytes.

*/

if ((status = B_GenerateRandomBytes (randomAlgorithm, ivBytes, 8, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

ivItem.data = ivBytes; ivItem.len = 8;

You must also indicate that you want to use the standard CBC padding which is defined in PKCS#5; do this by setting fbParams.paddingMethodName to "pad". You do not need to pass in any padding parameters for this padding scheme. Again, “Block Ciphers” on page 37 explains padding.

Now set up the B_BLK_CIPHER_W_FEEDBACK_PARAMS structure:

fbParams.encryptionMethodName = (unsigned char *)"des"; fbParams.encryptionParams = NULL_PTR; fbParams.feedbackMethodName = (unsigned char *)"cbc"; fbParams.feedbackParams = (POINTER)&ivItem; fbParams.paddingMethodName = (unsigned char *)"pad"; fbParams.paddingParams = NULL_PTR;

if ((status = B_SetAlgorithmInfo

(encryptionObject, AI_FeedbackCipher,(POINTER)&fbParams)) != 0) break;

Step 3: Init

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

Step 3a: Creating the Key Object

B_KEY_OBJ desKey = (B_KEY_OBJ)NULL_PTR;

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

1 8 0

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 202
Image 202
RSA Security 5.2.2 manual Call BGenerateRandomBytes, Now set up the Bblkcipherwfeedbackparams structure