summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
diff options
context:
space:
mode:
Diffstat (limited to 'CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
index 19e9fbeae6..7d49dc2698 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
@@ -78,22 +78,22 @@ HmacMd5Free (
}
/**
- Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for
- subsequent use.
+ Set user-supplied key for subsequent use. It must be done before any
+ calling to HmacMd5Update().
If HmacMd5Context is NULL, then return FALSE.
- @param[out] HmacMd5Context Pointer to HMAC-MD5 context being initialized.
+ @param[out] HmacMd5Context Pointer to HMAC-MD5 context.
@param[in] Key Pointer to the user-supplied key.
@param[in] KeySize Key size in bytes.
- @retval TRUE HMAC-MD5 context initialization succeeded.
- @retval FALSE HMAC-MD5 context initialization failed.
+ @retval TRUE Key is set successfully.
+ @retval FALSE Key is set unsuccessfully.
**/
BOOLEAN
EFIAPI
-HmacMd5Init (
+HmacMd5SetKey (
OUT VOID *HmacMd5Context,
IN CONST UINT8 *Key,
IN UINTN KeySize
@@ -106,13 +106,6 @@ HmacMd5Init (
return FALSE;
}
- //
- // OpenSSL HMAC-MD5 Context Initialization
- //
- memset(HmacMd5Context, 0, HMAC_MD5_CTX_SIZE);
- if (HMAC_CTX_reset ((HMAC_CTX *)HmacMd5Context) != 1) {
- return FALSE;
- }
if (HMAC_Init_ex ((HMAC_CTX *)HmacMd5Context, Key, (UINT32) KeySize, EVP_md5(), NULL) != 1) {
return FALSE;
}
@@ -159,8 +152,8 @@ HmacMd5Duplicate (
This function performs HMAC-MD5 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.
- HMAC-MD5 context should be already correctly initialized by HmacMd5Init(), and should not be
- finalized by HmacMd5Final(). Behavior with invalid context is undefined.
+ HMAC-MD5 context should be initialized by HmacMd5New(), and should not be finalized by
+ HmacMd5Final(). Behavior with invalid context is undefined.
If HmacMd5Context is NULL, then return FALSE.
@@ -210,8 +203,8 @@ HmacMd5Update (
This function completes HMAC-MD5 digest computation and retrieves the digest value into
the specified memory. After this function has been called, the HMAC-MD5 context cannot
be used again.
- HMAC-MD5 context should be already correctly initialized by HmacMd5Init(), and should not be
- finalized by HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined.
+ HMAC-MD5 context should be initialized by HmacMd5New(), and should not be finalized by
+ HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined.
If HmacMd5Context is NULL, then return FALSE.
If HmacValue is NULL, then return FALSE.