From ed5f6e103b34b2e7863fc342f27063c09b5ac586 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 6 May 2016 08:08:35 -0400 Subject: [PATCH 1/5] Change fpu to neon for Neon builds --- setenv-android.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setenv-android.sh b/setenv-android.sh index 3d4c351c..f68a7580 100755 --- a/setenv-android.sh +++ b/setenv-android.sh @@ -110,7 +110,7 @@ case "$THE_ARCH" in TOOLNAME_BASE="arm-linux-androideabi" AOSP_ABI="armeabi-v7a" AOSP_ARCH="arch-arm" - AOSP_FLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti" + AOSP_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti" ;; armv8|armv8a|aarch64|arm64|arm64-v8a) TOOLCHAIN_BASE="aarch64-linux-android" From 69f7802b53dfbc7ac9aacbaff02b45d6582aad3d Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 9 May 2016 02:59:16 -0400 Subject: [PATCH 2/5] Add rules for AArch32 and AArch64 detection. Restrict shared object warning to shared object and dylibs --- GNUmakefile | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 43e14098..8ddef45a 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -22,7 +22,8 @@ IS_X86 := $(shell uname -m | $(EGREP) -v "x86_64" | $(EGREP) -i -c "i.86|x86|i86 IS_X32 ?= 0 IS_X86_64 := $(shell uname -m | $(EGREP) -i -c "(_64|d64)") IS_PPC := $(shell uname -m | $(EGREP) -i -c "ppc|power") -IS_AARCH64 := $(shell uname -m | $(EGREP) -i -c "aarch64") +IS_ARM32 := $(shell uname -m | $(EGREP) -i -c "arm") +IS_ARM64 := $(shell uname -m | $(EGREP) -i -c "aarch64") IS_SUN := $(shell uname | $(EGREP) -i -c "SunOS") IS_LINUX := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Linux") @@ -325,9 +326,13 @@ endif # HAS_SOLIB_VERSION # is the second candidate for explicit initialization order. SRCS := cryptlib.cpp cpu.cpp $(filter-out cryptlib.cpp cpu.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(wildcard *.cpp)) -# No need for CPU or RDRAND on non-X86 systems. X32 is represented with X64. +# Need CPU for X86/X64/X32 and ARM +ifeq ($(IS_X86)$(IS_X86_64)$(IS_ARM32)$(IS_ARM64),0000) + SRCS := $(filter-out cpu.cpp, $(SRCS)) +endif +# Need RDRAND for X86/X64/X32 ifeq ($(IS_X86)$(IS_X86_64),00) - SRCS := $(filter-out cpu.cpp rdrand.cpp, $(SRCS)) + SRCS := $(filter-out rdrand.cpp, $(SRCS)) endif ifneq ($(IS_MINGW),0) @@ -522,16 +527,16 @@ ifeq ($(HAS_SOLIB_VERSION),1) endif endif -libcryptopp.a: $(LIBOBJS) | public_service +libcryptopp.a: $(LIBOBJS) | config_warning $(AR) $(ARFLAGS) $@ $(LIBOBJS) $(RANLIB) $@ ifeq ($(HAS_SOLIB_VERSION),1) .PHONY: libcryptopp.so -libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) +libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX) | so_warning endif -libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS) | public_service +libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS) $(CXX) -shared $(SOLIB_FLAGS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(LIBOBJS) $(LDLIBS) ifeq ($(HAS_SOLIB_VERSION),1) -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so @@ -541,7 +546,7 @@ endif libcryptopp.dylib: $(LIBOBJS) $(CXX) -dynamiclib -o $@ $(CXXFLAGS) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS) -cryptest.exe: libcryptopp.a $(TESTOBJS) | public_service +cryptest.exe: libcryptopp.a $(TESTOBJS) | config_warning $(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS) # Makes it faster to test changes @@ -673,8 +678,8 @@ endif UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h) NO_INIT_PRIORITY := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_INIT_PRIORITY" config.h) COMPATIBILITY_562 := $(shell $(EGREP) -c "^[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562" config.h) -.PHONY: public_service -public_service: +.PHONY: config_warning +config_warning: ifneq ($(UNALIGNED_ACCESS),0) $(info WARNING: CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is not defined in config.h.) endif @@ -690,6 +695,9 @@ ifneq ($(UNALIGNED_ACCESS)$(NO_INIT_PRIORITY)$(COMPATIBILITY_562),000) $(info WARNING: See http://cryptopp.com/wiki/config.h for more details.) $(info ) endif + +.PHONY: so_warning +so_warning: ifeq ($(HAS_SOLIB_VERSION),1) $(info WARNING: Only the symlinks to the shared-object library have been updated.) $(info WARNING: If the library is installed in a system directory you will need) From f43b7c95cd719285c8b9fef5872239400e53e2ed Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Tue, 10 May 2016 11:58:55 +0200 Subject: [PATCH 3/5] Check for SSE4 support before using SSE4.1 instruction In a 32-bit Windows program compiled with Visual C++ 2013 Update 5, we sometimes get crashes because of an exception "0xC000001D: Illegal Instruction" on the pextrd (_mm_extract_epi32) instruction. Explicitly check for SSE4 support instead of only AES-NI before using this SSE4.1 instruction. --- rijndael.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rijndael.cpp b/rijndael.cpp index 71fa1b85..46396205 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -217,9 +217,9 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, c word32 *rk = m_key; -#if (CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && (!defined(_MSC_VER) || _MSC_VER >= 1600 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)) +#if (CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE && (!defined(_MSC_VER) || _MSC_VER >= 1600 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)) // MSVC 2008 SP1 generates bad code for _mm_extract_epi32() when compiling for X64 - if (HasAESNI()) + if (HasAESNI() && HasSSE4()) { static const word32 rcLE[] = { 0x01, 0x02, 0x04, 0x08, From 58656e4bac2be9050a65f94cdc450470046524ae Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 15 May 2016 00:03:58 -0400 Subject: [PATCH 4/5] Updated documentation --- misc.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/misc.h b/misc.h index d9f98cad..dfb6e3ba 100644 --- a/misc.h +++ b/misc.h @@ -2077,15 +2077,15 @@ private: //! \tparam T class or type //! \tparam B enumeration indicating endianess //! \tparam A flag indicating alignment -//! \details GetBlock() provides alternate write access to a block of memory. The enumeration B is +//! \details PutBlock() provides alternate write access to a block of memory. The enumeration B is //! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T. //! Repeatedly applying operator() results in advancing in the block of memory. -//! \details An example of reading two word32 values from a block of memory is shown below. w1 -//! will be 0x03020100 and w1 will be 0x07060504. +//! \details An example of writing two word32 values from a block of memory is shown below. After the code +//! executes, the byte buffer will be {0,1,2,3,4,5,6,7}. //!
-//!    word32 w1, w2;
-//!    byte buffer[8] = {0,1,2,3,4,5,6,7};
-//!    GetBlock block(buffer);
+//!    word32 w1=0x03020100, w20x07060504;
+//!    byte buffer[8];
+//!    PutBlock block(NULL, buffer);
 //!    block(w1)(w2);
 //! 
template From be0d838e118c609d0117bd8e8f1c7a84b56a2470 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 15 May 2016 00:04:28 -0400 Subject: [PATCH 5/5] Updated documentation --- misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc.h b/misc.h index dfb6e3ba..e540da0d 100644 --- a/misc.h +++ b/misc.h @@ -2083,7 +2083,7 @@ private: //! \details An example of writing two word32 values from a block of memory is shown below. After the code //! executes, the byte buffer will be {0,1,2,3,4,5,6,7}. //!
-//!    word32 w1=0x03020100, w20x07060504;
+//!    word32 w1=0x03020100, w2=0x07060504;
 //!    byte buffer[8];
 //!    PutBlock block(NULL, buffer);
 //!    block(w1)(w2);