]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c
CryptoPkg/BaseCryptLib: replace HmacXxxInit API with HmacXxxSetKey
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Hmac / CryptHmacSha1.c
index 7d7df9640e7f6ad7a57b17b2deeb019bfe32aed9..8126fb525f3586f911f8812ff95d09891313a72f 100644 (file)
@@ -79,22 +79,22 @@ HmacSha1Free (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for\r
-  subsequent use.\r
+  Set user-supplied key for subsequent use. It must be done before any\r
+  calling to HmacSha1Update().\r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
 \r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
 \r
-  @param[out]  HmacSha1Context  Pointer to HMAC-SHA1 context being initialized.\r
+  @param[out]  HmacSha1Context  Pointer to HMAC-SHA1 context.\r
   @param[in]   Key              Pointer to the user-supplied key.\r
   @param[in]   KeySize          Key size in bytes.\r
 \r
   @param[in]   Key              Pointer to the user-supplied key.\r
   @param[in]   KeySize          Key size in bytes.\r
 \r
-  @retval TRUE   HMAC-SHA1 context initialization succeeded.\r
-  @retval FALSE  HMAC-SHA1 context initialization failed.\r
+  @retval TRUE   The Key is set successfully.\r
+  @retval FALSE  The Key is set unsuccessfully.\r
 \r
 **/\r
 BOOLEAN\r
 EFIAPI\r
 \r
 **/\r
 BOOLEAN\r
 EFIAPI\r
-HmacSha1Init (\r
+HmacSha1SetKey (\r
   OUT  VOID         *HmacSha1Context,\r
   IN   CONST UINT8  *Key,\r
   IN   UINTN        KeySize\r
   OUT  VOID         *HmacSha1Context,\r
   IN   CONST UINT8  *Key,\r
   IN   UINTN        KeySize\r
@@ -107,13 +107,6 @@ HmacSha1Init (
     return FALSE;\r
   }\r
 \r
     return FALSE;\r
   }\r
 \r
-  //\r
-  // OpenSSL HMAC-SHA1 Context Initialization\r
-  //\r
-  memset(HmacSha1Context, 0, HMAC_SHA1_CTX_SIZE);\r
-  if (HMAC_CTX_reset ((HMAC_CTX *)HmacSha1Context) != 1) {\r
-    return FALSE;\r
-  }\r
   if (HMAC_Init_ex ((HMAC_CTX *)HmacSha1Context, Key, (UINT32) KeySize, EVP_sha1(), NULL) != 1) {\r
     return FALSE;\r
   }\r
   if (HMAC_Init_ex ((HMAC_CTX *)HmacSha1Context, Key, (UINT32) KeySize, EVP_sha1(), NULL) != 1) {\r
     return FALSE;\r
   }\r
@@ -160,8 +153,8 @@ HmacSha1Duplicate (
 \r
   This function performs HMAC-SHA1 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
 \r
   This function performs HMAC-SHA1 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-SHA1 context should be already correctly initialized by HmacSha1Init(), and should not\r
-  be finalized by HmacSha1Final(). Behavior with invalid context is undefined.\r
+  HMAC-SHA1 context should be initialized by HmacSha1New(), and should not be finalized by\r
+  HmacSha1Final(). Behavior with invalid context is undefined.\r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
 \r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
 \r
@@ -211,8 +204,8 @@ HmacSha1Update (
   This function completes HMAC-SHA1 digest computation and retrieves the digest value into\r
   the specified memory. After this function has been called, the HMAC-SHA1 context cannot\r
   be used again.\r
   This function completes HMAC-SHA1 digest computation and retrieves the digest value into\r
   the specified memory. After this function has been called, the HMAC-SHA1 context cannot\r
   be used again.\r
-  HMAC-SHA1 context should be already correctly initialized by HmacSha1Init(), and should\r
-  not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined.\r
+  HMAC-SHA1 context should be initialized by HmacSha1New(), and should not be finalized by\r
+  HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined.\r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
   If HmacValue is NULL, then return FALSE.\r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
   If HmacValue is NULL, then return FALSE.\r