From f4173af1ad45a270a5d8b2283f8018582484a553 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Mon, 7 Aug 2017 17:34:45 -0400 Subject: New upstream version 12+1501864225.b586175 --- Cryptlib/Hash/CryptSha1.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'Cryptlib/Hash/CryptSha1.c') diff --git a/Cryptlib/Hash/CryptSha1.c b/Cryptlib/Hash/CryptSha1.c index 78c29c1b..42cfd08a 100644 --- a/Cryptlib/Hash/CryptSha1.c +++ b/Cryptlib/Hash/CryptSha1.c @@ -1,7 +1,7 @@ /** @file SHA-1 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 @@ -102,7 +102,7 @@ Sha1Duplicate ( This function performs SHA-1 digest on a data buffer of the specified size. It can be called multiple times to compute the digest of long or discontinuous data streams. - SHA-1 context should be already correctly intialized by Sha1Init(), and should not be finalized + SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized by Sha1Final(). Behavior with invalid context is undefined. If Sha1Context is NULL, then return FALSE. @@ -149,7 +149,7 @@ Sha1Update ( This function completes SHA-1 hash computation and retrieves the digest value into the specified memory. After this function has been called, the SHA-1 context cannot be used again. - SHA-1 context should be already correctly intialized by Sha1Init(), and should not be + SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined. If Sha1Context is NULL, then return FALSE. @@ -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 == NULL) { + return FALSE; + } + if (Data == NULL && DataSize != 0) { + return FALSE; + } + + // + // OpenSSL SHA-1 Hash Computation. + // + if (SHA1 (Data, DataSize, HashValue) == NULL) { + return FALSE; + } else { + return TRUE; + } +} -- cgit v1.2.3