34 lines
944 B
C
34 lines
944 B
C
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
|
|
#include "hmac.h"
|
|
#include "global.h"
|
|
|
|
bool
|
|
test_hmac(void)
|
|
{
|
|
uint8_t key[32];
|
|
uint8_t input[64];
|
|
uint8_t output[64];
|
|
size_t output_sz;
|
|
|
|
uint8_t output_sample[] = {
|
|
0x7b, 0x4a, 0xf4, 0x20, 0x98, 0x0c, 0xeb, 0xfa, 0xc1, 0x42, 0xf1, 0x33, 0x66, 0x9d, 0x05, 0xe5,
|
|
0x8d, 0x6d, 0x47, 0x49, 0x88, 0xd9, 0x48, 0x22, 0x04, 0xa2, 0xd1, 0x70, 0xf4, 0x59, 0x2c, 0x73,
|
|
0xea, 0xd5, 0xc3, 0xf0, 0x8a, 0x8e, 0xe4, 0xf1, 0x9d, 0xfa, 0x13, 0x81, 0x8a, 0xbf, 0xb7, 0xb4
|
|
};
|
|
|
|
memset(key, 0x01, sizeof(key));
|
|
memset(input, 0x02, sizeof(input));
|
|
|
|
if (IOTELIC_OK != hmac(HASH_SHA_384,
|
|
key, sizeof(key),
|
|
input, sizeof(input),
|
|
output, sizeof(output), &output_sz)) {
|
|
return false;
|
|
}
|
|
|
|
return 0 == memcmp(output, output_sample, output_sz);
|
|
}
|