Block Ciphers
180 RSA BSAFE Crypto-C Developers Guide
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:
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
/* 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;
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;
B_KEY_OBJ desKey = (B_KEY_OBJ)NULL_PTR;
if ((status = B_CreateKeyObject (&desKey)) != 0)
break;