Code Example
if ((status = B_CreateAlgorithmObject (&desAlgorithm)) != 0) break;
initVector.data = iv; initVector.len = 8; feedbackParams.encryptionMethodName = “des”; feedbackParams.encryptionParams = NULL_PTR; feedbackParams.feedbackMethodName = “cbc”; feedbackParams.feedbackParams = initVector; feedbackParams.paddingMethodName = “pad”; feedbackParams.paddingParams = NULL_PTR;
if ((status = B_SetAlgorithmInfo (desAlgorithm, (POINTER)&AI_FeedbackCipher, (POINTER)&feedbackParams)) != 0)
break;
if ((status = B_EncryptInit
(desAlgorithm, desKey, DEMO_ALGORITHM_CHOOSER, NULL_SURRENDER_PTR)) != 0)
break;
if ((status = B_EncryptUpdate
(desAlgorithm, output, outputLen, maxOutputLen, input, inputLen, (B_ALGORITHM_OBJ)NULL_PTR, NULL_SURRENDER_PTR)) != 0)
break;
if ((status = B_EncryptFinal
(desAlgorithm, output + *outputLen, &partOutLen, maxOutputLen - *outputLen, (B_ALGORITHM_OBJ)NULL_PTR, NULL_SURRENDER_PTR)) != 0)
break;
*outputLen += partOutLen; } while (0);
B_KEY_OBJ desKey = (B_KEY_OBJ)NULL_PTR;
B_ALGORITHM_OBJ desAlgorithm = (B_ALGORITHM_OBJ)NULL_PTR; return (status);
}
The main work in EncryptData is done by the functions B_EncryptInit,
B_EncryptUpdate, and B_EncryptFinal. The calling format for these and other functions is shown in Chapter 4, “Details of
6 | R S A B S A F E C r y p t o - C L i b r a r y R e f e r e n c e M a n u a l |