diff options
author | dartraiden <wowemuh@gmail.com> | 2024-11-06 20:55:13 +0300 |
---|---|---|
committer | dartraiden <wowemuh@gmail.com> | 2024-11-06 21:41:16 +0300 |
commit | 5d2ecfef56e49a8e4bfad25a582ff1597987f717 (patch) | |
tree | cdb31e45b051830ecf50c74a84b8d2ac5aa6cfd9 /libs/libcurl/src/md5.c | |
parent | 995e85e9e63553576fc285d937d4abbad369e7e4 (diff) |
libcurl: update to 8.11.0
Diffstat (limited to 'libs/libcurl/src/md5.c')
-rw-r--r-- | libs/libcurl/src/md5.c | 99 |
1 files changed, 45 insertions, 54 deletions
diff --git a/libs/libcurl/src/md5.c b/libs/libcurl/src/md5.c index 6083db9e69..2f7f913ad6 100644 --- a/libs/libcurl/src/md5.c +++ b/libs/libcurl/src/md5.c @@ -88,20 +88,20 @@ typedef struct md5_ctx my_md5_ctx;
-static CURLcode my_md5_init(my_md5_ctx *ctx)
+static CURLcode my_md5_init(void *ctx)
{
md5_init(ctx);
return CURLE_OK;
}
-static void my_md5_update(my_md5_ctx *ctx,
+static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int inputLen)
{
md5_update(ctx, inputLen, input);
}
-static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx)
+static void my_md5_final(unsigned char *digest, void *ctx)
{
md5_digest(ctx, 16, digest);
}
@@ -110,7 +110,7 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) typedef MD5_CTX my_md5_ctx;
-static CURLcode my_md5_init(my_md5_ctx *ctx)
+static CURLcode my_md5_init(void *ctx)
{
if(!MD5_Init(ctx))
return CURLE_OUT_OF_MEMORY;
@@ -118,14 +118,14 @@ static CURLcode my_md5_init(my_md5_ctx *ctx) return CURLE_OK;
}
-static void my_md5_update(my_md5_ctx *ctx,
+static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int len)
{
(void)MD5_Update(ctx, input, len);
}
-static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx)
+static void my_md5_final(unsigned char *digest, void *ctx)
{
(void)MD5_Final(digest, ctx);
}
@@ -134,7 +134,7 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) typedef mbedtls_md5_context my_md5_ctx;
-static CURLcode my_md5_init(my_md5_ctx *ctx)
+static CURLcode my_md5_init(void *ctx)
{
#if (MBEDTLS_VERSION_NUMBER >= 0x03000000)
if(mbedtls_md5_starts(ctx))
@@ -148,7 +148,7 @@ static CURLcode my_md5_init(my_md5_ctx *ctx) return CURLE_OK;
}
-static void my_md5_update(my_md5_ctx *ctx,
+static void my_md5_update(void *ctx,
const unsigned char *data,
unsigned int length)
{
@@ -159,7 +159,7 @@ static void my_md5_update(my_md5_ctx *ctx, #endif
}
-static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx)
+static void my_md5_final(unsigned char *digest, void *ctx)
{
#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
(void) mbedtls_md5_finish(ctx, digest);
@@ -178,7 +178,7 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) reliable than defining COMMON_DIGEST_FOR_OPENSSL on older cats. */
# define my_md5_ctx CC_MD5_CTX
-static CURLcode my_md5_init(my_md5_ctx *ctx)
+static CURLcode my_md5_init(void *ctx)
{
if(!CC_MD5_Init(ctx))
return CURLE_OUT_OF_MEMORY;
@@ -186,14 +186,14 @@ static CURLcode my_md5_init(my_md5_ctx *ctx) return CURLE_OK;
}
-static void my_md5_update(my_md5_ctx *ctx,
+static void my_md5_update(void *ctx,
const unsigned char *input,
unsigned int inputLen)
{
CC_MD5_Update(ctx, input, inputLen);
}
-static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx)
+static void my_md5_final(unsigned char *digest, void *ctx)
{
CC_MD5_Final(digest, ctx);
}
@@ -206,8 +206,9 @@ struct md5_ctx { };
typedef struct md5_ctx my_md5_ctx;
-static CURLcode my_md5_init(my_md5_ctx *ctx)
+static CURLcode my_md5_init(void *in)
{
+ my_md5_ctx *ctx = (my_md5_ctx *)in;
if(!CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
return CURLE_OUT_OF_MEMORY;
@@ -221,15 +222,17 @@ static CURLcode my_md5_init(my_md5_ctx *ctx) return CURLE_OK;
}
-static void my_md5_update(my_md5_ctx *ctx,
+static void my_md5_update(void *in,
const unsigned char *input,
unsigned int inputLen)
{
+ my_md5_ctx *ctx = in;
CryptHashData(ctx->hHash, (unsigned char *)input, inputLen, 0);
}
-static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx)
+static void my_md5_final(unsigned char *digest, void *in)
{
+ my_md5_ctx *ctx = (my_md5_ctx *)in;
unsigned long length = 0;
CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
if(length == 16)
@@ -292,10 +295,10 @@ struct md5_ctx { };
typedef struct md5_ctx my_md5_ctx;
-static CURLcode my_md5_init(my_md5_ctx *ctx);
-static void my_md5_update(my_md5_ctx *ctx, const void *data,
- unsigned long size);
-static void my_md5_final(unsigned char *result, my_md5_ctx *ctx);
+static CURLcode my_md5_init(void *ctx);
+static void my_md5_update(void *ctx, const unsigned char *data,
+ unsigned int size);
+static void my_md5_final(unsigned char *result, void *ctx);
/*
* The basic MD5 functions.
@@ -455,8 +458,9 @@ static const void *my_md5_body(my_md5_ctx *ctx, return ptr;
}
-static CURLcode my_md5_init(my_md5_ctx *ctx)
+static CURLcode my_md5_init(void *in)
{
+ my_md5_ctx *ctx = (my_md5_ctx *)in;
ctx->a = 0x67452301;
ctx->b = 0xefcdab89;
ctx->c = 0x98badcfe;
@@ -468,11 +472,12 @@ static CURLcode my_md5_init(my_md5_ctx *ctx) return CURLE_OK;
}
-static void my_md5_update(my_md5_ctx *ctx, const void *data,
- unsigned long size)
+static void my_md5_update(void *in, const unsigned char *data,
+ unsigned int size)
{
MD5_u32plus saved_lo;
- unsigned long used;
+ unsigned int used;
+ my_md5_ctx *ctx = (my_md5_ctx *)in;
saved_lo = ctx->lo;
ctx->lo = (saved_lo + size) & 0x1fffffff;
@@ -483,7 +488,7 @@ static void my_md5_update(my_md5_ctx *ctx, const void *data, used = saved_lo & 0x3f;
if(used) {
- unsigned long available = 64 - used;
+ unsigned int available = 64 - used;
if(size < available) {
memcpy(&ctx->buffer[used], data, size);
@@ -504,9 +509,10 @@ static void my_md5_update(my_md5_ctx *ctx, const void *data, memcpy(ctx->buffer, data, size);
}
-static void my_md5_final(unsigned char *result, my_md5_ctx *ctx)
+static void my_md5_final(unsigned char *result, void *in)
{
- unsigned long used, available;
+ unsigned int used, available;
+ my_md5_ctx *ctx = (my_md5_ctx *)in;
used = ctx->lo & 0x3f;
@@ -557,36 +563,21 @@ static void my_md5_final(unsigned char *result, my_md5_ctx *ctx) #endif /* CRYPTO LIBS */
-const struct HMAC_params Curl_HMAC_MD5[] = {
- {
- /* Hash initialization function. */
- CURLX_FUNCTION_CAST(HMAC_hinit_func, my_md5_init),
- /* Hash update function. */
- CURLX_FUNCTION_CAST(HMAC_hupdate_func, my_md5_update),
- /* Hash computation end function. */
- CURLX_FUNCTION_CAST(HMAC_hfinal_func, my_md5_final),
- /* Size of hash context structure. */
- sizeof(my_md5_ctx),
- /* Maximum key length. */
- 64,
- /* Result size. */
- 16
- }
+const struct HMAC_params Curl_HMAC_MD5 = {
+ my_md5_init, /* Hash initialization function. */
+ my_md5_update, /* Hash update function. */
+ my_md5_final, /* Hash computation end function. */
+ sizeof(my_md5_ctx), /* Size of hash context structure. */
+ 64, /* Maximum key length. */
+ 16 /* Result size. */
};
-const struct MD5_params Curl_DIGEST_MD5[] = {
- {
- /* Digest initialization function */
- CURLX_FUNCTION_CAST(Curl_MD5_init_func, my_md5_init),
- /* Digest update function */
- CURLX_FUNCTION_CAST(Curl_MD5_update_func, my_md5_update),
- /* Digest computation end function */
- CURLX_FUNCTION_CAST(Curl_MD5_final_func, my_md5_final),
- /* Size of digest context struct */
- sizeof(my_md5_ctx),
- /* Result size */
- 16
- }
+const struct MD5_params Curl_DIGEST_MD5 = {
+ my_md5_init, /* Digest initialization function */
+ my_md5_update, /* Digest update function */
+ my_md5_final, /* Digest computation end function */
+ sizeof(my_md5_ctx), /* Size of digest context struct */
+ 16 /* Result size */
};
/*
|