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