From 728b7ef23716266719a66aa021f47fdff3ea89d4 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 23 Oct 2019 19:30:48 +0200 Subject: [PATCH] Add libarmcrypto.la --- configure.ac | 15 +++++++++++++++ src/libsodium/Makefile.am | 10 ++++++++-- .../aegis256/arm-crypto/aead_aegis256_armcrypto.c | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 706b2839..a413ce57 100644 --- a/configure.ac +++ b/configure.ac @@ -366,6 +366,20 @@ dnl Checks for headers AS_IF([test "x$EMSCRIPTEN" = "x"], [ + AS_IF([test "$host_cpu" = "aarch64"], [ + oldcflags="$CFLAGS" + AX_CHECK_COMPILE_FLAG([-march=armv8-a+crypto], [CFLAGS="$CFLAGS -march=armv8-a+crypto"]) + AC_MSG_CHECKING(for ARM crypto instructions set) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ vaeseq_u8(vmovq_n_u8(0), vmovq_n_u8(__ARM_FEATURE_CRYPTO)) ]])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_ARMCRYPTO], [1], [ARM crypto extensions are available]) + AX_CHECK_COMPILE_FLAG([-march=armv8-a+crypto], [CFLAGS_ARMCRYPTO="-march=armv8-a+crypto"])], + [AC_MSG_RESULT(no)]) + CFLAGS="$oldcflags" + ]) + oldcflags="$CFLAGS" AX_CHECK_COMPILE_FLAG([-mmmx], [CFLAGS="$CFLAGS -mmmx"]) AC_MSG_CHECKING(for MMX instructions set) @@ -542,6 +556,7 @@ __m512i y = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), ]) +AC_SUBST(CFLAGS_ARMCRYPTO) AC_SUBST(CFLAGS_MMX) AC_SUBST(CFLAGS_SSE2) AC_SUBST(CFLAGS_SSE3) diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 36c2aca2..e0b8343a 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -199,8 +199,8 @@ endif SUBDIRS = \ include -libsodium_la_LIBADD = libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la -noinst_LTLIBRARIES = libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la +libsodium_la_LIBADD = libaesni.la libarmcrypto.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la +noinst_LTLIBRARIES = libaesni.la libarmcrypto.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand_la_LDFLAGS = $(libsodium_la_LDFLAGS) librdrand_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ @@ -216,6 +216,12 @@ libsodium_la_SOURCES += \ randombytes/sysrandom/randombytes_sysrandom.c endif +libarmcrypto_la_LDFLAGS = $(libsodium_la_LDFLAGS) +libarmcrypto_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ + @CFLAGS_ARMCRYPTO@ +libarmcrypto_la_SOURCES = \ + crypto_aead/aegis256/arm-crypto/aead_aegis256_armcrypto.c + libaesni_la_LDFLAGS = $(libsodium_la_LDFLAGS) libaesni_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ @CFLAGS_SSE2@ @CFLAGS_SSSE3@ @CFLAGS_AESNI@ @CFLAGS_PCLMUL@ diff --git a/src/libsodium/crypto_aead/aegis256/arm-crypto/aead_aegis256_armcrypto.c b/src/libsodium/crypto_aead/aegis256/arm-crypto/aead_aegis256_armcrypto.c index 6b491537..8832fadc 100644 --- a/src/libsodium/crypto_aead/aegis256/arm-crypto/aead_aegis256_armcrypto.c +++ b/src/libsodium/crypto_aead/aegis256/arm-crypto/aead_aegis256_armcrypto.c @@ -12,7 +12,7 @@ #include "private/common.h" -#if (defined(__ARM_NEON) || defined(__aarch64__)) && defined(__ARM_FEATURE_CRYPTO) +#ifdef HAVE_ARM_CRYPTO # include static inline void