]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: add hmac support for sha256
authorMatthias Gatto <matthias.gatto@outscale.com>
Fri, 3 Jul 2020 13:12:57 +0000 (15:12 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 21 Dec 2020 14:26:41 +0000 (15:26 +0100)
It seems current hmac implementation use md5 for the hash,
V4 signature require sha256, so I've added the needed struct in
this commit.

I've added the functions that do the hmac in v4 signature file
as a static function ,in the next patch of the serie,
because it's used only by this file.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
lib/curl_sha256.h
lib/sha256.c

index 0fceb6329aab5548361ffcf1d2a4ff400aa075c6..b4579d7692ea181925da1bcbe6518672b28190d4 100644 (file)
@@ -24,6 +24,9 @@
  ***************************************************************************/
 
 #ifndef CURL_DISABLE_CRYPTO_AUTH
+#include "curl_hmac.h"
+
+extern const struct HMAC_params Curl_HMAC_SHA256[1];
 
 #define SHA256_DIGEST_LENGTH 32
 
index 910d7ae1e8710a7c794ea4f7af057b1b11a2077b..c64ee093689fa0783012dc2365f0979d04043a8c 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "warnless.h"
 #include "curl_sha256.h"
+#include "curl_hmac.h"
 
 #if defined(USE_OPENSSL)
 
@@ -491,4 +492,23 @@ void Curl_sha256it(unsigned char *output, const unsigned char *input,
   SHA256_Final(output, &ctx);
 }
 
+
+const struct HMAC_params Curl_HMAC_SHA256[] = {
+  {
+    /* Hash initialization function. */
+    CURLX_FUNCTION_CAST(HMAC_hinit_func, SHA256_Init),
+    /* Hash update function. */
+    CURLX_FUNCTION_CAST(HMAC_hupdate_func, SHA256_Update),
+    /* Hash computation end function. */
+    CURLX_FUNCTION_CAST(HMAC_hfinal_func, SHA256_Final),
+    /* Size of hash context structure. */
+    sizeof(SHA256_CTX),
+    /* Maximum key length. */
+    64,
+    /* Result size. */
+    32
+  }
+};
+
+
 #endif /* CURL_DISABLE_CRYPTO_AUTH */