diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f0d5c8d..cfe63b18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,18 +338,8 @@ if(CRYPTO_BACKEND STREQUAL "WinCNG" OR NOT CRYPTO_BACKEND) set(CRYPTO_BACKEND_DEFINE "LIBSSH2_WINCNG") set(CRYPTO_BACKEND_INCLUDE_DIR "") - set(HAVE_LIBCRYPT32 TRUE) - list(APPEND LIBRARIES bcrypt) - list(APPEND PC_LIBS -lbcrypt) - - # Reading keys from files is optional and depends on Wincrypt - check_include_files("windows.h;wincrypt.h" HAVE_WINCRYPT_H) - - if(HAVE_WINCRYPT_H) - list(APPEND LIBRARIES crypt32) - list(APPEND PC_LIBS -lcrypt32) - endif() - + list(APPEND LIBRARIES crypt32 bcrypt) + list(APPEND PC_LIBS -lcrypt32 -lbcrypt) elseif(${SPECIFIC_CRYPTO_REQUIREMENT} STREQUAL ${REQUIRED}) message(FATAL_ERROR "WinCNG not available") endif() diff --git a/Makefile.WinCNG.inc b/Makefile.WinCNG.inc index bbcb82bf..09e41096 100644 --- a/Makefile.WinCNG.inc +++ b/Makefile.WinCNG.inc @@ -1,3 +1,3 @@ CRYPTO_CSOURCES = wincng.c CRYPTO_HHEADERS = wincng.h -CRYPTO_LTLIBS = $(LTLIBBCRYPT) $(LTLIBCRYPT32) +CRYPTO_LTLIBS = $(LTLIBBCRYPT) diff --git a/acinclude.m4 b/acinclude.m4 index 130ac8bb..85de8c14 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -449,10 +449,8 @@ m4_case([$1], [wincng], [ # Look for Windows Cryptography API: Next Generation - LIBSSH2_LIB_HAVE_LINKFLAGS([crypt32], [], [ - #include - #include - ]) + LIBS="$LIBS -lcrypt32" + LIBSSH2_LIB_HAVE_LINKFLAGS([bcrypt], [], [ #include #include @@ -504,4 +502,3 @@ AC_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]), CFLAGS="$CFLAGS -Werror" fi ]) - diff --git a/os400/libssh2_config.h b/os400/libssh2_config.h index 1c07d1f2..f3bf725d 100644 --- a/os400/libssh2_config.h +++ b/os400/libssh2_config.h @@ -77,9 +77,6 @@ /* use Ioctlsocket() for non-blocking sockets */ #undef HAVE_IOCTLSOCKET_CASE -/* Define if you have the crypt32 library. */ -#undef HAVE_LIBCRYPT32 - /* Define if you have the gcrypt library. */ #undef HAVE_LIBGCRYPT diff --git a/src/libssh2_config_cmake.h.in b/src/libssh2_config_cmake.h.in index 2bca1e4a..ccace656 100644 --- a/src/libssh2_config_cmake.h.in +++ b/src/libssh2_config_cmake.h.in @@ -50,9 +50,6 @@ #cmakedefine HAVE_ARPA_INET_H #cmakedefine HAVE_NETINET_IN_H -/* Libraries */ -#cmakedefine HAVE_LIBCRYPT32 - /* Types */ #cmakedefine HAVE_LONGLONG diff --git a/src/wincng.c b/src/wincng.c index e17ae454..46a29d85 100644 --- a/src/wincng.c +++ b/src/wincng.c @@ -48,6 +48,10 @@ #define _WIN32_WINNT 0x0600 #endif +#if !defined(LIBSSH2_WINCNG_DISABLE_WINCRYPT) && !defined(HAVE_LIBCRYPT32) +#define HAVE_LIBCRYPT32 +#endif + /* specify the required libraries for dependencies using MSVC */ #ifdef _MSC_VER #pragma comment(lib, "bcrypt.lib") @@ -63,7 +67,7 @@ #include #ifdef HAVE_LIBCRYPT32 -#include +#include /* for CryptDecodeObjectEx() */ #endif #define PEM_RSA_HEADER "-----BEGIN RSA PRIVATE KEY-----" diff --git a/win32/libssh2_config.h b/win32/libssh2_config.h index da4af839..371ae634 100644 --- a/win32/libssh2_config.h +++ b/win32/libssh2_config.h @@ -9,7 +9,6 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #endif -#define HAVE_LIBCRYPT32 #define HAVE_IOCTLSOCKET #define HAVE_SELECT #define HAVE_SNPRINTF