This commit is contained in:
Edouard LEFIZELIER
2023-03-20 12:24:03 +01:00
parent 4fbf228680
commit 5906f6d179
4 changed files with 196 additions and 1 deletions
+1 -1
View File
@@ -116,7 +116,7 @@ libmicrohttpd_la_LDFLAGS = \
-export-dynamic -no-undefined \
-version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@
libmicrohttpd_la_LIBADD = \
$(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS)
$(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS) -lcrypto
if HAVE_W32
+99
View File
@@ -0,0 +1,99 @@
/*
This file is part of GNU libmicrohttpd
Copyright (C) 2022 Evgeny Grin (Karlson2k)
GNU libmicrohttpd is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with GNU libmicrohttpd.
If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file microhttpd/md5_ext.h
* @brief Wrapper for MD5 calculation performed by TLS library
* @author Karlson2k (Evgeny Grin)
* @author Edouard LEFIZELIER
*/
#include <openssl/crypto.h>
#include "md5_ext.h"
#include "mhd_assert.h"
/**
* Initialise structure for MD5 calculation.
*
* @param ctx the calculation context
*/
void
MHD_MD5_init (struct Md5Ctx *ctx)
{
MD5_CTX c;
/*Initial Hash value, see OpenSSL manual*/
if (1 = MD5_INIT (&c))
{
ctx->H[0] = c->A;
ctx->H[1] = c->B;
ctx->H[2] = c->C;
ctx->H[3] = c->D;
/* Initialise the number of bytes. */
ctx->count = 0;
}
OPENSSL_cleanse (c, sizeof(*c));
}
/* à terminer */
/**
* 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 uint8_t *data,
size_t length)
{
MD5_CTX c;
if (0 == ctx->ext_error)
/* MD5_Update() return 1 for success, 0 otherwise.*/
ctx->ext_error = ! MD5_Update (c, data, length);
}
/* à terminer */
/**
* Finalise MD5 calculation, return digest, reset hash calculation.
*
* @param ctx the calculation context
* @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes
*/
void
MHD_MD5_finish_reset (struct Md5CtxExt *ctx,
uint8_t digest[MD5_DIGEST_SIZE])
{
if (0 == ctx->ext_error)
gnutls_hash_output (ctx->handle, digest);
}
/*
typedef struct MD5state_st
101 {
102 MD5_LONG A,B,C,D;
103 MD5_LONG Nl,Nh;
104 MD5_LONG data[MD5_LBLOCK];
105 unsigned int num;
106 } MD5_CTX;
*/
+47
View File
@@ -0,0 +1,47 @@
/*
This file is part of GNU libmicrohttpd
Copyright (C) 2022 Evgeny Grin (Karlson2k)
GNU libmicrohttpd is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with GNU libmicrohttpd.
If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file microhttpd/md5_ext.h
* @brief Wrapper for MD5 calculation performed by TLS library
* @author Karlson2k (Evgeny Grin)
* @author Edouard LEFIZELIER
*/
#include <openssl/crypto.h>
#include "md5_ext_openssl_bis.h"
#include "mhd_assert.h"
void
MHD_MD5 (struct Md5CtxExt *ctx,
const unsigned char *d,
size_t n)
{
unsigned char *md;
if (NULL == MD5 (d, n, md))
{
ctx->ext_error = 1;
}
else
{
ctx->ext_error = 0;
memcpy (ctx->handle, md, sizeof(ctx->digest));
}
}
+49
View File
@@ -58,12 +58,61 @@ microhttpd/sha256_ext.c:
microhttpd/test_upgrade_large.c:
51: #include <gnutls/gnutls.h>
-> gnutlscli_connect(...)
-> command gnutls-cli
-> type gnutls_certificate_credentials_t
-> type gnutls_session_t
-> GNUTLS_E_SUCCESS
-> GNUTLS_CLIENT
-> gnutls_set_default_priority(...)
-> gnutls_certificate_allocate_credentials(...)
-> gnutls_credentials_set(...)
-> GNUTLS_CRD_CERTIFICATE
-> GNUTLS_VERSION_NUMBER
-> gnutls_transport_set_int(...)
-> gnutls_transport_set_ptr(...)
-> type gnutls_transport_ptr_t
-> gnutls_certificate_free_credentials(...)
-> gnutls_deinit(...)
-> gnutls_handshake(...)
-> GNUTLS_E_AGAIN
-> gnutls_record_send(...)
-> gnutls_record_recv(...)
-> gnutlscli_connect(...)
-> parameter "--use-gnutls-cli"
-> parameter "--use-gnutls-lib"
-> gnutls_global_init(...)
-> gnutls_global_deinit(...)
microhttpd/test_upgrade.c:
54: #include <gnutls/gnutls.h>
-> same as test_upgrade_large.c
testcurl/https/test_https_sni.c:
37: #include <gnutls/gnutls.h>
-> type gnutls_pcert_st
-> type gnutls_privkey_t
-> type gnutls_datum_t
-> gnutls_load_file(...)
-> gnutls_pcert_import_x509_raw
-> gnutls_strerror(...)
-> gnutls_free(...)
-> gnutls_load_file(...)
-> gnutls_privkey_init(...)
-> gnutls_privkey_import_x509_raw(...)
-> GNUTLS_X509_FMT_PEM
-> gnutls_strerror(...)
-> gnutls_free(...)
-> type gnutls_session_t
-> type gnutls_datum_t
-> type gnutls_pk_algorithm_t
-> type gnutls_pcert_st
-> type gnutls_privkey_t
-> GNUTLS_E_SUCCESS
-> gnutls_server_name_get(...)
-> curl_tls_is_gnutls(...)
42: #include <gnutls/abstract.h>
testcurl/https/tls_test_common.h: