Hash-Based Message Authentication Code (HMA C)
162 RSA BSAFE Crypto-C Developers Guide
Step 3: Init
For hash-based message authentication, you need a key before you can initialize the
object.
Step 3a: Creating the Key Object
Create the key object:
Step 3b: Setting the Key Object
Generate a random 24-byte key using KI_24Byte:
B_DIGEST_SPECIFIER hmacInfo;
hmacInfo.digestInfoType = AI_SHA1;
hmacInfo.digestInfoParams = NULL_PTR;
if ((status = B_SetAlgorithmInfo
(HMACDigester, AI_HMAC, (POINTER)&hmacInfo)) != 0)
break;
#define KEY_SIZE 24
B_KEY_OBJ HMACKey = (B_KEY_OBJ)NULL_PTR;
unsigned char *keyData;
/* Create a key object */
if ((status = B_CreateKeyObject (&HMACKey)) != 0)
break;
ITEM keyDataItem = {NULL,0};
keyData = T_malloc (KEY_SIZE);
if ((status = (keyData == NULL_PTR)) != 0)
break;