From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.2812.1663895697563537089 for ; Thu, 22 Sep 2022 18:15:07 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=WT6HWpFM; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: qi1.zhang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663895707; x=1695431707; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AJJRqjoJA+nPwpQNkp8mhtwdaFuS64nYsNBXxU5eRPU=; b=WT6HWpFMwBqNwsPMiH6b7wsBir0SsCJj/CX5gCvl3kx8ENSyT6sL/Ax4 FZ1HqhqIn9bqbm1ejjH2qGZn/wul9Hzsu3UfMcpgRm55LqXna+0uiiJW9 tgDkvJJy/1Ju6/+iU5F5hcfW8KJ36N54HZu2KtlAhD0jweV4QS1OUZ6J0 PReJCXIStPb4aZPZWTjOzscr0/eD1JJl/cv5KARVFwUDnE+TNbaiPjox0 /ud+/ZJyOx7madXzTKjLJ4SOb9FgyP+VpxMQqoRb7pdx1DGw9CZVkneGb 6Wd0ikNMuaHzdVKWqXzHQkIstPu4Bl4vxr6oUgAgLKd/X+CxqgxJk53MN g==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="301921227" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="301921227" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 18:15:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="762435052" Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.157.129]) by fmsmga001.fm.intel.com with ESMTP; 22 Sep 2022 18:15:05 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Qi Zhang , Jiewen Yao , Jian J Wang , Xiaoyu Lu , Guomin Jiang Subject: [PATCH v2 5/5] CryptoPkg: add Hmac Sha384 to host UnitTest. Date: Fri, 23 Sep 2022 09:14:52 +0800 Message-Id: <20220923011452.2446-6-qi1.zhang@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20220923011452.2446-1-qi1.zhang@intel.com> References: <20220923011452.2446-1-qi1.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4025 Signed-off-by: Qi Zhang Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang Reviewed-by: Jiewen Yao --- .../BaseCryptLib/UnitTestHostBaseCryptLib.inf | 2 +- .../UnitTest/Library/BaseCryptLib/HmacTests.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf b/= CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf index 11ff1c6931..63282dc5ab 100644 --- a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf @@ -28,7 +28,7 @@ Hash/CryptSha256.c=0D Hash/CryptSha512.c=0D Hash/CryptSm3.c=0D - Hmac/CryptHmacSha256.c=0D + Hmac/CryptHmac.c=0D Kdf/CryptHkdf.c=0D Cipher/CryptAes.c=0D Pk/CryptRsaBasic.c=0D diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c b/Cry= ptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c index 595729424b..9c5b39410d 100644 --- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c +++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c @@ -64,6 +64,23 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha256Dig= est[] =3D { 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, = 0x2e, 0x32, 0xcf, 0xf7=0D };=0D =0D +//=0D +// Key value for HMAC-SHA-384 validation. (From "4. Test Vectors" of IETF = RFC4231)=0D +//=0D +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Key[20] =3D {=0D + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, = 0x0b, 0x0b, 0x0b, 0x0b,=0D + 0x0b, 0x0b, 0x0b, 0x0b=0D +};=0D +=0D +//=0D +// Result for HMAC-SHA-384 ("Hi There"). (From "4. Test Vectors" of IETF R= FC4231)=0D +//=0D +GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Digest[] =3D {=0D + 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, 0x6b, 0x08, 0x25, 0xf4, = 0xab, 0x46, 0x90, 0x7f,=0D + 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, 0x82, 0xaa, 0x03, 0x4c, = 0x7c, 0xeb, 0xc5, 0x9c,=0D + 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, 0x4a, 0xf1, 0x52, 0xe8, = 0xb2, 0xfa, 0x9c, 0xb6=0D +};=0D +=0D typedef=0D VOID *=0D (EFIAPI *EFI_HMAC_NEW)(=0D @@ -109,6 +126,7 @@ typedef struct { // HMAC_TEST_CONTEXT mHmacMd5TestCtx =3D {MD5_DIGEST_SIZE, Hma= cMd5New, HmacMd5SetKey, HmacMd5Update, HmacMd5Final, HmacMd5Key= , sizeof(HmacMd5Key), HmacMd5Digest};=0D // HMAC_TEST_CONTEXT mHmacSha1TestCtx =3D {SHA1_DIGEST_SIZE, Hma= cSha1New, HmacSha1SetKey, HmacSha1Update, HmacSha1Final, HmacSha1Ke= y, sizeof(HmacSha1Key), HmacSha1Digest};=0D HMAC_TEST_CONTEXT mHmacSha256TestCtx =3D { SHA256_DIGEST_SIZE, HmacSha256= New, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, si= zeof (HmacSha256Key), HmacSha256Digest };=0D +HMAC_TEST_CONTEXT mHmacSha384TestCtx =3D { SHA384_DIGEST_SIZE, HmacSha384= New, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, si= zeof (HmacSha384Key), HmacSha384Digest };=0D =0D UNIT_TEST_STATUS=0D EFIAPI=0D @@ -174,6 +192,7 @@ TEST_DESC mHmacTest[] =3D { // -----Description---------------------Class---------------------Functi= on---------------Pre------------------Post------------Context=0D //=0D { "TestVerifyHmacSha256()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHma= c, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha256TestCtx },=0D + { "TestVerifyHmacSha384()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHma= c, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha384TestCtx },=0D // These functions have been deprecated but they've been left commented = out for future reference=0D // {"TestVerifyHmacMd5()", "CryptoPkg.BaseCryptLib.Hmac", TestVerif= yHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacMd5TestCtx},=0D // {"TestVerifyHmacSha1()", "CryptoPkg.BaseCryptLib.Hmac", TestVerif= yHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha1TestCtx},=0D --=20 2.26.2.windows.1