mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-28 21:00:54 +00:00
testing/crypto: add SHA2-224 HMAC test case
Add SHA2-224 HMAC verification to the crypto hmac test using CRYPTO_SHA2_224_HMAC through the /dev/crypto interface. Uses standard HMAC test vectors producing a 28-byte digest. Signed-off-by: guao <guao@xiaomi.com>
This commit is contained in:
parent
6a19675e77
commit
c91322216b
1 changed files with 38 additions and 0 deletions
|
|
@ -129,6 +129,20 @@ FAR char *sha1_result[] =
|
|||
"\x97\xc6\x33\x56"
|
||||
};
|
||||
|
||||
FAR char *sha224_result[] =
|
||||
{
|
||||
"\x4e\x84\x1c\xe7\xa4\xae\x83\xfb\xcf\x71\xe3\xcd\x64\xbf\xbf\x27"
|
||||
"\x7f\x73\xa1\x46\x80\xaa\xe8\xc5\x18\xac\x78\x61",
|
||||
"\xa3\x0e\x01\x09\x8b\xc6\xdb\xbf\x45\x69\x0f\x3a\x7e\x9e\x6d\x0f"
|
||||
"\x8b\xbe\xa2\xa3\x9e\x61\x48\x00\x8f\xd0\x5e\x44",
|
||||
"\xcb\xff\x7c\x27\x16\xbb\xaa\x7c\x77\xbe\xd4\xf4\x91\xd3\xe8\x45"
|
||||
"\x6c\xb6\xc5\x74\xe9\x2f\x67\x2b\x29\x1a\xcf\x5b",
|
||||
"\x1b\xf1\xc2\x0e\x5b\x2e\x25\x3f\x51\x39\x5e\x1f\x22\xe1\x52\x06"
|
||||
"\xb3\x99\x24\x1d\x72\xa9\xa1\xa4\x60\x2d\x3e\x31",
|
||||
"\x76\x7d\xf3\x5c\x24\xcd\x61\xa4\xd7\xd3\xf0\xf4\xc3\xa2\xf2\x53"
|
||||
"\x99\x8a\x1e\x4a\x4e\x54\x22\x3c\x19\x95\x14\x10"
|
||||
};
|
||||
|
||||
FAR char *sha256_result[] =
|
||||
{
|
||||
"\x49\x2c\xe0\x20\xfe\x25\x34\xa5\x78\x9d\xc3\x84\x88\x06\xc7\x8f"
|
||||
|
|
@ -245,6 +259,7 @@ int main(void)
|
|||
{
|
||||
char output[32];
|
||||
int ret = 0;
|
||||
|
||||
for (int i = 0; i < nitems(testcase); i++)
|
||||
{
|
||||
ret += syshmac(CRYPTO_MD5_HMAC, testcase[i].key,
|
||||
|
|
@ -291,6 +306,29 @@ int main(void)
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < nitems(testcase); i++)
|
||||
{
|
||||
ret = syshmac(CRYPTO_SHA2_224_HMAC, testcase[i].key,
|
||||
testcase[i].keylen,
|
||||
testcase[i].data, testcase[i].datalen, output);
|
||||
if (ret)
|
||||
{
|
||||
printf("syshamc sha224 failed\n");
|
||||
}
|
||||
|
||||
ret = match((unsigned char *)sha224_result[i],
|
||||
(unsigned char *)output,
|
||||
SHA224_DIGEST_LENGTH);
|
||||
if (ret)
|
||||
{
|
||||
printf("match sha224 failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("hmac sha224 success\n");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < nitems(testcase); i++)
|
||||
{
|
||||
ret = syshmac(CRYPTO_SHA2_256_HMAC, testcase[i].key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue