Skip to content

Commit

Permalink
Land #188, add ASM support for cmake builds
Browse files Browse the repository at this point in the history
  • Loading branch information
busterb committed Apr 9, 2016
2 parents 2510a5e + e1f8a1e commit 752ad82
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ endif()

add_definitions(-DLIBRESSL_INTERNAL)
add_definitions(-DOPENSSL_NO_HW_PADLOCK)
add_definitions(-DOPENSSL_NO_ASM)

set(CMAKE_POSITION_INDEPENDENT_CODE true)

Expand Down Expand Up @@ -182,6 +181,14 @@ if(HAVE_ERR_H)
add_definitions(-DHAVE_ERR_H)
endif()

if("${CMAKE_C_COMPILER_ABI}" STREQUAL "ELF" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND ENABLE_ASM)
set(HOST_ASM_ELF_X86_64 true)
endif()

if(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND ENABLE_ASM)
set(HOST_ASM_MACOSX_X86_64 true)
endif()

set(OPENSSL_LIBS ssl crypto)
if(CMAKE_HOST_WIN32)
set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
Expand Down
115 changes: 107 additions & 8 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,107 @@ include_directories(
modes
)

if(HOST_ASM_ELF_X86_64)
set(
ASM_X86_64_ELF_SRC
aes/aes-elf-x86_64.s
aes/bsaes-elf-x86_64.s
aes/vpaes-elf-x86_64.s
aes/aesni-elf-x86_64.s
aes/aesni-sha1-elf-x86_64.s
bn/modexp512-elf-x86_64.s
bn/mont-elf-x86_64.s
bn/mont5-elf-x86_64.s
bn/gf2m-elf-x86_64.s
camellia/cmll-elf-x86_64.s
md5/md5-elf-x86_64.s
modes/ghash-elf-x86_64.s
rc4/rc4-elf-x86_64.s
rc4/rc4-md5-elf-x86_64.s
sha/sha1-elf-x86_64.s
sha/sha256-elf-x86_64.S
sha/sha512-elf-x86_64.S
whrlpool/wp-elf-x86_64.s
cpuid-elf-x86_64.S
)
add_definitions(-DAES_ASM)
add_definitions(-DBSAES_ASM)
add_definitions(-DVPAES_ASM)
add_definitions(-DOPENSSL_IA32_SSE2)
add_definitions(-DOPENSSL_BN_ASM_MONT)
add_definitions(-DOPENSSL_BN_ASM_MONT5)
add_definitions(-DOPENSSL_BN_ASM_GF2m)
add_definitions(-DMD5_ASM)
add_definitions(-DGHASH_ASM)
add_definitions(-DRSA_ASM)
add_definitions(-DSHA1_ASM)
add_definitions(-DSHA256_ASM)
add_definitions(-DSHA512_ASM)
add_definitions(-DWHIRLPOOL_ASM)
add_definitions(-DOPENSSL_CPUID_OBJ)
set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_ELF_SRC})
set_property(SOURCE ${ASM_X86_64_ELF_SRC} PROPERTY LANGUAGE C)
endif()

if(HOST_ASM_MACOSX_X86_64)
set(
ASM_X86_64_MACOSX_SRC
aes/aes-macosx-x86_64.s
aes/bsaes-macosx-x86_64.s
aes/vpaes-macosx-x86_64.s
aes/aesni-macosx-x86_64.s
aes/aesni-sha1-macosx-x86_64.s
bn/modexp512-macosx-x86_64.s
bn/mont-macosx-x86_64.s
bn/mont5-macosx-x86_64.s
bn/gf2m-macosx-x86_64.s
camellia/cmll-macosx-x86_64.s
md5/md5-macosx-x86_64.s
modes/ghash-macosx-x86_64.s
rc4/rc4-macosx-x86_64.s
rc4/rc4-md5-macosx-x86_64.s
sha/sha1-macosx-x86_64.s
sha/sha256-macosx-x86_64.S
sha/sha512-macosx-x86_64.S
whrlpool/wp-macosx-x86_64.s
cpuid-macosx-x86_64.S
)
add_definitions(-DAES_ASM)
add_definitions(-DBSAES_ASM)
add_definitions(-DVPAES_ASM)
add_definitions(-DOPENSSL_IA32_SSE2)
add_definitions(-DOPENSSL_BN_ASM_MONT)
add_definitions(-DOPENSSL_BN_ASM_MONT5)
add_definitions(-DOPENSSL_BN_ASM_GF2m)
add_definitions(-DMD5_ASM)
add_definitions(-DGHASH_ASM)
add_definitions(-DRSA_ASM)
add_definitions(-DSHA1_ASM)
add_definitions(-DSHA256_ASM)
add_definitions(-DSHA512_ASM)
add_definitions(-DWHIRLPOOL_ASM)
add_definitions(-DOPENSSL_CPUID_OBJ)
set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MACOSX_SRC})
set_property(SOURCE ${ASM_X86_64_MACOSX_SRC} PROPERTY LANGUAGE C)
endif()

if((NOT HOST_ASM_ELF_X86_64) AND (NOT HOST_ASM_MACOSX_X86_64))
set(
CRYPTO_SRC
${CRYPTO_SRC}
aes/aes_cbc.c
aes/aes_core.c
camellia/camellia.c
camellia/cmll_cbc.c
rc4/rc4_enc.c
rc4/rc4_skey.c
whrlpool/wp_block.c
)
endif()

set(
CRYPTO_SRC

aes/aes_cbc.c
aes/aes_core.c
camellia/camellia.c
camellia/cmll_cbc.c
rc4/rc4_enc.c
rc4/rc4_skey.c
whrlpool/wp_block.c
${CRYPTO_SRC}
cpt_err.c
cryptlib.c
cversion.c
Expand Down Expand Up @@ -643,6 +734,14 @@ if(NOT HAVE_TIMINGSAFE_MEMCMP)
set(CRYPTO_SRC ${CRYPTO_SRC} compat/timingsafe_memcmp.c)
endif()

if(NOT ENABLE_ASM)
add_definitions(-DOPENSSL_NO_ASM)
else()
if(CMAKE_HOST_WIN32)
add_definitions(-DOPENSSL_NO_ASM)
endif()
endif()

if (BUILD_SHARED)
add_library(crypto-objects OBJECT ${CRYPTO_SRC})
add_library(crypto STATIC $<TARGET_OBJECTS:crypto-objects>)
Expand Down

0 comments on commit 752ad82

Please sign in to comment.