\r
**/\r
\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-\r
-#include <Library/BaseCryptLib.h>\r
+#include "InternalCryptLib.h"\r
#include <openssl/sha.h>\r
\r
\r
return (UINTN)(sizeof (SHA_CTX));\r
}\r
\r
-\r
/**\r
- Initializes user-supplied memory pointed by Sha1Context as the SHA-1 hash context for\r
+ Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r
subsequent use.\r
\r
If Sha1Context is NULL, then ASSERT().\r
\r
- @param[in, out] Sha1Context Pointer to the SHA-1 Context being initialized.\r
+ @param[out] Sha1Context Pointer to SHA-1 context being initialized.\r
\r
- @retval TRUE SHA-1 initialization succeeded.\r
- @retval FALSE SHA-1 initialization failed.\r
+ @retval TRUE SHA-1 context initialization succeeded.\r
+ @retval FALSE SHA-1 context initialization failed.\r
\r
**/\r
BOOLEAN\r
EFIAPI\r
Sha1Init (\r
- IN OUT VOID *Sha1Context\r
+ OUT VOID *Sha1Context\r
)\r
{\r
//\r
return (BOOLEAN) (SHA1_Init ((SHA_CTX *)Sha1Context));\r
}\r
\r
+/**\r
+ Makes a copy of an existing SHA-1 context.\r
+\r
+ If Sha1Context is NULL, then ASSERT().\r
+ If NewSha1Context is NULL, then ASSERT().\r
+\r
+ @param[in] Sha1Context Pointer to SHA-1 context being copied.\r
+ @param[out] NewSha1Context Pointer to new SHA-1 context.\r
+\r
+ @retval TRUE SHA-1 context copy succeeded.\r
+ @retval FALSE SHA-1 context copy failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha1Duplicate (\r
+ IN CONST VOID *Sha1Context,\r
+ OUT VOID *NewSha1Context\r
+ )\r
+{\r
+ CopyMem (NewSha1Context, Sha1Context, sizeof (SHA_CTX));\r
+\r
+ return TRUE;\r
+}\r
\r
/**\r
- Performs SHA-1 digest on a data buffer of the specified length. This function can\r
- be called multiple times to compute the digest of long or discontinuous data streams.\r
+ Digests the input data and updates SHA-1 context.\r
+\r
+ This function performs SHA-1 digest on a data buffer of the specified size.\r
+ It can be called multiple times to compute the digest of long or discontinuous data streams.\r
+ SHA-1 context should be already correctly intialized by Sha1Init(), and should not be finalized\r
+ by Sha1Final(). Behavior with invalid context is undefined.\r
\r
If Sha1Context is NULL, then ASSERT().\r
\r
@param[in, out] Sha1Context Pointer to the SHA-1 context.\r
@param[in] Data Pointer to the buffer containing the data to be hashed.\r
- @param[in] DataLength Length of Data buffer in bytes.\r
+ @param[in] DataSize Size of Data buffer in bytes.\r
\r
@retval TRUE SHA-1 data digest succeeded.\r
- @retval FALSE Invalid SHA-1 context. After Sha1Final function has been called, the\r
- SHA-1 context cannot be reused.\r
+ @retval FALSE SHA-1 data digest failed.\r
\r
**/\r
BOOLEAN\r
Sha1Update (\r
IN OUT VOID *Sha1Context,\r
IN CONST VOID *Data,\r
- IN UINTN DataLength\r
+ IN UINTN DataSize\r
)\r
{\r
//\r
// ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
//\r
if (Data == NULL) {\r
- ASSERT (DataLength == 0);\r
+ ASSERT (DataSize == 0);\r
}\r
\r
//\r
// OpenSSL SHA-1 Hash Update\r
//\r
- return (BOOLEAN) (SHA1_Update ((SHA_CTX *)Sha1Context, Data, DataLength));\r
+ return (BOOLEAN) (SHA1_Update ((SHA_CTX *)Sha1Context, Data, DataSize));\r
}\r
\r
-\r
/**\r
- Completes SHA-1 hash computation and retrieves the digest value into the specified\r
- memory. After this function has been called, the SHA-1 context cannot be used again.\r
+ Completes computation of the SHA-1 digest value.\r
+\r
+ This function completes SHA-1 hash computation and retrieves the digest value into\r
+ the specified memory. After this function has been called, the SHA-1 context cannot\r
+ be used again.\r
+ SHA-1 context should be already correctly intialized by Sha1Init(), and should not be\r
+ finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r
\r
If Sha1Context is NULL, then ASSERT().\r
If HashValue is NULL, then ASSERT().\r
\r
- @param[in, out] Sha1Context Pointer to the SHA-1 context\r
+ @param[in, out] Sha1Context Pointer to the SHA-1 context.\r
@param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r
value (20 bytes).\r
\r