X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=CryptoPkg%2FLibrary%2FBaseCryptLib%2FHash%2FCryptSha256.c;fp=CryptoPkg%2FLibrary%2FBaseCryptLib%2FHash%2FCryptSha256.c;h=aaf689b361a52c3b57de2f220b49f13dfe9c985b;hp=56894aca30d678131290425640366a57ee539aa7;hb=b7d1ba0a8ae9719689ad9725e02e4cb5d469a3ae;hpb=90a40219673303f97890d5ea2e367ee2dc04a0b3 diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c index 56894aca30..aaf689b361 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. -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 == NULL) { + return FALSE; + } + if (Data == NULL && DataSize != 0) { + return FALSE; + } + + // + // OpenSSL SHA-256 Hash Computation. + // + if (SHA256 (Data, DataSize, HashValue) == NULL) { + return FALSE; + } else { + return TRUE; + } +}