mirror of https://github.com/acidanthera/audk.git
CryptoPkg: add Hmac Sha384 to host UnitTest.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4025 Signed-off-by: Qi Zhang <qi1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
3f77ccb9c8
commit
f3c69cb5a1
|
@ -28,7 +28,7 @@
|
||||||
Hash/CryptSha256.c
|
Hash/CryptSha256.c
|
||||||
Hash/CryptSha512.c
|
Hash/CryptSha512.c
|
||||||
Hash/CryptSm3.c
|
Hash/CryptSm3.c
|
||||||
Hmac/CryptHmacSha256.c
|
Hmac/CryptHmac.c
|
||||||
Kdf/CryptHkdf.c
|
Kdf/CryptHkdf.c
|
||||||
Cipher/CryptAes.c
|
Cipher/CryptAes.c
|
||||||
Pk/CryptRsaBasic.c
|
Pk/CryptRsaBasic.c
|
||||||
|
|
|
@ -64,6 +64,23 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha256Digest[] = {
|
||||||
0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7
|
0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Key value for HMAC-SHA-384 validation. (From "4. Test Vectors" of IETF RFC4231)
|
||||||
|
//
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Key[20] = {
|
||||||
|
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
|
||||||
|
0x0b, 0x0b, 0x0b, 0x0b
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Result for HMAC-SHA-384 ("Hi There"). (From "4. Test Vectors" of IETF RFC4231)
|
||||||
|
//
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Digest[] = {
|
||||||
|
0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
|
||||||
|
0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
|
||||||
|
0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6
|
||||||
|
};
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
VOID *
|
VOID *
|
||||||
(EFIAPI *EFI_HMAC_NEW)(
|
(EFIAPI *EFI_HMAC_NEW)(
|
||||||
|
@ -109,6 +126,7 @@ typedef struct {
|
||||||
// HMAC_TEST_CONTEXT mHmacMd5TestCtx = {MD5_DIGEST_SIZE, HmacMd5New, HmacMd5SetKey, HmacMd5Update, HmacMd5Final, HmacMd5Key, sizeof(HmacMd5Key), HmacMd5Digest};
|
// HMAC_TEST_CONTEXT mHmacMd5TestCtx = {MD5_DIGEST_SIZE, HmacMd5New, HmacMd5SetKey, HmacMd5Update, HmacMd5Final, HmacMd5Key, sizeof(HmacMd5Key), HmacMd5Digest};
|
||||||
// HMAC_TEST_CONTEXT mHmacSha1TestCtx = {SHA1_DIGEST_SIZE, HmacSha1New, HmacSha1SetKey, HmacSha1Update, HmacSha1Final, HmacSha1Key, sizeof(HmacSha1Key), HmacSha1Digest};
|
// HMAC_TEST_CONTEXT mHmacSha1TestCtx = {SHA1_DIGEST_SIZE, HmacSha1New, HmacSha1SetKey, HmacSha1Update, HmacSha1Final, HmacSha1Key, sizeof(HmacSha1Key), HmacSha1Digest};
|
||||||
HMAC_TEST_CONTEXT mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };
|
HMAC_TEST_CONTEXT mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };
|
||||||
|
HMAC_TEST_CONTEXT mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest };
|
||||||
|
|
||||||
UNIT_TEST_STATUS
|
UNIT_TEST_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
@ -174,6 +192,7 @@ TEST_DESC mHmacTest[] = {
|
||||||
// -----Description---------------------Class---------------------Function---------------Pre------------------Post------------Context
|
// -----Description---------------------Class---------------------Function---------------Pre------------------Post------------Context
|
||||||
//
|
//
|
||||||
{ "TestVerifyHmacSha256()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha256TestCtx },
|
{ "TestVerifyHmacSha256()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha256TestCtx },
|
||||||
|
{ "TestVerifyHmacSha384()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha384TestCtx },
|
||||||
// These functions have been deprecated but they've been left commented out for future reference
|
// These functions have been deprecated but they've been left commented out for future reference
|
||||||
// {"TestVerifyHmacMd5()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacMd5TestCtx},
|
// {"TestVerifyHmacMd5()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacMd5TestCtx},
|
||||||
// {"TestVerifyHmacSha1()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha1TestCtx},
|
// {"TestVerifyHmacSha1()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha1TestCtx},
|
||||||
|
|
Loading…
Reference in New Issue