config: fix building SMB with configure using Win32 Crypto

Align conditions for NTLM features between CMake and configure
builds by differentiating between USE_NTLM and USE_CURL_NTLM_CORE,
just like curl_setup.h does internally to detect support of:

- USE_NTLM: required for NTLM crypto authentication feature
- USE_CURL_NTLM_CORE: required for SMB protocol

Implement USE_WIN32_CRYPTO detection by checking for Crypt functions
in wincrypt.h which are not available in the Windows App environment.

Link advapi32 and crypt32 for Crypto API and Schannel SSL backend.
Fix condition of Schannel SSL backend in CMake build accordingly.

Reviewed-by: Marcel Raad

Closes #6277
This commit is contained in:
Marc Hoersken 2021-03-06 15:52:09 +01:00
parent 7152957421
commit cc615f48e7
No known key found for this signature in database
GPG key ID: 61E03CBED7BC859E
4 changed files with 131 additions and 39 deletions

View file

@ -347,6 +347,39 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
])
dnl CURL_CHECK_HEADER_WINCRYPT
dnl -------------------------------------------------
dnl Check for compilable and valid wincrypt.h header
AC_DEFUN([CURL_CHECK_HEADER_WINCRYPT], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
AC_CACHE_CHECK([for wincrypt.h], [curl_cv_header_wincrypt_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <wincrypt.h>
]],[[
int dummy=2*PROV_RSA_FULL;
]])
],[
curl_cv_header_wincrypt_h="yes"
],[
curl_cv_header_wincrypt_h="no"
])
])
case "$curl_cv_header_wincrypt_h" in
yes)
AC_DEFINE_UNQUOTED(HAVE_WINCRYPT_H, 1,
[Define to 1 if you have the wincrypt.h header file.])
;;
esac
])
dnl CURL_CHECK_HEADER_WINLDAP
dnl -------------------------------------------------
dnl Check for compilable and valid winldap.h header
@ -2353,11 +2386,54 @@ AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
AC_MSG_RESULT([yes (large file enabled)])
AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
[Define to 1 if you are building a Windows target with large file support.])
AC_SUBST(USE_WIN32_LARGE_FILES, [1])
;;
win32_small_files)
AC_MSG_RESULT([yes (large file disabled)])
AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
[Define to 1 if you are building a Windows target without large file support.])
AC_SUBST(USE_WIN32_SMALL_FILES, [1])
;;
*)
AC_MSG_RESULT([no])
;;
esac
])
dnl CURL_CHECK_WIN32_CRYPTO
dnl -------------------------------------------------
dnl Check if curl's WIN32 crypto lib can be used
AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
AC_REQUIRE([CURL_CHECK_HEADER_WINCRYPT])dnl
AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
curl_win32_crypto_api="no"
if test "$curl_cv_header_wincrypt_h" = "yes"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#undef inline
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <wincrypt.h>
]],[[
HCRYPTPROV hCryptProv;
if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
CryptReleaseContext(hCryptProv, 0);
}
]])
],[
curl_win32_crypto_api="yes"
])
fi
case "$curl_win32_crypto_api" in
yes)
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
[Define to 1 if you are building a Windows target with crypto API support.])
AC_SUBST(USE_WIN32_CRYPTO, [1])
;;
*)
AC_MSG_RESULT([no])