mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 08:38:49 -05:00
md4: Move the mbed TLS MD4 implementation out of the NTLM code
This commit is contained in:
parent
c5eb2fd618
commit
2ff216f1b0
@ -27,17 +27,15 @@
|
||||
#if defined(USE_GNUTLS_NETTLE) || defined(USE_GNUTLS) || \
|
||||
defined(USE_OPENSSL) || defined(USE_SECTRANSP) || \
|
||||
defined(USE_WIN32_CRYPTO) || defined(USE_NSS) || \
|
||||
defined(USE_OS400CRYPTO) || \
|
||||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
|
||||
defined(USE_OS400CRYPTO) || defined(USE_MBEDTLS)
|
||||
|
||||
#define MD4_DIGEST_LENGTH 16
|
||||
|
||||
void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len);
|
||||
|
||||
#endif /* defined(USE_GNUTLS_NETTLE) || defined(USE_GNUTLS) ||
|
||||
defined(USE_OPENSSL) || defined(USE_SECTRANSP) || \
|
||||
defined(USE_WIN32_CRYPTO) || defined(USE_NSS) || \
|
||||
defined(USE_OS400CRYPTO) || \
|
||||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C)) */
|
||||
defined(USE_OPENSSL) || defined(USE_SECTRANSP) ||
|
||||
defined(USE_WIN32_CRYPTO) || defined(USE_NSS) ||
|
||||
defined(USE_OS400CRYPTO) || defined(USE_MBEDTLS) */
|
||||
|
||||
#endif /* HEADER_CURL_MD4_H */
|
||||
|
@ -94,10 +94,7 @@
|
||||
#elif defined(USE_MBEDTLS)
|
||||
|
||||
# include <mbedtls/des.h>
|
||||
# include <mbedtls/md4.h>
|
||||
# if !defined(MBEDTLS_MD4_C)
|
||||
# include "curl_md4.h"
|
||||
# endif
|
||||
# include "curl_md4.h"
|
||||
|
||||
#elif defined(USE_SECTRANSP)
|
||||
|
||||
@ -575,11 +572,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
|
||||
#elif defined(USE_NSS)
|
||||
Curl_md4it(ntbuffer, pw, 2 * len);
|
||||
#elif defined(USE_MBEDTLS)
|
||||
#if defined(MBEDTLS_MD4_C)
|
||||
mbedtls_md4(pw, 2 * len, ntbuffer);
|
||||
#else
|
||||
Curl_md4it(ntbuffer, pw, 2 * len);
|
||||
#endif
|
||||
#elif defined(USE_SECTRANSP)
|
||||
Curl_md4it(ntbuffer, pw, 2 * len);
|
||||
#elif defined(USE_OS400CRYPTO)
|
||||
|
53
lib/md4.c
53
lib/md4.c
@ -180,6 +180,48 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
|
||||
CryptReleaseContext(ctx->hCryptProv, 0);
|
||||
}
|
||||
|
||||
#elif(defined(USE_MBEDTLS) && defined(MBEDTLS_MD4_C))
|
||||
|
||||
#include <mbedtls/md4.h>
|
||||
|
||||
#include "curl_md4.h"
|
||||
#include "warnless.h"
|
||||
#include "curl_memory.h"
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef struct {
|
||||
void *data;
|
||||
unsigned long size;
|
||||
} MD4_CTX;
|
||||
|
||||
static void MD4_Init(MD4_CTX *ctx)
|
||||
{
|
||||
ctx->data = NULL;
|
||||
ctx->size = 0;
|
||||
}
|
||||
|
||||
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
|
||||
{
|
||||
if(ctx->data == NULL) {
|
||||
ctx->data = malloc(size);
|
||||
if(ctx->data != NULL) {
|
||||
memcpy(ctx->data, data, size);
|
||||
ctx->size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
|
||||
{
|
||||
if(ctx->data != NULL) {
|
||||
mbedtls_md4(ctx->data, ctx->size, result);
|
||||
|
||||
Curl_safefree(ctx->data);
|
||||
ctx->size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(USE_NSS) || defined(USE_OS400CRYPTO) || \
|
||||
(defined(USE_OPENSSL) && defined(OPENSSL_NO_MD4)) || \
|
||||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
|
||||
@ -479,9 +521,7 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
|
||||
#if defined(USE_GNUTLS_NETTLE) || defined(USE_GNUTLS) || \
|
||||
defined(USE_OPENSSL) || defined(USE_SECTRANSP) || \
|
||||
defined(USE_WIN32_CRYPTO) || defined(USE_NSS) || \
|
||||
defined(USE_OS400CRYPTO) || \
|
||||
(defined(USE_OPENSSL) && defined(OPENSSL_NO_MD4)) || \
|
||||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
|
||||
defined(USE_OS400CRYPTO) || defined(USE_MBEDTLS)
|
||||
|
||||
void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len)
|
||||
{
|
||||
@ -492,7 +532,6 @@ void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len)
|
||||
}
|
||||
|
||||
#endif /* defined(USE_GNUTLS_NETTLE) || defined(USE_GNUTLS) ||
|
||||
defined(USE_OPENSSL) || defined(USE_SECTRANSP) || \
|
||||
defined(USE_WIN32_CRYPTO) || defined(USE_NSS) || \
|
||||
defined(USE_OS400CRYPTO) || \
|
||||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C)) */
|
||||
defined(USE_OPENSSL) || defined(USE_SECTRANSP) ||
|
||||
defined(USE_WIN32_CRYPTO) || defined(USE_NSS) ||
|
||||
defined(USE_OS400CRYPTO) || defined(USE_MBEDTLS) */
|
||||
|
Loading…
Reference in New Issue
Block a user