RSA Security 5.2.2 manual Final

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 233
Image 233

Block Ciphers

Step 5: Final

unsigned int outputLenFinal;

if ((status = B_EncryptFinal

(pbEncrypter, encryptedData + outputLenUpdate, &outputLenFinal, encryptedDataLen - outputLenUpdate, (B_ALGORITHM_OBJ)NULL_PTR,

(A_SURRENDER_CTX *)NULL_PTR)) != 0) break;

Step 6: Destroy

Remember to destroy all objects and free up any allocated memory:

B_DestroyKeyObject (&pbeKey);

B_DestroyAlgorithmObject (&pbEncrypter);

B_DestroyAlgorithmObject (&randomAlgorithm);

if (pbeKeyItem.data, 0, MAX_PW_LEN) { T_memset (pbeKeyItem.data, 0, MAX_PW_LEN); T_free (pbekeyItem.data); pbeKeyItem.data = NULL_PTR;

}

if (encryptedData != NULL_PTR) {

T_memset (encryptedData, 0, encryptedDataLen); T_free (encryptedData);

encryptedData = NULL_PTR;

}

Decrypting

As in the “Introductory Example” on page 9, decrypting is similar to encrypting. Use the same AI, password, and salt. Use the proper decrypting AM and call B_DecryptInit, B_DecryptUpdate, and B_DecryptFinal.

C h a p t e r 6 S y m m e t r i c - K e y O p e r a t i o n s

2 1 1

Page 233
Image 233
RSA Security 5.2.2 manual Final