Commit 1bf9acce authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-20386: Allow RDRAND, RDSEED WITH_MSAN

Let us use Intel intrinsic functions in WolfSSL whenever possible.
This allows such code to be compiled WITH_MSAN.
parent c1f0afb1
......@@ -9,20 +9,32 @@ ENDIF()
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
IF(MSVC)
SET(WOLFSSL_INTELASM ON)
SET(WOLFSSL_X86_64_BUILD 1)
SET(HAVE_INTEL_RDSEED 1)
SET(HAVE_INTEL_RDRAND 1)
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
SET(WOLFSSL_X86_64_BUILD 1)
IF(CMAKE_C_COMPILER_ID MATCHES GNU AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
MESSAGE_ONCE(NO_INTEL_ASSEMBLY "Disable Intel assembly for WolfSSL - compiler is too old")
ELSEIF(WITH_MSAN)
MESSAGE_ONCE(MSAN_CANT_HANDLE_IT
"Disable Intel assembly for WolfSSL - MSAN can't handle it")
ELSE()
MY_CHECK_C_COMPILER_FLAG(-maes)
MY_CHECK_C_COMPILER_FLAG(-msse4)
MY_CHECK_C_COMPILER_FLAG(-mpclmul)
IF(WITH_MSAN)
MESSAGE_ONCE(MSAN_CANT_HANDLE_IT
"Disable Intel assembly for WolfSSL - MSAN can't handle it")
ELSE()
MY_CHECK_C_COMPILER_FLAG(-maes)
MY_CHECK_C_COMPILER_FLAG(-msse4)
MY_CHECK_C_COMPILER_FLAG(-mpclmul)
IF(have_C__maes AND have_C__msse4 AND have_C__mpclmul)
SET(WOLFSSL_INTELASM ON)
ENDIF()
ENDIF()
MY_CHECK_C_COMPILER_FLAG(-mrdrnd)
MY_CHECK_C_COMPILER_FLAG(-mrdseed)
IF(have_C__maes AND have_C__msse4 AND have_C__mpclmul)
SET(WOLFSSL_INTELASM ON)
IF(have_C__mrdrnd)
SET(HAVE_INTEL_RDRAND ON)
ENDIF()
IF(have_C__mrdseed)
SET(HAVE_INTEL_RDSEED ON)
ENDIF()
ENDIF()
ENDIF()
......@@ -109,33 +121,22 @@ ELSE()
SET(WOLFCRYPT_SOURCES ${WOLFCRYPT_SOURCES} ${WOLFCRYPT_SRCDIR}/integer.c)
ENDIF()
IF(WOLFSSL_INTELASM)
SET(WOLFSSL_AESNI 1)
IF(WOLFSSL_X86_64_BUILD)
LIST(APPEND WOLFCRYPT_SOURCES ${WOLFCRYPT_SRCDIR}/cpuid.c)
IF(MSVC)
SET(WOLFSSL_AESNI 1)
LIST(APPEND WOLFCRYPT_SOURCES ${WOLFCRYPT_SRCDIR}/aes_asm.asm)
SET(WOLFSSL_X86_64_BUILD 1)
SET(HAVE_INTEL_RDSEED 1)
SET(HAVE_INTEL_RDRAND 1)
IF(CMAKE_C_COMPILER_ID MATCHES Clang)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -msse4.2 -mpclmul -mrdrnd -mrdseed")
ENDIF()
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
ELSEIF(WOLFSSL_INTELASM)
SET(WOLFSSL_AESNI 1)
SET(USE_INTEL_SPEEDUP 1)
LIST(APPEND WOLFCRYPT_SOURCES
${WOLFCRYPT_SRCDIR}/aes_asm.S
${WOLFCRYPT_SRCDIR}/sha512_asm.S
${WOLFCRYPT_SRCDIR}/sha256_asm.S)
ADD_DEFINITIONS(-maes -msse4 -mpclmul)
IF(have_C__mrdrnd)
SET(HAVE_INTEL_RDRAND 1)
ADD_DEFINITIONS(-mrdrnd)
ENDIF()
IF(have_C__mrdseed)
SET(HAVE_INTEL_RDSEED 1)
ADD_DEFINITIONS(-mrdseed)
ENDIF()
${WOLFCRYPT_SRCDIR}/aes_asm.S
${WOLFCRYPT_SRCDIR}/sha512_asm.S
${WOLFCRYPT_SRCDIR}/sha256_asm.S)
ADD_DEFINITIONS(-maes -msse4.2 -mpclmul)
ENDIF()
ENDIF()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment