mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Update CMake options of RDRND
Separate CMake option of rdrand and rdseed. In some CPUs only rdrand is supported.
This commit is contained in:
@@ -256,15 +256,21 @@ if (ENABLE_BROKEN_CRYPTO)
|
||||
endif()
|
||||
|
||||
|
||||
option(ENABLE_RDRND "Enable Intel RDRND instructions" OFF)
|
||||
option(ENABLE_INTEL_RDRAND "Enable Intel RDRAND instructions" OFF)
|
||||
option(ENABLE_INTEL_RDSEED "Enable Intel RDSEED instructions" OFF)
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64)
|
||||
set(ENABLE_RDRND ON)
|
||||
set(ENABLE_INTEL_RDRAND ON)
|
||||
endif()
|
||||
if (ENABLE_RDRND)
|
||||
message(STATUS "ENABLE_RDRND")
|
||||
if (ENABLE_INTEL_RDRAND)
|
||||
message(STATUS "ENABLE_INTEL_RDRAND")
|
||||
list(APPEND src src/rdrand.c)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mrdrnd -mrdseed")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mrdrnd")
|
||||
if (ENABLE_INTEL_RDSEED)
|
||||
add_definitions(-DINTEL_RDSEED)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mrdseed")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
option(ENABLE_GMT_0105_RNG "Enable GM/T 0105 Software RNG" OFF)
|
||||
if (ENABLE_GMT_0105_RNG)
|
||||
|
||||
@@ -21,7 +21,10 @@ extern "C" {
|
||||
|
||||
|
||||
int rdrand_bytes(uint8_t *buf, size_t buflen);
|
||||
|
||||
#ifdef INTEL_RDSEED
|
||||
int rdseed_bytes(uint8_t *buf, size_t buflen);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -32,6 +32,7 @@ int rdrand_bytes(uint8_t *buf, size_t buflen)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef INTEL_RDSEED
|
||||
int rdseed_bytes(uint8_t *buf, size_t buflen)
|
||||
{
|
||||
unsigned long long val;
|
||||
@@ -49,3 +50,4 @@ int rdseed_bytes(uint8_t *buf, size_t buflen)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user