Block Ciphers

for the surrender context:

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;

Step 5: Final

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;

Step 6: Destroy

Remember to destroy any objects that you created and to free up any memory that has

2 0 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 222
Image 222
RSA Security 5.2.2 manual For the surrender context, Break OutputLenTotal = outputLenUpdate + outputLenFinal