mirror of https://github.com/microsoft/vcpkg.git
73 lines
2.4 KiB
Diff
73 lines
2.4 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 6b5c73c..77ca1f5 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -23,6 +23,8 @@ set(PACKAGE_RELEASE_VERSION 1)
|
|
include(GNUInstallDirs)
|
|
include(CheckIPOSupported)
|
|
include(CMakePackageConfigHelpers)
|
|
+include(CMakePushCheckState)
|
|
+include(CheckSymbolExists)
|
|
# default is "No tests"
|
|
option(BUILD_TESTING "" OFF)
|
|
include(CTest)
|
|
@@ -119,6 +121,18 @@ target_link_options(${PROJECT_NAME} BEFORE PRIVATE
|
|
${LTM_LD_FLAGS}
|
|
)
|
|
|
|
+if(MSVC)
|
|
+ cmake_push_check_state()
|
|
+ set(CMAKE_REQUIRED_LIBRARIES bcrypt)
|
|
+ check_symbol_exists(BCryptGenRandom "windows.h;bcrypt.h" BCRYPT_AVAILABLE)
|
|
+ cmake_pop_check_state()
|
|
+ if(BCRYPT_AVAILABLE)
|
|
+ target_compile_definitions(${PROJECT_NAME} PRIVATE LTM_WIN32_BCRYPT)
|
|
+ target_link_libraries(${PROJECT_NAME} PRIVATE bcrypt)
|
|
+ string(APPEND PC_LIBS_PRIVATE -lbcrypt)
|
|
+ endif()
|
|
+endif()
|
|
+
|
|
set(PUBLIC_HEADERS tommath.h)
|
|
set(C89 False CACHE BOOL "(Usually maintained automatically) Enable when the library is in c89 mode to package the correct header files on install")
|
|
if(C89)
|
|
diff --git a/bn_s_mp_rand_platform.c b/bn_s_mp_rand_platform.c
|
|
index 27339bf..097f7be 100644
|
|
--- a/bn_s_mp_rand_platform.c
|
|
+++ b/bn_s_mp_rand_platform.c
|
|
@@ -29,6 +29,17 @@ static mp_err s_read_arc4random(void *p, size_t n)
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <windows.h>
|
|
+
|
|
+#ifdef LTM_WIN32_BCRYPT
|
|
+#include <bcrypt.h>
|
|
+#pragma comment(lib, "bcrypt")
|
|
+
|
|
+static mp_err s_read_wincsp(void *p, size_t n)
|
|
+{
|
|
+ return BCRYPT_SUCCESS(BCryptGenRandom(NULL, (PUCHAR)p, (ULONG)n,
|
|
+ BCRYPT_USE_SYSTEM_PREFERRED_RNG)) ? MP_OKAY : MP_ERR;
|
|
+}
|
|
+#else
|
|
#include <wincrypt.h>
|
|
|
|
static mp_err s_read_wincsp(void *p, size_t n)
|
|
@@ -46,6 +57,7 @@ static mp_err s_read_wincsp(void *p, size_t n)
|
|
}
|
|
return CryptGenRandom(hProv, (DWORD)n, (BYTE *)p) == TRUE ? MP_OKAY : MP_ERR;
|
|
}
|
|
+#endif
|
|
#endif /* WIN32 */
|
|
|
|
#if !defined(BN_S_READ_WINCSP_C) && defined(__linux__) && defined(__GLIBC_PREREQ)
|
|
diff --git a/libtommath.pc.in b/libtommath.pc.in
|
|
index 7ce50fd..4b8e5fa 100644
|
|
--- a/libtommath.pc.in
|
|
+++ b/libtommath.pc.in
|
|
@@ -6,4 +6,5 @@ Name: LibTomMath
|
|
Description: public domain library for manipulating large integer numbers
|
|
Version: @PROJECT_VERSION@
|
|
Libs: -L${libdir} -ltommath
|
|
+Libs.private: @PC_LIBS_PRIVATE@
|
|
Cflags: -I${includedir}
|