diff options
Diffstat (limited to 'Utilities/cmcurl/lib/sha256.c')
-rw-r--r-- | Utilities/cmcurl/lib/sha256.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/Utilities/cmcurl/lib/sha256.c b/Utilities/cmcurl/lib/sha256.c index 910d7ae1e8..d915117917 100644 --- a/Utilities/cmcurl/lib/sha256.c +++ b/Utilities/cmcurl/lib/sha256.c @@ -27,6 +27,7 @@ #include "warnless.h" #include "curl_sha256.h" +#include "curl_hmac.h" #if defined(USE_OPENSSL) @@ -343,11 +344,14 @@ static int sha256_compress(struct sha256_state *md, } /* Compress */ -#define RND(a,b,c,d,e,f,g,h,i) \ - unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ - unsigned long t1 = Sigma0(a) + Maj(a, b, c); \ - d += t0; \ - h = t0 + t1; +#define RND(a,b,c,d,e,f,g,h,i) \ + do { \ + unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ + unsigned long t1 = Sigma0(a) + Maj(a, b, c); \ + d += t0; \ + h = t0 + t1; \ + } while(0) + for(i = 0; i < 64; ++i) { unsigned long t; RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i); @@ -491,4 +495,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 */ |