mirror of
https://github.com/curl/curl.git
synced 2026-08-24 15:23:36 +03:00
NTLM: disable if DES support missing from OpenSSL or mbedTLS
Make autotools and cmake detect DES support in OpenSSL and mbedTLS. Forward feature macros to C and omit NTLM from the feature preview list. Use the feature macros in source. This ensure that `-V` output matches the preview. OpenSSL doesn't support DES when built with `no-des` or `no-deprecated`. mbedTLS 4.x no longer supports it, and it's possible to disable it in <4 with `scripts/config.py unset MBEDTLS_DES_C`. Before this patch this worked for mbedTLS 4 only, and with a regression for pending PR #16973. Also: - drop NTLM feature check from `curl_setup.h` in favour of autotools/ cmake feature macros. This makes `curl_setup.h` no longer need to include an mbedTLS header, which in turn makes tests/server build without depending on mbedTLS. Fixing, in #16973: ``` In file included from tests/server/first.h:40, from bld/tests/server/servers.c:3: lib/curl_setup.h:741:10: fatal error: mbedtls/version.h: No such file or directory 741 | #include <mbedtls/version.h> | ^~~~~~~~~~~~~~~~~~~ ``` Ref: https://github.com/curl/curl/actions/runs/18689537893/job/53291322012?pr=16973 Ref: #19181 (initial fix idea) Follow-up to3a305831d1#19077 - move back mbedTLS header include and version check from `curl_setup.h` to each source which consumes mbedTLS. - GHA/http3-linux: drop workaround that disabled NTLM for `no-deprecated` OpenSSL builds. Follow-up to006977859d#12384 - curl_ntlm_core: drop pointless macro `CURL_NTLM_NOT_SUPPORTED`. Follow-up to006977859d#12384 Closes #19206
This commit is contained in:
parent
1de4a9a5fb
commit
4a6fbd5e1d
12 changed files with 95 additions and 79 deletions
|
|
@ -673,6 +673,9 @@ ${SIZEOF_TIME_T_CODE}
|
|||
/* if mbedTLS is enabled */
|
||||
#cmakedefine USE_MBEDTLS 1
|
||||
|
||||
/* if mbedTLS <4 has the mbedtls_des_crypt_ecb function. */
|
||||
#cmakedefine HAVE_MBEDTLS_DES_CRYPT_ECB 1
|
||||
|
||||
/* if Rustls is enabled */
|
||||
#cmakedefine USE_RUSTLS 1
|
||||
|
||||
|
|
@ -801,7 +804,10 @@ ${SIZEOF_TIME_T_CODE}
|
|||
#cmakedefine USE_ECH 1
|
||||
|
||||
/* Define to 1 if you have the wolfSSL_CTX_GenerateEchConfig function. */
|
||||
#cmakedefine HAVE_WOLFSSL_CTX_GENERATEECHCONFIG
|
||||
#cmakedefine HAVE_WOLFSSL_CTX_GENERATEECHCONFIG 1
|
||||
|
||||
/* Define to 1 if you have the SSL_set1_ech_config_list function. */
|
||||
#cmakedefine HAVE_SSL_SET1_ECH_CONFIG_LIST
|
||||
#cmakedefine HAVE_SSL_SET1_ECH_CONFIG_LIST 1
|
||||
|
||||
/* Define to 1 if OpenSSL has the DES_ecb_encrypt function. */
|
||||
#cmakedefine HAVE_DES_ECB_ENCRYPT 1
|
||||
|
|
|
|||
|
|
@ -50,21 +50,19 @@
|
|||
in NTLM type-3 messages.
|
||||
*/
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
#include <openssl/opensslconf.h>
|
||||
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
#define USE_OPENSSL_DES
|
||||
#endif
|
||||
#elif defined(USE_WOLFSSL)
|
||||
#include <wolfssl/options.h>
|
||||
#ifndef NO_DES3
|
||||
#define USE_OPENSSL_DES
|
||||
#endif
|
||||
#elif defined(USE_MBEDTLS)
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x04000000
|
||||
#define USE_MBEDTLS_DES
|
||||
#endif
|
||||
#ifdef USE_MBEDTLS
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_OPENSSL) && defined(HAVE_DES_ECB_ENCRYPT)
|
||||
#define USE_OPENSSL_DES
|
||||
#elif defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT)
|
||||
#define USE_OPENSSL_DES
|
||||
#elif defined(USE_MBEDTLS) && defined(HAVE_MBEDTLS_DES_CRYPT_ECB)
|
||||
#define USE_MBEDTLS_DES
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENSSL_DES
|
||||
|
|
@ -79,6 +77,7 @@
|
|||
# endif
|
||||
# define DESKEY(x) &x
|
||||
#else
|
||||
# include <wolfssl/options.h>
|
||||
# include <wolfssl/openssl/des.h>
|
||||
# include <wolfssl/openssl/md5.h>
|
||||
# include <wolfssl/openssl/ssl.h>
|
||||
|
|
@ -111,7 +110,6 @@
|
|||
# include <wincrypt.h>
|
||||
#else
|
||||
# error "cannot compile NTLM support without a crypto library with DES."
|
||||
# define CURL_NTLM_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#include "urldata.h"
|
||||
|
|
@ -128,7 +126,6 @@
|
|||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef CURL_NTLM_NOT_SUPPORTED
|
||||
/*
|
||||
* Turns a 56-bit key into being 64-bit wide.
|
||||
*/
|
||||
|
|
@ -143,7 +140,6 @@ static void extend_key_56_to_64(const unsigned char *key_56, char *key)
|
|||
key[6] = (char)(((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6));
|
||||
key[7] = (char) ((key_56[6] << 1) & 0xFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENSSL_DES
|
||||
/*
|
||||
|
|
@ -328,11 +324,9 @@ CURLcode Curl_ntlm_core_mk_lm_hash(const char *password,
|
|||
unsigned char *lmbuffer /* 21 bytes */)
|
||||
{
|
||||
unsigned char pw[14];
|
||||
#ifndef CURL_NTLM_NOT_SUPPORTED
|
||||
static const unsigned char magic[] = {
|
||||
0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 /* i.e. KGS!@#$% */
|
||||
};
|
||||
#endif
|
||||
size_t len = CURLMIN(strlen(password), 14);
|
||||
|
||||
Curl_strntoupper((char *)pw, password, len);
|
||||
|
|
|
|||
|
|
@ -737,13 +737,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_MBEDTLS
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_WOLFSSL) && defined(USE_GNUTLS)
|
||||
/* Avoid defining unprefixed wolfSSL SHA macros colliding with nettle ones */
|
||||
#define NO_OLD_WC_NAMES
|
||||
|
|
@ -763,9 +756,9 @@
|
|||
|
||||
/* Single point where USE_NTLM definition might be defined */
|
||||
#ifndef CURL_DISABLE_NTLM
|
||||
# if defined(USE_OPENSSL) || \
|
||||
# if (defined(USE_OPENSSL) && defined(HAVE_DES_ECB_ENCRYPT)) || \
|
||||
defined(USE_GNUTLS) || \
|
||||
(defined(USE_MBEDTLS) && MBEDTLS_VERSION_NUMBER < 0x04000000) || \
|
||||
(defined(USE_MBEDTLS) && defined(HAVE_MBEDTLS_DES_CRYPT_ECB)) || \
|
||||
defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
|
||||
(defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
|
||||
# define USE_CURL_NTLM_CORE
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@
|
|||
#endif
|
||||
|
||||
#ifdef USE_MBEDTLS
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#if defined(PSA_WANT_ALG_MD5) && PSA_WANT_ALG_MD5 /* mbedTLS 4+ */
|
||||
#define USE_MBEDTLS_MD5
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@
|
|||
#include "curl_hmac.h"
|
||||
|
||||
#ifdef USE_MBEDTLS
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#if defined(PSA_WANT_ALG_SHA_256) && PSA_WANT_ALG_SHA_256 /* mbedTLS 4+ */
|
||||
#define USE_MBEDTLS_SHA256
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
/* #define MBEDTLS_DEBUG */
|
||||
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#include <mbedtls/net_sockets.h>
|
||||
#include <mbedtls/ssl.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue