RSA Security 5.2.2 Projection Television User Manual


 
Hash-Based Message Authentication Code (HMAC)
164 RSA BSAFE Crypto-C Developers Guide
Step 5: Final
After the data to digest has been processed by calls to B_DigestUpdate, call
B_DigestFinal. You need to pass a pointer to the location where B_DigestFinal can
store the output. In the case of
AI_HMAC using SHA1, you need 20 bytes to store the
result.
Step 6: Destroy
Once you have generated the message authentication code, destroy any objects you
used, and free up any memory you allocated:
unsigned char *digestedData;
unsigned int digestedDataLen;
digestedData = T_malloc (20);
if ((status = (digestedData == NULL_PTR)) != 0)
break;
if ((status = B_DigestFinal
(HMACDigester, digestedData, &digestedDataLen,
20, (A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
B_DestroyKeyObject (&HMACKey);
B_DestroyAlgorithmObject (&randomAlgorithm);
B_DestroyAlgorithmObject (&HMACDigester);
if (digestedData != NULL_PTR) {
T_memset (digestedData, 0, 20);
T_free (digestedData);
digestedData = NULL_PTR;
digestedDataLen = 0;
}