From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7D89481CEB for ; Mon, 31 Oct 2016 19:23:33 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 31 Oct 2016 19:23:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,577,1473145200"; d="scan'208";a="25925164" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 31 Oct 2016 19:23:34 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 31 Oct 2016 19:23:34 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 31 Oct 2016 19:23:33 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.139]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Tue, 1 Nov 2016 10:23:30 +0800 From: "Long, Qin" To: "Ye, Ting" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] CryptoPkg: Add xxxxHashAll APIs to facilitate the digest computation Thread-Index: AQHSM9+lngV60rtRTUOEk8oML0Ldo6DDZPbw Date: Tue, 1 Nov 2016 02:23:29 +0000 Message-ID: References: <20161031082845.9180-1-qin.long@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] CryptoPkg: Add xxxxHashAll APIs to facilitate the digest computation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 02:23:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes, it's better to update to use MD4_DIGEST_SIZE, instead of MD5_DIGEST_SI= ZE there. For #2, it was specifically designed for IPF platform before, I may clean-u= p them in future. So will just keep as-is now. Will send the V2 for updates.=20 Best Regards & Thanks, LONG, Qin > -----Original Message----- > From: Ye, Ting > Sent: Tuesday, November 1, 2016 9:31 AM > To: Long, Qin ; edk2-devel@lists.01.org > Subject: RE: [Patch] CryptoPkg: Add xxxxHashAll APIs to facilitate the di= gest > computation >=20 > Hi Qin, >=20 > I have two questions for this patch: > 1) Both MD5_DIGEST_SIZE and MD4_DIGEST_SIZE are defined in > BaseCryptLib.h, with same value 16 bytes. However, in HashVerify.c, we us= e > MD5_DIGEST_SIZE directly for validating MD4 digest. > Do you think it might be better for code readability to use > MD4_DIGEST_SIZE for MD4 digest? > 2) BaseCryptLibRuntimeCryptProtocol in CryptoPkg/Library also includes > **Null.c for unsupported HASH interfaces. Do you think we need add > xxxxHashAll APIs there? >=20 > Others are good to me. > Reviewed-by: Ye Ting >=20 > Best Regards, > Ye Ting >=20 >=20 > -----Original Message----- > From: Long, Qin > Sent: Monday, October 31, 2016 4:29 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting > Subject: [Patch] CryptoPkg: Add xxxxHashAll APIs to facilitate the digest > computation >=20 > Add new xxxxHashAll APIs to facilitate the digest computation of blob dat= a. > New APIs include: Md4HashAll(), Md5HashAll(), Sha1HashAll(), > Sha256HashAll(), Sha384HashAll(), and Sha512HashAll(). >=20 > The corresponding test cases were added in Cryptest utility. >=20 > Cc: Ting Ye > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qin Long > --- > CryptoPkg/Application/Cryptest/HashVerify.c | 74 +++++++++- > CryptoPkg/Include/Library/BaseCryptLib.h | 158 > ++++++++++++++++++++- > CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c | 48 ++++++- > CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c | 27 +++- > CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c | 48 ++++++- > CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c | 48 ++++++- > CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c | 48 ++++++- > CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c | 94 +++++++++++- > .../Library/BaseCryptLib/Hash/CryptSha512Null.c | 52 ++++++- > 9 files changed, 588 insertions(+), 9 deletions(-) >=20 > diff --git a/CryptoPkg/Application/Cryptest/HashVerify.c > b/CryptoPkg/Application/Cryptest/HashVerify.c > index ca64361..345664b 100644 > --- a/CryptoPkg/Application/Cryptest/HashVerify.c > +++ b/CryptoPkg/Application/Cryptest/HashVerify.c > @@ -1,7 +1,7 @@ > /** @file > Application for Hash Primitives Validation. >=20 > -Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
> +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -132,6 +132,18 @@ ValidateCryptDigest ( > return EFI_ABORTED; > } >=20 > + Print (L"HashAll... "); > + ZeroMem (Digest, MD5_DIGEST_SIZE); > + Status =3D Md4HashAll (HashData, DataSize, Digest); if (!Status) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + if (CompareMem (Digest, Md4Digest, MD5_DIGEST_SIZE) !=3D 0) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + > Print (L"[Pass]\n"); >=20 > Print (L"- MD5: "); > @@ -172,6 +184,18 @@ ValidateCryptDigest ( > return EFI_ABORTED; > } >=20 > + Print (L"HashAll... "); > + ZeroMem (Digest, MD5_DIGEST_SIZE); > + Status =3D Md5HashAll (HashData, DataSize, Digest); if (!Status) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + if (CompareMem (Digest, Md5Digest, MD5_DIGEST_SIZE) !=3D 0) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + > Print (L"[Pass]\n"); >=20 > Print (L"- SHA1: "); > @@ -212,6 +236,18 @@ ValidateCryptDigest ( > return EFI_ABORTED; > } >=20 > + Print (L"HashAll... "); > + ZeroMem (Digest, SHA1_DIGEST_SIZE); > + Status =3D Sha1HashAll (HashData, DataSize, Digest); if (!Status) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + if (CompareMem (Digest, Sha1Digest, SHA1_DIGEST_SIZE) !=3D 0) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + > Print (L"[Pass]\n"); >=20 > Print (L"- SHA256: "); > @@ -252,6 +288,18 @@ ValidateCryptDigest ( > return EFI_ABORTED; > } >=20 > + Print (L"HashAll... "); > + ZeroMem (Digest, SHA256_DIGEST_SIZE); Status =3D Sha256HashAll > + (HashData, DataSize, Digest); if (!Status) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + if (CompareMem (Digest, Sha256Digest, SHA256_DIGEST_SIZE) !=3D 0) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + > Print (L"[Pass]\n"); >=20 > Print (L"- SHA384: "); > @@ -292,6 +340,18 @@ ValidateCryptDigest ( > return EFI_ABORTED; > } >=20 > + Print (L"HashAll... "); > + ZeroMem (Digest, SHA384_DIGEST_SIZE); Status =3D Sha384HashAll > + (HashData, DataSize, Digest); if (!Status) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + if (CompareMem (Digest, Sha384Digest, SHA384_DIGEST_SIZE) !=3D 0) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + > Print (L"[Pass]\n"); >=20 > Print (L"- SHA512: "); > @@ -332,6 +392,18 @@ ValidateCryptDigest ( > return EFI_ABORTED; > } >=20 > + Print (L"HashAll... "); > + ZeroMem (Digest, SHA512_DIGEST_SIZE); Status =3D Sha512HashAll > + (HashData, DataSize, Digest); if (!Status) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + if (CompareMem (Digest, Sha512Digest, SHA512_DIGEST_SIZE) !=3D 0) { > + Print (L"[Fail]"); > + return EFI_ABORTED; > + } > + > Print (L"[Pass]\n"); >=20 > return EFI_SUCCESS; > diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h > b/CryptoPkg/Include/Library/BaseCryptLib.h > index 0371d73..3463626 100644 > --- a/CryptoPkg/Include/Library/BaseCryptLib.h > +++ b/CryptoPkg/Include/Library/BaseCryptLib.h > @@ -4,7 +4,7 @@ > primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI sec= urity > functionality enabling. >=20 > -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -193,6 +193,32 @@ Md4Final ( > ); >=20 > /** > + Computes the MD4 message digest of a input data buffer. > + > + This function performs the MD4 message digest of a given data buffer, > + and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the MD4 dig= est > + value (16 bytes). > + > + @retval TRUE MD4 digest computation succeeded. > + @retval FALSE MD4 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Md4HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ); > + > +/** > Retrieves the size, in bytes, of the context buffer required for MD5 h= ash > operations. >=20 > If this interface is not supported, then return zero. > @@ -307,6 +333,32 @@ Md5Final ( > ); >=20 > /** > + Computes the MD5 message digest of a input data buffer. > + > + This function performs the MD5 message digest of a given data buffer, > + and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the MD5 dig= est > + value (16 bytes). > + > + @retval TRUE MD5 digest computation succeeded. > + @retval FALSE MD5 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Md5HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ); > + > +/** > Retrieves the size, in bytes, of the context buffer required for SHA-1= hash > operations. >=20 > If this interface is not supported, then return zero. > @@ -421,6 +473,32 @@ Sha1Final ( > ); >=20 > /** > + Computes the SHA-1 message digest of a input data buffer. > + > + This function performs the SHA-1 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-1 > digest > + value (20 bytes). > + > + @retval TRUE SHA-1 digest computation succeeded. > + @retval FALSE SHA-1 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha1HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ); > + > +/** > Retrieves the size, in bytes, of the context buffer required for SHA-2= 56 > hash operations. >=20 > @return The size, in bytes, of the context buffer required for SHA-25= 6 hash > operations. > @@ -526,6 +604,32 @@ Sha256Final ( > ); >=20 > /** > + Computes the SHA-256 message digest of a input data buffer. > + > + This function performs the SHA-256 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-256 > digest > + value (32 bytes). > + > + @retval TRUE SHA-256 digest computation succeeded. > + @retval FALSE SHA-256 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha256HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ); > + > +/** > Retrieves the size, in bytes, of the context buffer required for SHA-3= 84 > hash operations. >=20 > @return The size, in bytes, of the context buffer required for SHA-38= 4 hash > operations. > @@ -631,6 +735,32 @@ Sha384Final ( > ); >=20 > /** > + Computes the SHA-384 message digest of a input data buffer. > + > + This function performs the SHA-384 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-384 > digest > + value (48 bytes). > + > + @retval TRUE SHA-384 digest computation succeeded. > + @retval FALSE SHA-384 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha384HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ); > + > +/** > Retrieves the size, in bytes, of the context buffer required for SHA-5= 12 > hash operations. >=20 > @return The size, in bytes, of the context buffer required for SHA-51= 2 hash > operations. > @@ -735,6 +865,32 @@ Sha512Final ( > OUT UINT8 *HashValue > ); >=20 > +/** > + Computes the SHA-512 message digest of a input data buffer. > + > + This function performs the SHA-512 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-512 > digest > + value (64 bytes). > + > + @retval TRUE SHA-512 digest computation succeeded. > + @retval FALSE SHA-512 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha512HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ); > + >=20 > //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > // MAC (Message Authentication Code) Primitive >=20 > //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c > index 633d343..d9cc445 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c > @@ -1,7 +1,7 @@ > /** @file > MD4 Digest Wrapper Implementation over OpenSSL. >=20 > -Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -181,3 +181,49 @@ Md4Final ( > // > return (BOOLEAN) (MD4_Final (HashValue, (MD4_CTX *) Md4Context)); } > + > +/** > + Computes the MD4 message digest of a input data buffer. > + > + This function performs the MD4 message digest of a given data buffer, > + and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the MD4 dig= est > + value (16 bytes). > + > + @retval TRUE MD4 digest computation succeeded. > + @retval FALSE MD4 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Md4HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + // > + // Check input parameters. > + // > + if (HashValue =3D=3D NULL) { > + return FALSE; > + } > + if (Data =3D=3D NULL && DataSize !=3D 0) { > + return FALSE; > + } > + > + // > + // OpenSSL MD4 Hash Computation. > + // > + if (MD4 (Data, DataSize, HashValue) =3D=3D NULL) { > + return FALSE; > + } else { > + return TRUE; > + } > +} > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c > index fc634fd..01b3f23 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c > @@ -1,7 +1,7 @@ > /** @file > MD4 Digest Wrapper Implementation which does not provide real > capabilities. >=20 > -Copyright (c) 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -122,3 +122,28 @@ Md4Final ( > ASSERT (FALSE); > return FALSE; > } > + > +/** > + Computes the MD4 message digest of a input data buffer. > + > + Return FALSE to indicate this interface is not supported. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the MD4 dig= est > + value (16 bytes). > + > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Md4HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c > index e1c10e3..34eabe9 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c > @@ -1,7 +1,7 @@ > /** @file > MD5 Digest Wrapper Implementation over OpenSSL. >=20 > -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -183,3 +183,49 @@ Md5Final ( > // > return (BOOLEAN) (MD5_Final (HashValue, (MD5_CTX *) Md5Context)); } > + > +/** > + Computes the MD5 message digest of a input data buffer. > + > + This function performs the MD5 message digest of a given data buffer, > + and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the MD5 dig= est > + value (16 bytes). > + > + @retval TRUE MD5 digest computation succeeded. > + @retval FALSE MD5 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Md5HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + // > + // Check input parameters. > + // > + if (HashValue =3D=3D NULL) { > + return FALSE; > + } > + if (Data =3D=3D NULL && (DataSize !=3D 0)) { > + return FALSE; > + } > + > + // > + // OpenSSL MD5 Hash Computation. > + // > + if (MD5 (Data, DataSize, HashValue) =3D=3D NULL) { > + return FALSE; > + } else { > + return TRUE; > + } > +} > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c > index 78c29c1..b8a6d0c 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c > @@ -1,7 +1,7 @@ > /** @file > SHA-1 Digest Wrapper Implementation over OpenSSL. >=20 > -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -182,3 +182,49 @@ Sha1Final ( > // > return (BOOLEAN) (SHA1_Final (HashValue, (SHA_CTX *) Sha1Context)); } > + > +/** > + Computes the SHA-1 message digest of a input data buffer. > + > + This function performs the SHA-1 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-1 > digest > + value (20 bytes). > + > + @retval TRUE SHA-1 digest computation succeeded. > + @retval FALSE SHA-1 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha1HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + // > + // Check input parameters. > + // > + if (HashValue =3D=3D NULL) { > + return FALSE; > + } > + if (Data =3D=3D NULL && DataSize !=3D 0) { > + return FALSE; > + } > + > + // > + // OpenSSL SHA-1 Hash Computation. > + // > + if (SHA1 (Data, DataSize, HashValue) =3D=3D NULL) { > + return FALSE; > + } else { > + return TRUE; > + } > +} > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c > index 56894ac..aaf689b 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c > @@ -1,7 +1,7 @@ > /** @file > SHA-256 Digest Wrapper Implementation over OpenSSL. >=20 > -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -181,3 +181,49 @@ Sha256Final ( > // > return (BOOLEAN) (SHA256_Final (HashValue, (SHA256_CTX *) > Sha256Context)); } > + > +/** > + Computes the SHA-256 message digest of a input data buffer. > + > + This function performs the SHA-256 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-256 > digest > + value (32 bytes). > + > + @retval TRUE SHA-256 digest computation succeeded. > + @retval FALSE SHA-256 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha256HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + // > + // Check input parameters. > + // > + if (HashValue =3D=3D NULL) { > + return FALSE; > + } > + if (Data =3D=3D NULL && DataSize !=3D 0) { > + return FALSE; > + } > + > + // > + // OpenSSL SHA-256 Hash Computation. > + // > + if (SHA256 (Data, DataSize, HashValue) =3D=3D NULL) { > + return FALSE; > + } else { > + return TRUE; > + } > +} > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c > index 491f45d..457151e 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512.c > @@ -1,7 +1,7 @@ > /** @file > SHA-384 and SHA-512 Digest Wrapper Implementations over OpenSSL. >=20 > -Copyright (c) 2014, Intel Corporation. All rights reserved.
> +Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -185,6 +185,52 @@ Sha384Final ( } >=20 > /** > + Computes the SHA-384 message digest of a input data buffer. > + > + This function performs the SHA-384 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-384 > digest > + value (48 bytes). > + > + @retval TRUE SHA-384 digest computation succeeded. > + @retval FALSE SHA-384 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha384HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + // > + // Check input parameters. > + // > + if (HashValue =3D=3D NULL) { > + return FALSE; > + } > + if (Data =3D=3D NULL && DataSize !=3D 0) { > + return FALSE; > + } > + > + // > + // OpenSSL SHA-384 Hash Computation. > + // > + if (SHA384 (Data, DataSize, HashValue) =3D=3D NULL) { > + return FALSE; > + } else { > + return TRUE; > + } > +} > + > +/** > Retrieves the size, in bytes, of the context buffer required for SHA-5= 12 > hash operations. >=20 > @return The size, in bytes, of the context buffer required for SHA-51= 2 hash > operations. > @@ -352,3 +398,49 @@ Sha512Final ( > // > return (BOOLEAN) (SHA384_Final (HashValue, (SHA512_CTX *) > Sha512Context)); } > + > +/** > + Computes the SHA-512 message digest of a input data buffer. > + > + This function performs the SHA-512 message digest of a given data > + buffer, and places the digest value into the specified memory. > + > + If this interface is not supported, then return FALSE. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-512 > digest > + value (64 bytes). > + > + @retval TRUE SHA-512 digest computation succeeded. > + @retval FALSE SHA-512 digest computation failed. > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha512HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + // > + // Check input parameters. > + // > + if (HashValue =3D=3D NULL) { > + return FALSE; > + } > + if (Data =3D=3D NULL && DataSize !=3D 0) { > + return FALSE; > + } > + > + // > + // OpenSSL SHA-512 Hash Computation. > + // > + if (SHA512 (Data, DataSize, HashValue) =3D=3D NULL) { > + return FALSE; > + } else { > + return TRUE; > + } > +} > diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512Null.c > b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512Null.c > index 89aeacc..8cd754f 100644 > --- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512Null.c > +++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha512Null.c > @@ -1,7 +1,7 @@ > /** @file > SHA-384 and SHA-512 Digest Wrapper Implementations which does not > provide real capabilities. >=20 > -Copyright (c) 2014, Intel Corporation. All rights reserved.
> +Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -123,6 +123,31 @@ Sha384Final ( } >=20 > /** > + Computes the SHA-384 message digest of a input data buffer. > + > + Return FALSE to indicate this interface is not supported. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-384 > digest > + value (48 bytes). > + > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha384HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > + > +/** > Retrieves the size, in bytes, of the context buffer required for SHA-5= 12 > hash operations. >=20 > Return zero to indicate this interface is not supported. > @@ -229,3 +254,28 @@ Sha512Final ( > ASSERT (FALSE); > return FALSE; > } > + > +/** > + Computes the SHA-512 message digest of a input data buffer. > + > + Return FALSE to indicate this interface is not supported. > + > + @param[in] Data Pointer to the buffer containing the data to = be > hashed. > + @param[in] DataSize Size of Data buffer in bytes. > + @param[out] HashValue Pointer to a buffer that receives the SHA-512 > digest > + value (64 bytes). > + > + @retval FALSE This interface is not supported. > + > +**/ > +BOOLEAN > +EFIAPI > +Sha512HashAll ( > + IN CONST VOID *Data, > + IN UINTN DataSize, > + OUT UINT8 *HashValue > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > -- > 2.10.1.windows.1