From 03cd45e2c78b0298ab006fb64a4cda4fe6ab5657 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 6 Dec 2014 18:43:58 -0600 Subject: Enable optimized crypto operations for x86_64 This adds initial support for assembly crypto acceleration on x86_64 for ELF (Linux, *BSD, Solaris) and Mach-O (OS-X) systems. The build method is a little different than OpenSSL and OpenBSD. All the .s files are generated ahead of time when the tarball is generated, so there are no complicated makefile rules at configure/build time. This also means the builds are faster and perl is not required on the build system. Thanks to Wouter Clarie for providing the initial cleanup and patch that this is based on. --- crypto/Makefile.am | 28 +++++++++++++++++++-------- crypto/Makefile.am.elf-x86_64 | 41 ++++++++++++++++++++++++++++++++++++++++ crypto/Makefile.am.macosx-x86_64 | 41 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 crypto/Makefile.am.elf-x86_64 create mode 100644 crypto/Makefile.am.macosx-x86_64 (limited to 'crypto') diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 39b143d..91c58db 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am @@ -10,7 +10,11 @@ EXTRA_DIST = VERSION libcrypto_la_LDFLAGS = -version-info @LIBCRYPTO_VERSION@ libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la -libcrypto_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) -DOPENSSL_NO_HW_PADLOCK +libcrypto_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) +libcrypto_la_CFLAGS += -DOPENSSL_NO_HW_PADLOCK +if OPENSSL_NO_ASM +libcrypto_la_CFLAGS += -DOPENSSL_NO_ASM +endif noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la @@ -103,6 +107,21 @@ noinst_HEADERS += compat/chacha_private.h libcrypto_la_SOURCES = EXTRA_libcrypto_la_SOURCES = +include Makefile.am.elf-x86_64 +include Makefile.am.macosx-x86_64 + +if !HOST_ASM_ELF_X86_64 +if !HOST_ASM_MACOSX_X86_64 +libcrypto_la_SOURCES += aes/aes_cbc.c +libcrypto_la_SOURCES += aes/aes_core.c +libcrypto_la_SOURCES += camellia/camellia.c +libcrypto_la_SOURCES += camellia/cmll_cbc.c +libcrypto_la_SOURCES += rc4/rc4_enc.c +libcrypto_la_SOURCES += rc4/rc4_skey.c +libcrypto_la_SOURCES += whrlpool/wp_block.c +endif +endif + libcrypto_la_SOURCES += cpt_err.c libcrypto_la_SOURCES += cryptlib.c libcrypto_la_SOURCES += cversion.c @@ -118,9 +137,7 @@ noinst_HEADERS += md32_common.h noinst_HEADERS += o_time.h # aes -libcrypto_la_SOURCES += aes/aes_cbc.c libcrypto_la_SOURCES += aes/aes_cfb.c -libcrypto_la_SOURCES += aes/aes_core.c libcrypto_la_SOURCES += aes/aes_ctr.c libcrypto_la_SOURCES += aes/aes_ecb.c libcrypto_la_SOURCES += aes/aes_ige.c @@ -284,8 +301,6 @@ libcrypto_la_SOURCES += buffer/buf_str.c libcrypto_la_SOURCES += buffer/buffer.c # camellia -libcrypto_la_SOURCES += camellia/camellia.c -libcrypto_la_SOURCES += camellia/cmll_cbc.c libcrypto_la_SOURCES += camellia/cmll_cfb.c libcrypto_la_SOURCES += camellia/cmll_ctr.c libcrypto_la_SOURCES += camellia/cmll_ecb.c @@ -666,8 +681,6 @@ libcrypto_la_SOURCES += rc2/rc2ofb64.c noinst_HEADERS += rc2/rc2_locl.h # rc4 -libcrypto_la_SOURCES += rc4/rc4_enc.c -libcrypto_la_SOURCES += rc4/rc4_skey.c noinst_HEADERS += rc4/rc4_locl.h # ripemd @@ -739,7 +752,6 @@ libcrypto_la_SOURCES += ui/ui_util.c noinst_HEADERS += ui/ui_locl.h # whrlpool -libcrypto_la_SOURCES += whrlpool/wp_block.c libcrypto_la_SOURCES += whrlpool/wp_dgst.c noinst_HEADERS += whrlpool/wp_locl.h diff --git a/crypto/Makefile.am.elf-x86_64 b/crypto/Makefile.am.elf-x86_64 new file mode 100644 index 0000000..6257c40 --- /dev/null +++ b/crypto/Makefile.am.elf-x86_64 @@ -0,0 +1,41 @@ + +ASM_X86_64_ELF = aes/aes-elf-x86_64.s +ASM_X86_64_ELF += aes/bsaes-elf-x86_64.s +ASM_X86_64_ELF += aes/vpaes-elf-x86_64.s +ASM_X86_64_ELF += aes/aesni-elf-x86_64.s +ASM_X86_64_ELF += aes/aesni-sha1-elf-x86_64.s +ASM_X86_64_ELF += bn/modexp512-elf-x86_64.s +ASM_X86_64_ELF += bn/mont-elf-x86_64.s +ASM_X86_64_ELF += bn/mont5-elf-x86_64.s +ASM_X86_64_ELF += bn/gf2m-elf-x86_64.s +ASM_X86_64_ELF += camellia/cmll-elf-x86_64.s +ASM_X86_64_ELF += md5/md5-elf-x86_64.s +ASM_X86_64_ELF += modes/ghash-elf-x86_64.s +ASM_X86_64_ELF += rc4/rc4-elf-x86_64.s +ASM_X86_64_ELF += rc4/rc4-md5-elf-x86_64.s +ASM_X86_64_ELF += sha/sha1-elf-x86_64.s +ASM_X86_64_ELF += sha/sha256-elf-x86_64.S +ASM_X86_64_ELF += sha/sha512-elf-x86_64.S +ASM_X86_64_ELF += whrlpool/wp-elf-x86_64.s +ASM_X86_64_ELF += cpuid-elf-x86_64.S + +EXTRA_DIST += $(ASM_X86_64_ELF) + +if HOST_ASM_ELF_X86_64 +libcrypto_la_CFLAGS += -DAES_ASM +libcrypto_la_CFLAGS += -DBSAES_ASM +libcrypto_la_CFLAGS += -DVPAES_ASM +libcrypto_la_CFLAGS += -DOPENSSL_IA32_SSE2 +libcrypto_la_CFLAGS += -DOPENSSL_BN_ASM_MONT +libcrypto_la_CFLAGS += -DOPENSSL_BN_ASM_MONT5 +libcrypto_la_CFLAGS += -DOPENSSL_BN_ASM_GF2m +libcrypto_la_CFLAGS += -DMD5_ASM +libcrypto_la_CFLAGS += -DGHASH_ASM +libcrypto_la_CFLAGS += -DRSA_ASM +libcrypto_la_CFLAGS += -DSHA1_ASM +libcrypto_la_CFLAGS += -DSHA256_ASM +libcrypto_la_CFLAGS += -DSHA512_ASM +libcrypto_la_CFLAGS += -DWHIRLPOOL_ASM +libcrypto_la_CFLAGS += -DOPENSSL_CPUID_OBJ +libcrypto_la_SOURCES += $(ASM_X86_64_ELF) +endif diff --git a/crypto/Makefile.am.macosx-x86_64 b/crypto/Makefile.am.macosx-x86_64 new file mode 100644 index 0000000..e361aae --- /dev/null +++ b/crypto/Makefile.am.macosx-x86_64 @@ -0,0 +1,41 @@ + +ASM_X86_64_MACOSX = aes/aes-macosx-x86_64.s +ASM_X86_64_MACOSX += aes/bsaes-macosx-x86_64.s +ASM_X86_64_MACOSX += aes/vpaes-macosx-x86_64.s +ASM_X86_64_MACOSX += aes/aesni-macosx-x86_64.s +ASM_X86_64_MACOSX += aes/aesni-sha1-macosx-x86_64.s +ASM_X86_64_MACOSX += bn/modexp512-macosx-x86_64.s +ASM_X86_64_MACOSX += bn/mont-macosx-x86_64.s +ASM_X86_64_MACOSX += bn/mont5-macosx-x86_64.s +ASM_X86_64_MACOSX += bn/gf2m-macosx-x86_64.s +ASM_X86_64_MACOSX += camellia/cmll-macosx-x86_64.s +ASM_X86_64_MACOSX += md5/md5-macosx-x86_64.s +ASM_X86_64_MACOSX += modes/ghash-macosx-x86_64.s +ASM_X86_64_MACOSX += rc4/rc4-macosx-x86_64.s +ASM_X86_64_MACOSX += rc4/rc4-md5-macosx-x86_64.s +ASM_X86_64_MACOSX += sha/sha1-macosx-x86_64.s +ASM_X86_64_MACOSX += sha/sha256-macosx-x86_64.S +ASM_X86_64_MACOSX += sha/sha512-macosx-x86_64.S +ASM_X86_64_MACOSX += whrlpool/wp-macosx-x86_64.s +ASM_X86_64_MACOSX += cpuid-macosx-x86_64.S + +EXTRA_DIST += $(ASM_X86_64_MACOSX) + +if HOST_ASM_MACOSX_X86_64 +libcrypto_la_CFLAGS += -DAES_ASM +libcrypto_la_CFLAGS += -DBSAES_ASM +libcrypto_la_CFLAGS += -DVPAES_ASM +libcrypto_la_CFLAGS += -DOPENSSL_IA32_SSE2 +libcrypto_la_CFLAGS += -DOPENSSL_BN_ASM_MONT +libcrypto_la_CFLAGS += -DOPENSSL_BN_ASM_MONT5 +libcrypto_la_CFLAGS += -DOPENSSL_BN_ASM_GF2m +libcrypto_la_CFLAGS += -DMD5_ASM +libcrypto_la_CFLAGS += -DGHASH_ASM +libcrypto_la_CFLAGS += -DRSA_ASM +libcrypto_la_CFLAGS += -DSHA1_ASM +libcrypto_la_CFLAGS += -DSHA256_ASM +libcrypto_la_CFLAGS += -DSHA512_ASM +libcrypto_la_CFLAGS += -DWHIRLPOOL_ASM +libcrypto_la_CFLAGS += -DOPENSSL_CPUID_OBJ +libcrypto_la_SOURCES += $(ASM_X86_64_MACOSX) +endif -- cgit v1.2.3-55-g6feb