summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/hmac.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2020-03-07 17:44:38 +0300
committerdartraiden <wowemuh@gmail.com>2020-03-07 17:48:48 +0300
commit36bce64b00dcad9f6bffd1d64f946afa1c94d851 (patch)
treeeb3051233516d665f1ae035c8b52ef08a4fe9b40 /libs/libcurl/src/hmac.c
parentfdaf961eebb4e6f03133b3d7e0a3b963a88e59a9 (diff)
libcurl: update to 7.69
Diffstat (limited to 'libs/libcurl/src/hmac.c')
-rw-r--r--libs/libcurl/src/hmac.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/libs/libcurl/src/hmac.c b/libs/libcurl/src/hmac.c
index bf49ebec54..ae68827bea 100644
--- a/libs/libcurl/src/hmac.c
+++ b/libs/libcurl/src/hmac.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -30,6 +30,7 @@
#include "curl_hmac.h"
#include "curl_memory.h"
+#include "warnless.h"
/* The last #include file should be: */
#include "memdebug.h"
@@ -129,4 +130,40 @@ int Curl_HMAC_final(HMAC_context *ctxt, unsigned char *result)
return 0;
}
+/*
+ * Curl_hmacit()
+ *
+ * This is used to generate a HMAC hash, for the specified input data, given
+ * the specified hash function and key.
+ *
+ * Parameters:
+ *
+ * hashparams [in] - The hash function (Curl_HMAC_MD5).
+ * key [in] - The key to use.
+ * keylen [in] - The length of the key.
+ * data [in] - The data to encrypt.
+ * datalen [in] - The length of the data.
+ * output [in/out] - The output buffer.
+ *
+ * Returns CURLE_OK on success.
+ */
+CURLcode Curl_hmacit(const HMAC_params *hashparams,
+ const unsigned char *key, const size_t keylen,
+ const unsigned char *data, const size_t datalen,
+ unsigned char *output)
+{
+ HMAC_context *ctxt = Curl_HMAC_init(hashparams, key, curlx_uztoui(keylen));
+
+ if(!ctxt)
+ return CURLE_OUT_OF_MEMORY;
+
+ /* Update the digest with the given challenge */
+ Curl_HMAC_update(ctxt, data, curlx_uztoui(datalen));
+
+ /* Finalise the digest */
+ Curl_HMAC_final(ctxt, output);
+
+ return CURLE_OK;
+}
+
#endif /* CURL_DISABLE_CRYPTO_AUTH */