Hash-Based Message Authentication Code (HMAC)

B_DIGEST_SPECIFIER hmacInfo;

hmacInfo.digestInfoType = AI_SHA1; hmacInfo.digestInfoParams = NULL_PTR;

if ((status = B_SetAlgorithmInfo

(HMACDigester, AI_HMAC, (POINTER)&hmacInfo)) != 0) break;

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:

#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;

Step 3b: Setting the Key Object

Generate a random 24-byte key using KI_24Byte:

ITEM keyDataItem = {NULL,0}; keyData = T_malloc (KEY_SIZE);

if ((status = (keyData == NULL_PTR)) != 0) break;

1 6 2

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 184
Image 184
RSA Security 5.2.2 manual Hash-Based Message Authentication Code Hmac, Create the key object