From nobody Mon Feb 9 15:07:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+92845+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92845+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1661495577; cv=none; d=zohomail.com; s=zohoarc; b=ldHxhZno85Y7TXYQu510hhagReAWCW4N1NUrd0gtubrZX/2taZ+ZXHIVLEnnBn4rxCCXYSPQCLlOKE1HWAnND7uG4YdEP7ehvNAR119aKzlFRgaBFJxWPQqzdAnPLIUMUISXVxjrCinmueNTwzyGYfrfgvA5Kq0RCO3GYhkLvxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661495577; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=q6fd4Eo+HQUb2h+DN3QG8AXSA4f8TKOPmIFmfv80ekM=; b=AfhperpJZCAmJcc4oZgO0BKzM2ggrpi7JTkM/sEFg2K+ZZufihrqR1Kq/rmqb/1DIuSGsLgXBRMssIas8WzneB/M0ywiVPiFJB0wrChxjgcAanK2FgubSNqzZzS/k+4XXT+5sWnHpR5nwLVicbfnylxgXroEiTTXabQ2BEtVLis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92845+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1661495577564442.08755630892426; Thu, 25 Aug 2022 23:32:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FKwuYY1788612xYmip21tE8I; Thu, 25 Aug 2022 23:32:57 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.34161.1661495572044873211 for ; Thu, 25 Aug 2022 23:32:56 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="295217244" X-IronPort-AV: E=Sophos;i="5.93,264,1654585200"; d="scan'208";a="295217244" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2022 23:32:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,264,1654585200"; d="scan'208";a="561335793" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.157.129]) by orsmga003.jf.intel.com with ESMTP; 25 Aug 2022 23:32:52 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Qi Zhang , Jiewen Yao , Jian J Wang , Xiaoyu Lu , Guomin Jiang Subject: [edk2-devel] [PATCH 2/4] CryptoPkg: add new Hkdf api in Crypt Lib. Date: Fri, 26 Aug 2022 14:32:41 +0800 Message-Id: <20220826063243.7855-3-qi1.zhang@intel.com> In-Reply-To: <20220826063243.7855-1-qi1.zhang@intel.com> References: <20220826063243.7855-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,qi1.zhang@intel.com X-Gm-Message-State: lO7nEZgqDv0GXP0cAsPcPAdex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1661495577; bh=fnRmgxfDN3nSYolgR662gNvDNmUCQPJEeEgqOPnM3Lk=; h=Cc:Date:From:Reply-To:Subject:To; b=kqn4weeeDP3YG9m5/yhP/NalZ0QN9ecplq+X8DX9zSsTYmUoS4l12S2uWj8fIjbDcNv T7z98TVTO05hpkpVSgMbLzt+jDfvTJAh+6cdjs1hL3hZs+Gi0oUj4NHWP+sVMuBkE4NhA TSQtGQbaD3rgNsJqDpUzHk8DdKq8zWO2mq0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1661495577944100009 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4033 Signed-off-by: Qi Zhang Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang --- .../Library/BaseCryptLib/Kdf/CryptHkdf.c | 362 +++++++++++++++++- .../Library/BaseCryptLib/Kdf/CryptHkdfNull.c | 151 +++++++- .../BaseCryptLibNull/Kdf/CryptHkdfNull.c | 151 +++++++- 3 files changed, 650 insertions(+), 14 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c b/CryptoPkg/Lib= rary/BaseCryptLib/Kdf/CryptHkdf.c index 9457b04f72..ffaf5fb131 100644 --- a/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c +++ b/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c @@ -1,7 +1,7 @@ /** @file HMAC-SHA256 KDF Wrapper Implementation over OpenSSL. =20 -Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /** Derive HMAC-based Extract-and-Expand Key Derivation Function (HKDF). =20 + @param[in] Md Message Digest. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. @param[in] Salt Pointer to the salt(non-secret) value. @@ -27,16 +28,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ BOOLEAN -EFIAPI -HkdfSha256ExtractAndExpand ( - IN CONST UINT8 *Key, - IN UINTN KeySize, - IN CONST UINT8 *Salt, - IN UINTN SaltSize, - IN CONST UINT8 *Info, - IN UINTN InfoSize, - OUT UINT8 *Out, - IN UINTN OutSize +HkdfMdExtractAndExpand ( + IN CONST EVP_MD *Md, + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize ) { EVP_PKEY_CTX *pHkdfCtx; @@ -55,7 +56,7 @@ HkdfSha256ExtractAndExpand ( =20 Result =3D EVP_PKEY_derive_init (pHkdfCtx) > 0; if (Result) { - Result =3D EVP_PKEY_CTX_set_hkdf_md (pHkdfCtx, EVP_sha256 ()) > 0; + Result =3D EVP_PKEY_CTX_set_hkdf_md (pHkdfCtx, Md) > 0; } =20 if (Result) { @@ -78,3 +79,340 @@ HkdfSha256ExtractAndExpand ( pHkdfCtx =3D NULL; return Result; } + +/** + Derive HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Md message digest. + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +HkdfMdExtract ( + IN CONST EVP_MD *Md, + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + EVP_PKEY_CTX *pHkdfCtx; + BOOLEAN Result; + + if ((Key =3D=3D NULL) || (Salt =3D=3D NULL) || (PrkOut =3D=3D NULL) || + (KeySize > INT_MAX) || (SaltSize > INT_MAX) || + (PrkOutSize > INT_MAX)) + { + return FALSE; + } + + pHkdfCtx =3D EVP_PKEY_CTX_new_id (EVP_PKEY_HKDF, NULL); + if (pHkdfCtx =3D=3D NULL) { + return FALSE; + } + + Result =3D EVP_PKEY_derive_init (pHkdfCtx) > 0; + if (Result) { + Result =3D EVP_PKEY_CTX_set_hkdf_md (pHkdfCtx, Md) > 0; + } + + if (Result) { + Result =3D + EVP_PKEY_CTX_hkdf_mode ( + pHkdfCtx, + EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY + ) > 0; + } + + if (Result) { + Result =3D EVP_PKEY_CTX_set1_hkdf_salt ( + pHkdfCtx, + Salt, + (uint32_t)SaltSize + ) > 0; + } + + if (Result) { + Result =3D EVP_PKEY_CTX_set1_hkdf_key ( + pHkdfCtx, + Key, + (uint32_t)KeySize + ) > 0; + } + + if (Result) { + Result =3D EVP_PKEY_derive (pHkdfCtx, PrkOut, &PrkOutSize) > 0; + } + + EVP_PKEY_CTX_free (pHkdfCtx); + pHkdfCtx =3D NULL; + return Result; +} + +/** + Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Md Message Digest. + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +HkdfMdExpand ( + IN CONST EVP_MD *Md, + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + EVP_PKEY_CTX *pHkdfCtx; + BOOLEAN Result; + + if ((Prk =3D=3D NULL) || (Info =3D=3D NULL) || (Out =3D=3D NULL) || + (PrkSize > INT_MAX) || (InfoSize > INT_MAX) || (OutSize > INT_MAX)) + { + return FALSE; + } + + pHkdfCtx =3D EVP_PKEY_CTX_new_id (EVP_PKEY_HKDF, NULL); + if (pHkdfCtx =3D=3D NULL) { + return FALSE; + } + + Result =3D EVP_PKEY_derive_init (pHkdfCtx) > 0; + if (Result) { + Result =3D EVP_PKEY_CTX_set_hkdf_md (pHkdfCtx, Md) > 0; + } + + if (Result) { + Result =3D EVP_PKEY_CTX_hkdf_mode (pHkdfCtx, EVP_PKEY_HKDEF_MODE_EXPAN= D_ONLY) > 0; + } + + if (Result) { + Result =3D EVP_PKEY_CTX_set1_hkdf_key (pHkdfCtx, Prk, (UINT32)PrkSize)= > 0; + } + + if (Result) { + Result =3D EVP_PKEY_CTX_add1_hkdf_info (pHkdfCtx, Info, (UINT32)InfoSi= ze) > 0; + } + + if (Result) { + Result =3D EVP_PKEY_derive (pHkdfCtx, Out, &OutSize) > 0; + } + + EVP_PKEY_CTX_free (pHkdfCtx); + pHkdfCtx =3D NULL; + return Result; +} + +/** + Derive HMAC-based Extract-and-Expand Key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize Key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize Salt size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256ExtractAndExpand ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + return HkdfMdExtractAndExpand (EVP_sha256 (), Key, KeySize, Salt, SaltSi= ze, Info, InfoSize, Out, OutSize); +} + +/** + Derive SHA256 HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256Extract ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + return HkdfMdExtract ( + EVP_sha256 (), + Key, + KeySize, + Salt, + SaltSize, + PrkOut, + PrkOutSize + ); +} + +/** + Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256Expand ( + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + return HkdfMdExpand (EVP_sha256 (), Prk, PrkSize, Info, InfoSize, Out, O= utSize); +} + +/** + Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKD= F). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize Key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize Salt size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384ExtractAndExpand ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + return HkdfMdExtractAndExpand (EVP_sha384 (), Key, KeySize, Salt, SaltSi= ze, Info, InfoSize, Out, OutSize); +} + +/** + Derive SHA384 HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384Extract ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + return HkdfMdExtract ( + EVP_sha384 (), + Key, + KeySize, + Salt, + SaltSize, + PrkOut, + PrkOutSize + ); +} + +/** + Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384Expand ( + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + return HkdfMdExpand (EVP_sha384 (), Prk, PrkSize, Info, InfoSize, Out, O= utSize); +} diff --git a/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdfNull.c b/CryptoPkg= /Library/BaseCryptLib/Kdf/CryptHkdfNull.c index 19d795a4cc..d8c967d669 100644 --- a/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdfNull.c +++ b/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdfNull.c @@ -1,7 +1,7 @@ /** @file HMAC-SHA256 KDF Wrapper Implementation which does not provide real capab= ilities. =20 -Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -41,3 +41,152 @@ HkdfSha256ExtractAndExpand ( ASSERT (FALSE); return FALSE; } + +/** + Derive SHA256 HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256Extract ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256Expand ( + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKD= F). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize Key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize Salt size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384ExtractAndExpand ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA384 HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384Extract ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384Expand ( + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} diff --git a/CryptoPkg/Library/BaseCryptLibNull/Kdf/CryptHkdfNull.c b/Crypt= oPkg/Library/BaseCryptLibNull/Kdf/CryptHkdfNull.c index 19d795a4cc..d8c967d669 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Kdf/CryptHkdfNull.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Kdf/CryptHkdfNull.c @@ -1,7 +1,7 @@ /** @file HMAC-SHA256 KDF Wrapper Implementation which does not provide real capab= ilities. =20 -Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -41,3 +41,152 @@ HkdfSha256ExtractAndExpand ( ASSERT (FALSE); return FALSE; } + +/** + Derive SHA256 HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256Extract ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha256Expand ( + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKD= F). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize Key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize Salt size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384ExtractAndExpand ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA384 HMAC-based Extract key Derivation Function (HKDF). + + @param[in] Key Pointer to the user-supplied key. + @param[in] KeySize key size in bytes. + @param[in] Salt Pointer to the salt(non-secret) value. + @param[in] SaltSize salt size in bytes. + @param[out] PrkOut Pointer to buffer to receive hkdf value. + @param[in] PrkOutSize size of hkdf bytes to generate. + + @retval true Hkdf generated successfully. + @retval false Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384Extract ( + IN CONST UINT8 *Key, + IN UINTN KeySize, + IN CONST UINT8 *Salt, + IN UINTN SaltSize, + OUT UINT8 *PrkOut, + UINTN PrkOutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF). + + @param[in] Prk Pointer to the user-supplied key. + @param[in] PrkSize Key size in bytes. + @param[in] Info Pointer to the application specific info. + @param[in] InfoSize Info size in bytes. + @param[out] Out Pointer to buffer to receive hkdf value. + @param[in] OutSize Size of hkdf bytes to generate. + + @retval TRUE Hkdf generated successfully. + @retval FALSE Hkdf generation failed. + +**/ +BOOLEAN +EFIAPI +HkdfSha384Expand ( + IN CONST UINT8 *Prk, + IN UINTN PrkSize, + IN CONST UINT8 *Info, + IN UINTN InfoSize, + OUT UINT8 *Out, + IN UINTN OutSize + ) +{ + ASSERT (FALSE); + return FALSE; +} --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92845): https://edk2.groups.io/g/devel/message/92845 Mute This Topic: https://groups.io/mt/93265015/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-