Block Ciphers

200 RSA BSAFE Crypto-C Developers Guide

for the surrender context:
Step 5: Final
Step 6: Destroy
Remember to destroy any objects that you created and to free up any memory that has
unsigned char *dataToEncrypt = (unsigned char *)"Encrypt this sentence.";
unsigned int dataToEncryptLen;
unsigned char *encryptedData = NULL_PTR;
unsigned int outputLenUpdate, outputLenFinal, outputLenTotal;
unsigned int encryptedDataLen;
dataToEncryptLen = T_strlen ((char *)dataToEncrypt) + 1;
RSA_PrintBuf ("Data To Encrypt", dataToEncrypt, dataToEncryptLen);
encryptedDataLen = dataToEncryptLen + BLOCK_SIZE;
encryptedData = T_malloc (encryptedDataLen);
if ((status = (encryptedData == NULL_PTR)) != 0) {
status = RSA_DEMO_E_ALLOC;
break;
}
if ((status = B_EncryptUpdate
(rc6Encrypter, encryptedData, &outputLenUpdate,
encryptedDataLen, dataToEncrypt, dataToEncryptLen,
(B_ALGORITHM_OBJ)NULL_PTR,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
if ((status = B_EncryptFinal
(rc6Encrypter, encryptedData + outputLenUpdate,
&outputLenFinal, encryptedDataLen - outputLenUpdate,
(B_ALGORITHM_OBJ)NULL_PTR,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
outputLenTotal = outputLenUpdate + outputLenFinal;