This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HMAC with SHA256 and CCM0 on TM4C129ENCPDT



I'm having difficulty using the SHA/MD5 periperal library code.  I'm trying to calculate a keyed hash of a simple string, namely "Hi There".
 
Using a key consisting of 16 bytes of 0x0B, the resulting keyed hash should be as follows:
 
HMAC-SHA-256 = b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7
 
This example key, data, and expected results come from RFC 4231.
 
The resulting value after the SHAMD5HMACProcess function is not correct.  I have a software implementation under Linux that does result in the expected values so I believe my input data and key are right.
 

Here's the code I'm testing:
 
 
memset(g_ui32HMACKey, 0, sizeof(g_ui32HMACKey));

memset(g_ui32DataToHash, 0, sizeof(g_ui32DataToHash));

for (i=0; i<16; i++)  {  g_ui32HMACKey[i] = 0x0b; }

g_ui32DataToHash[0] = 'H';

g_ui32DataToHash[1] = 'i';

g_ui32DataToHash[2] = ' ';

g_ui32DataToHash[3] = 'T';

g_ui32DataToHash[4] = 'h';

g_ui32DataToHash[5] = 'e';

g_ui32DataToHash[6] = 'r';

g_ui32DataToHash[7] = 'e';

SysCtlPeripheralEnable(SYSCTL_PERIPH_CCM0);

while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0)) { }

SHAMD5Reset(SHAMD5_BASE);

SHAMD5ConfigSet(SHAMD5_BASE, SHAMD5_ALGO_HMAC_SHA256);

SHAMD5HMACKeySet(SHAMD5_BASE, g_ui32HMACKey);

SHAMD5HMACProcess(SHAMD5_BASE, g_ui32DataToHash, 8, pui32HashResult);