From bb490ab247d03b72e5893bdb07808a78b1632c33 Mon Sep 17 00:00:00 2001 From: Edouard LEFIZELIER Date: Mon, 17 Apr 2023 11:51:47 +0200 Subject: [PATCH] modification of md5_ext_openssl.c .h --- src/microhttpd/md5_ext_openssl.c | 29 +++++++++-------- src/microhttpd/md5_ext_openssl.h | 54 +++++++++++++++++--------------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/microhttpd/md5_ext_openssl.c b/src/microhttpd/md5_ext_openssl.c index 53f68ccb..26962ca1 100644 --- a/src/microhttpd/md5_ext_openssl.c +++ b/src/microhttpd/md5_ext_openssl.c @@ -29,18 +29,21 @@ #include "mhd_assert.h" void -MHD_MD5 (struct Md5CtxExt_OpenSSL *c, - const unsigned char *d, - size_t n) +MHD_MD5_init (struct Md5CtxExt *ctx) { - unsigned char *md; - if (NULL == MD5 (d, n, md)) - { - c->ext_error = 1; - } - else - { - c->ext_error = 0; - memcpy (c->hash, md, sizeof(ctx->H)); - } + MD5_init (*ctx); +} + + +void +MHD_MD5_update (struct Md5CtxExt *ctx, const void *buf, int len) +{ + MD5_update (*ctx, *buf, len); +} + + +void +MHD_MD5_final (struct Md5CtxExt *ctx, unsigned char *md) +{ + MD5_final (md, *ctx); } diff --git a/src/microhttpd/md5_ext_openssl.h b/src/microhttpd/md5_ext_openssl.h index db77196d..96092bb3 100644 --- a/src/microhttpd/md5_ext_openssl.h +++ b/src/microhttpd/md5_ext_openssl.h @@ -23,35 +23,37 @@ * @author Édouard LEFIZELIER */ -#ifndef MHD_MD5_EXT_OPENSSL_H -#define MHD_MD5_EXT_OPENSSL_H 1 - - -/* -MD5 calcul return -*/ - -struct Md5CtxExt_OpenSSL -{ - unsigned char *hash; /** Data's hash calculated */ - int ext_error; /** Non-zero if external error occurs during init or hashing */ -}; +#ifndef MHD_MD5_EXT_OPENSSL +#define MHD_MD5_EXT_OPENSSL 1 +#include /** - * Indicates that MHD_MD5() function is present. - */ -#define MHD_MD5 1 - - -/** - * Calculate MD5 hash of the data. + * Initialise structure for MD5 calculation * - * @param c the informations about the hash return - * @param d the data to hash - * @param n the length of the data + * @param ctx the calculation context +*/ +void +MHD_MD5_init (struct Md5CtxExt *ctx); + +/** + * Process portion of bytes. + * + * @param ctx the calculation context + * @param data bytes to add to hash + * @param length number of bytes in @a data +*/ +void +MHD_MD5_update (struct Md5CtxExt *ctx, const void *buf, int len); + +/** + * Finalise MD5 calculation, return digest. + * + * @param ctx the calculation context + * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes */ void -MHD_MD5 (struct Md5CtxExt_OpenSSL *c, - const unsigned char *d, - size_t n) \ No newline at end of file +MHD_MD5_final (struct Md5CtxExt *ctx, unsigned char *md); + + +#endif