summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGNUmakefile11
-rw-r--r--blake2.cpp2
-rw-r--r--config.h16
-rw-r--r--config.recommend18
-rw-r--r--cpu.cpp2
-rw-r--r--cpu.h75
-rwxr-xr-xcryptest.sh68
-rw-r--r--default.h12
-rw-r--r--eccrypto.h24
-rw-r--r--gcm.cpp14
-rw-r--r--misc.h10
-rw-r--r--panama.h4
-rw-r--r--rdrand.cpp4
-rw-r--r--rijndael.h2
-rw-r--r--sha.h2
15 files changed, 205 insertions, 59 deletions
diff --git a/GNUmakefile b/GNUmakefile
index f1db629b..e45f7b3a 100755
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -30,9 +30,9 @@ IS_DARWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Darwin")
IS_NETBSD := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "NetBSD")
SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun")
-GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "(gcc|g\+\+)")
+GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -v "clang" | $(EGREP) -i -c "(gcc|g\+\+)")
CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
-INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
+INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(icc\)")
MACPORTS_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "macports")
# Sun Studio 12.0 (0x0510) and 12.3 (0x0512)
@@ -179,6 +179,9 @@ ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11)
ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-Wa,-q)
CXXFLAGS += -Wa,-q
endif
+ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
+CXXFLAGS += -DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER=1
+endif
endif
# Allow use of "/" operator for GNU Assembler.
@@ -300,10 +303,10 @@ endif # Asan
# LD gold linker testing. Triggered by 'LD=ld.gold'.
ifeq ($(findstring ld.gold,$(LD)),ld.gold)
-ifeq ($(findstring -Wl,-fuse-ld=gold,$(LDFLAGS)),)
+ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf")
ifneq ($(ELF_FORMAT),0)
-LDFLAGS += -Wl,-fuse-ld=gold
+LDFLAGS += -fuse-ld=gold
endif # ELF/ELF64
endif # CXXFLAGS
endif # Gold
diff --git a/blake2.cpp b/blake2.cpp
index 77eef8ce..0cb858b1 100644
--- a/blake2.cpp
+++ b/blake2.cpp
@@ -35,7 +35,7 @@ NAMESPACE_BEGIN(CryptoPP)
// Apple Clang 6.0/Clang 3.5 does not have SSSE3 intrinsics
// http://llvm.org/bugs/show_bug.cgi?id=20213
-#if (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 60000)) || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION <= 30500))
+#if (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 60000)) || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION <= 30500))
# undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
#endif
diff --git a/config.h b/config.h
index 7ac17fda..9a40f2ba 100644
--- a/config.h
+++ b/config.h
@@ -63,7 +63,9 @@
// Define this to choose the FIPS 202 version of SHA3, and not the original version of SHA3. NIST selected Keccak as SHA3
// in January 2013. SHA3 was finalized in FIPS 202 in August 2015, and it was a modified version of the original selection.
// If CRYPTOPP_USE_FIPS_202_SHA3 is defined, then sha3_fips_202.txt test vectors will be used instead of sha3.txt.
-// #define CRYPTOPP_USE_FIPS_202_SHA3
+// #ifndef CRYPTOPP_USE_FIPS_202_SHA3
+// # define CRYPTOPP_USE_FIPS_202_SHA3
+// #endif
// ***************** Less Important Settings ***************
@@ -236,9 +238,11 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
// Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
#if defined(__clang__ ) && !defined(__apple_build_version__)
- #define CRYPTOPP_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
#elif defined(__clang__ ) && defined(__apple_build_version__)
#define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
#endif
#ifdef _MSC_VER
@@ -246,13 +250,13 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
#endif
// Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
-#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
+#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
#define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
#endif
// Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
// TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
-#if (defined(CRYPTOPP_CLANG_VERSION) && CRYPTOPP_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000)
+#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
#define CRYPTOPP_DISABLE_INTEL_ASM 1
#endif
@@ -726,7 +730,7 @@ NAMESPACE_END
// ************** Deprecated ***************
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
# define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg)));
#elif (CRYPTOPP_GCC_VERSION)
# define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated));
@@ -779,7 +783,7 @@ NAMESPACE_END
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1200)
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
-#elif (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
+#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (CRYPTOPP_GCC_VERSION >= 40400)
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
diff --git a/config.recommend b/config.recommend
index c9064240..713a6780 100644
--- a/config.recommend
+++ b/config.recommend
@@ -63,7 +63,9 @@
// Define this to choose the FIPS 202 version of SHA3, and not the original version of SHA3. NIST selected Keccak as SHA3
// in January 2013. SHA3 was finalized in FIPS 202 in August 2015, and it was a modified version of the original selection.
// If CRYPTOPP_USE_FIPS_202_SHA3 is defined, then sha3_fips_202.txt test vectors will be used instead of sha3.txt.
-#define CRYPTOPP_USE_FIPS_202_SHA3
+#ifndef CRYPTOPP_USE_FIPS_202_SHA3
+# define CRYPTOPP_USE_FIPS_202_SHA3
+#endif
// ***************** Less Important Settings ***************
@@ -236,9 +238,11 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
// Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7
#if defined(__clang__ ) && !defined(__apple_build_version__)
- #define CRYPTOPP_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
#elif defined(__clang__ ) && defined(__apple_build_version__)
#define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1
#endif
#ifdef _MSC_VER
@@ -246,13 +250,13 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
#endif
// Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
-#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
+#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
#define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
#endif
// Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
// TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes.
-#if (defined(CRYPTOPP_CLANG_VERSION) && CRYPTOPP_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000)
+#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
#define CRYPTOPP_DISABLE_INTEL_ASM 1
#endif
@@ -565,6 +569,8 @@ NAMESPACE_END
#define CRYPTOPP_BOOL_ARM32 0
#endif
+// Microsoft plans to support ARM-64, but its not clear how to detect it.
+// TODO: Add MSC_VER and ARM-64 platform define when available
#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
#define CRYPTOPP_BOOL_ARM64 1
#else
@@ -724,7 +730,7 @@ NAMESPACE_END
// ************** Deprecated ***************
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
# define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg)));
#elif (CRYPTOPP_GCC_VERSION)
# define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated));
@@ -777,7 +783,7 @@ NAMESPACE_END
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1200)
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
-#elif (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
+#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (CRYPTOPP_GCC_VERSION >= 40400)
# define CRYPTOPP_CXX11_SYNCHRONIZATION 1
diff --git a/cpu.cpp b/cpu.cpp
index 7c39cccd..b13dd255 100644
--- a/cpu.cpp
+++ b/cpu.cpp
@@ -27,7 +27,7 @@ NAMESPACE_BEGIN(CryptoPP)
#ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
// MacPorts/GCC does not provide constructor(priority). Apple/GCC and Fink/GCC do provide it.
-#define HAVE_GCC_CONSTRUCTOR1 (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && ((CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 300)) && !(MACPORTS_GCC_COMPILER > 0))
+#define HAVE_GCC_CONSTRUCTOR1 (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && ((CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 300)) && !(MACPORTS_GCC_COMPILER > 0))
#define HAVE_GCC_CONSTRUCTOR0 (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && !(MACPORTS_GCC_COMPILER > 0))
extern "C" {
diff --git a/cpu.h b/cpu.h
index 890f53db..b1414a91 100644
--- a/cpu.h
+++ b/cpu.h
@@ -2,9 +2,7 @@
//! \file cpu.h
//! \brief Functions for CPU features and intrinsics
-//! \details At the moment, the functions are used heavily in X86/X32/X64 code paths
-// for SSE, SSE2 and SSE4. The funtions are also used on occassion for AArch32
-//! and AArch64 code paths for NEON.
+//! \details The functions are used in X86/X32/X64 and NEON code paths
#ifndef CRYPTOPP_CPU_H
#define CRYPTOPP_CPU_H
@@ -52,7 +50,7 @@
#endif
// PUSHFB needs Clang 3.3 and Apple Clang 5.0.
-#if !defined(__GNUC__) || defined(__SSSE3__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
+#if !defined(__GNUC__) || defined(__SSSE3__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
#include <tmmintrin.h>
#else
NAMESPACE_BEGIN(CryptoPP)
@@ -66,7 +64,7 @@ NAMESPACE_END
#endif // tmmintrin.h
// PEXTRD needs Clang 3.3 and Apple Clang 5.0.
-#if !defined(__GNUC__) || defined(__SSE4_1__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
+#if !defined(__GNUC__) || defined(__SSE4_1__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
#include <smmintrin.h>
#else
NAMESPACE_BEGIN(CryptoPP)
@@ -87,7 +85,7 @@ NAMESPACE_END
#endif // smmintrin.h
// AES needs Clang 2.8 and Apple Clang 4.6. PCLMUL needs Clang 3.4 and Apple Clang 6.0
-#if !defined(__GNUC__) || (defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || (CRYPTOPP_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 60000)
+#if !defined(__GNUC__) || (defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 60000)
#include <wmmintrin.h>
#else
NAMESPACE_BEGIN(CryptoPP)
@@ -141,11 +139,13 @@ NAMESPACE_END
NAMESPACE_BEGIN(CryptoPP)
-#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
+#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_DOXYGEN_PROCESSING
#define CRYPTOPP_CPUID_AVAILABLE
-// these should not be used directly
+// Hide from Doxygen
+#ifndef CRYPTOPP_DOXYGEN_PROCESSING
+// These should not be used directly
extern CRYPTOPP_DLL bool g_x86DetectionDone;
extern CRYPTOPP_DLL bool g_hasMMX;
extern CRYPTOPP_DLL bool g_hasISSE;
@@ -166,7 +166,12 @@ extern CRYPTOPP_DLL word32 g_cacheLineSize;
CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features();
CRYPTOPP_DLL bool CRYPTOPP_API CpuId(word32 input, word32 output[4]);
+#endif // CRYPTOPP_DOXYGEN_PROCESSING
+//! \brief Determines MMX availability
+//! \returns true if MMX is determined to be available, false otherwise
+//! \details MMX, SSE and SSE2 are core processor features for x86_64, and
+//! the function always returns true for the platform.
inline bool HasMMX()
{
#if CRYPTOPP_BOOL_X64
@@ -178,6 +183,10 @@ inline bool HasMMX()
#endif
}
+//! \brief Determines SSE availability
+//! \returns true if SSE is determined to be available, false otherwise
+//! \details MMX, SSE and SSE2 are core processor features for x86_64, and
+//! the function always returns true for the platform.
inline bool HasISSE()
{
#if CRYPTOPP_BOOL_X64
@@ -189,6 +198,10 @@ inline bool HasISSE()
#endif
}
+//! \brief Determines SSE2 availability
+//! \returns true if SSE2 is determined to be available, false otherwise
+//! \details MMX, SSE and SSE2 are core processor features for x86_64, and
+//! the function always returns true for the platform.
inline bool HasSSE2()
{
#if CRYPTOPP_BOOL_X64
@@ -200,6 +213,10 @@ inline bool HasSSE2()
#endif
}
+//! \brief Determines SSSE3 availability
+//! \returns true if SSSE3 is determined to be available, false otherwise
+//! \details HasSSSE3() is a runtime check performed using CPUID
+//! \note Some Clang compilers incorrectly omit SSSE3 even though its native to the processor.
inline bool HasSSSE3()
{
if (!g_x86DetectionDone)
@@ -207,6 +224,9 @@ inline bool HasSSSE3()
return g_hasSSSE3;
}
+//! \brief Determines SSE4 availability
+//! \returns true if SSE4.1 and SSE4.2 are determined to be available, false otherwise
+//! \details HasSSE4() is a runtime check performed using CPUID which requires both SSE4.1 and SSE4.2
inline bool HasSSE4()
{
if (!g_x86DetectionDone)
@@ -214,6 +234,9 @@ inline bool HasSSE4()
return g_hasSSE4;
}
+//! \brief Determines AES-NI availability
+//! \returns true if AES-NI is determined to be available, false otherwise
+//! \details HasAESNI() is a runtime check performed using CPUID
inline bool HasAESNI()
{
if (!g_x86DetectionDone)
@@ -221,6 +244,9 @@ inline bool HasAESNI()
return g_hasAESNI;
}
+//! \brief Determines Carryless Multiply availability
+//! \returns true if pclmulqdq is determined to be available, false otherwise
+//! \details HasCLMUL() is a runtime check performed using CPUID
inline bool HasCLMUL()
{
if (!g_x86DetectionDone)
@@ -228,6 +254,9 @@ inline bool HasCLMUL()
return g_hasCLMUL;
}
+//! \brief Determines if the CPU is an Intel P4
+//! \returns true if the CPU is a P4, false otherwise
+//! \details IsP4() is a runtime check performed using CPUID
inline bool IsP4()
{
if (!g_x86DetectionDone)
@@ -235,6 +264,9 @@ inline bool IsP4()
return g_isP4;
}
+//! \brief Determines RDRAND availability
+//! \returns true if RDRAND is determined to be available, false otherwise
+//! \details HasRDRAND() is a runtime check performed using CPUID
inline bool HasRDRAND()
{
if (!g_x86DetectionDone)
@@ -242,6 +274,9 @@ inline bool HasRDRAND()
return g_hasRDRAND;
}
+//! \brief Determines RDSEED availability
+//! \returns true if RDSEED is determined to be available, false otherwise
+//! \details HasRDSEED() is a runtime check performed using CPUID
inline bool HasRDSEED()
{
if (!g_x86DetectionDone)
@@ -249,6 +284,9 @@ inline bool HasRDSEED()
return g_hasRDSEED;
}
+//! \brief Determines Padlock RNG availability
+//! \returns true if VIA Padlock RNG is determined to be available, false otherwise
+//! \details HasPadlockRNG() is a runtime check performed using CPUID
inline bool HasPadlockRNG()
{
if (!g_x86DetectionDone)
@@ -256,6 +294,9 @@ inline bool HasPadlockRNG()
return g_hasPadlockRNG;
}
+//! \brief Determines Padlock ACE availability
+//! \returns true if VIA Padlock ACE is determined to be available, false otherwise
+//! \details HasPadlockACE() is a runtime check performed using CPUID
inline bool HasPadlockACE()
{
if (!g_x86DetectionDone)
@@ -263,6 +304,9 @@ inline bool HasPadlockACE()
return g_hasPadlockACE;
}
+//! \brief Determines Padlock ACE2 availability
+//! \returns true if VIA Padlock ACE2 is determined to be available, false otherwise
+//! \details HasPadlockACE2() is a runtime check performed using CPUID
inline bool HasPadlockACE2()
{
if (!g_x86DetectionDone)
@@ -270,6 +314,9 @@ inline bool HasPadlockACE2()
return g_hasPadlockACE2;
}
+//! \brief Determines Padlock PHE availability
+//! \returns true if VIA Padlock PHE is determined to be available, false otherwise
+//! \details HasPadlockPHE() is a runtime check performed using CPUID
inline bool HasPadlockPHE()
{
if (!g_x86DetectionDone)
@@ -277,6 +324,9 @@ inline bool HasPadlockPHE()
return g_hasPadlockPHE;
}
+//! \brief Determines Padlock PMM availability
+//! \returns true if VIA Padlock PMM is determined to be available, false otherwise
+//! \details HasPadlockPMM() is a runtime check performed using CPUID
inline bool HasPadlockPMM()
{
if (!g_x86DetectionDone)
@@ -284,6 +334,13 @@ inline bool HasPadlockPMM()
return g_hasPadlockPMM;
}
+//! \brief Provides the cache line size
+//! \returns lower bound on the size of a cache line in bytes, if available
+//! \details GetCacheLineSize() returns the lower bound on the size of a cache line, if it
+//! is available. If the value is not available at runtime, then 32 is returned for a 32-bit
+//! processor and 64 is returned for a 64-bit processor.
+//! \details x86/x32/x64 uses CPUID to determine the value and its usually accurate. The ARM
+//! processor equivalent is a privileged instruction, so a compile time value is returned.
inline int GetCacheLineSize()
{
if (!g_x86DetectionDone)
@@ -415,7 +472,7 @@ inline int GetCacheLineSize()
#else
#define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
-#if defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)
+#if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
#define NEW_LINE "\n"
#define INTEL_PREFIX ".intel_syntax;"
#define INTEL_NOPREFIX ".intel_syntax;"
diff --git a/cryptest.sh b/cryptest.sh
index c28f80c7..d177cd1e 100755
--- a/cryptest.sh
+++ b/cryptest.sh
@@ -227,6 +227,14 @@ if [[ (-z "$HAVE_CXX03") ]]; then
fi
fi
+if [[ (-z "$HAVE_GNU03") ]]; then
+ HAVE_GNU03=0
+ "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++03 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
+ if [[ "$?" -eq "0" ]]; then
+ HAVE_GNU03=1
+ fi
+fi
+
HAVE_O3=0
OPT_O3=
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
@@ -499,6 +507,7 @@ fi
# C++03, C++11, C++14 and C++17
echo | tee -a "$TEST_RESULTS"
echo "HAVE_CXX03: $HAVE_CXX03" | tee -a "$TEST_RESULTS"
+echo "HAVE_GNU03: $HAVE_GNU03" | tee -a "$TEST_RESULTS"
echo "HAVE_CXX11: $HAVE_CXX11" | tee -a "$TEST_RESULTS"
echo "HAVE_GNU11: $HAVE_GNU11" | tee -a "$TEST_RESULTS"
if [[ ("$HAVE_CXX14" -ne "0" || "$HAVE_CXX17" -ne "0" || "$HAVE_GNU14" -ne "0" || "$HAVE_GNU17" -ne "0") ]]; then
@@ -962,6 +971,65 @@ if [[ "$HAVE_CXX03" -ne "0" ]]; then
fi
############################################
+# gnu++03 debug and release build
+if [[ "$HAVE_GNU03" -ne "0" ]]; then
+
+ ############################################
+ # Debug build
+ echo
+ echo "************************************" | tee -a "$TEST_RESULTS"
+ echo "Testing: debug, gnu++03" | tee -a "$TEST_RESULTS"
+ echo
+
+ unset CXXFLAGS
+ "$MAKE" clean > /dev/null 2>&1
+ rm -f adhoc.cpp > /dev/null 2>&1
+
+ export CXXFLAGS="$DEBUG_CXXFLAGS -std=gnu++03 ${RETAINED_CXXFLAGS[@]}"
+ "$MAKE" "${MAKEARGS[@]}" CXX="$CXX" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
+
+ if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
+ echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS"
+ else
+ ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
+ echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS"
+ fi
+ ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+ if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
+ echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS"
+ fi
+ fi
+
+ ############################################
+ # Release build
+ echo
+ echo "************************************" | tee -a "$TEST_RESULTS"
+ echo "Testing: release, gnu++03" | tee -a "$TEST_RESULTS"
+ echo
+
+ unset CXXFLAGS
+ "$MAKE" clean > /dev/null 2>&1
+ rm -f adhoc.cpp > /dev/null 2>&1
+
+ export CXXFLAGS="$RELEASE_CXXFLAGS -std=gnu++03 ${RETAINED_CXXFLAGS[@]}"
+ "$MAKE" "${MAKEARGS[@]}" CXX="$CXX" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
+
+ if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
+ echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS"
+ else
+ ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
+ echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS"
+ fi
+ ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+ if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
+ echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS"
+ fi
+ fi
+fi
+
+############################################
# c++11 debug and release build
if [[ "$HAVE_CXX11" -ne "0" ]]; then
diff --git a/default.h b/default.h
index 00ec6647..6b30f2e4 100644
--- a/default.h
+++ b/default.h
@@ -48,7 +48,7 @@ private:
SecByteBlock m_passphrase;
CBC_Mode<DefaultBlockCipher>::Encryption m_cipher;
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
} __attribute__((deprecated ("DefaultEncryptor will be changing in the near future because the algorithms are no longer secure")));
#elif (CRYPTOPP_GCC_VERSION)
} __attribute__((deprecated));
@@ -68,7 +68,7 @@ public:
//! \param attachment a BufferedTransformation to attach to this object
//! \param throwException a flag specifiying whether an Exception should be thrown on error
DefaultDecryptor(const char *passphrase, BufferedTransformation *attachment = NULL, bool throwException=true);
-
+
//! \brief Constructs a DefaultDecryptor
//! \param passphrase a byte string password
//! \param passphraseLength the length of the byte string password
@@ -79,7 +79,7 @@ public:
class Err : public Exception
{
public:
- Err(const std::string &s)
+ Err(const std::string &s)
: Exception(DATA_INTEGRITY_CHECK_FAILED, s) {}
};
class KeyBadErr : public Err {public: KeyBadErr() : Err("DefaultDecryptor: cannot decrypt message with this passphrase") {}};
@@ -101,7 +101,7 @@ private:
member_ptr<FilterWithBufferedInput> m_decryptor;
bool m_throwException;
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
} __attribute__((deprecated ("DefaultDecryptor will be changing in the near future because the algorithms are no longer secure")));
#elif (CRYPTOPP_GCC_VERSION)
} __attribute__((deprecated));
@@ -139,7 +139,7 @@ protected:
private:
member_ptr<DefaultMAC> m_mac;
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
} __attribute__((deprecated ("DefaultEncryptorWithMAC will be changing in the near future because the algorithms are no longer secure")));
#elif (CRYPTOPP_GCC_VERSION)
} __attribute__((deprecated));
@@ -188,7 +188,7 @@ private:
HashVerifier *m_hashVerifier;
bool m_throwException;
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
} __attribute__((deprecated ("DefaultDecryptorWithMAC will be changing in the near future because the algorithms are no longer secure")));
#elif (CRYPTOPP_GCC_VERSION)
} __attribute__((deprecated));
diff --git a/eccrypto.h b/eccrypto.h
index 96b2817b..c90e06c4 100644
--- a/eccrypto.h
+++ b/eccrypto.h
@@ -132,7 +132,7 @@ public:
const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();}
void LoadRecommendedParameters(const OID &oid) {Initialize(oid);}
#endif
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_GroupParameters_EC() {}
#endif
@@ -162,7 +162,7 @@ public:
// X509PublicKey
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodePublicKey(BufferedTransformation &bt) const;
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_PublicKey_EC() {}
#endif
@@ -187,7 +187,7 @@ public:
// PKCS8PrivateKey
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodePrivateKey(BufferedTransformation &bt) const;
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_PrivateKey_EC() {}
#endif
@@ -198,7 +198,7 @@ template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<E
struct ECDH
{
typedef DH_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION> Domain;
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~ECDH() {}
#endif
@@ -209,7 +209,7 @@ template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<E
struct ECMQV
{
typedef MQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION> Domain;
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~ECMQV() {}
#endif
@@ -259,7 +259,7 @@ struct DL_Keys_EC
{
typedef DL_PublicKey_EC<EC> PublicKey;
typedef DL_PrivateKey_EC<EC> PrivateKey;
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_Keys_EC() {}
#endif
@@ -274,7 +274,7 @@ struct DL_Keys_ECDSA
{
typedef DL_PublicKey_EC<EC> PublicKey;
typedef DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<EC>, ECDSA<EC, SHA256> > PrivateKey;
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_Keys_ECDSA() {}
#endif
@@ -286,7 +286,7 @@ class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA<typename EC::Point>
{
public:
static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";}
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_Algorithm_ECDSA() {}
#endif
@@ -298,7 +298,7 @@ class DL_Algorithm_ECNR : public DL_Algorithm_NR<typename EC::Point>
{
public:
static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";}
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~DL_Algorithm_ECNR() {}
#endif
@@ -336,12 +336,12 @@ struct ECIES
ECIES<EC> >
{
static std::string CRYPTOPP_API StaticAlgorithmName() {return "ECIES";} // TODO: fix this after name is standardized
-
+
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~ECIES() {}
#endif
-
-#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800)
+
+#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800)
} __attribute__((deprecated ("ECIES will be changing in the near future due to (1) an implementation bug and (2) an interop issue")));
#elif (CRYPTOPP_GCC_VERSION)
} __attribute__((deprecated));
diff --git a/gcm.cpp b/gcm.cpp
index fd82bddb..fd6731f0 100644
--- a/gcm.cpp
+++ b/gcm.cpp
@@ -13,7 +13,7 @@
#ifndef CRYPTOPP_GENERATE_X64_MASM
// Clang 3.3 integrated assembler crash on Linux
-#if defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400)
+#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
# undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE
@@ -703,9 +703,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( pxor xmm5, xmm2 )
AS2( psrldq xmm0, 15 )
-#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
+#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
AS2( movd edi, xmm0 )
-#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
+#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
AS2( mov WORD_REG(di), xmm0 )
#else // GNU Assembler
AS2( movd WORD_REG(di), xmm0 )
@@ -718,9 +718,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( pxor xmm4, xmm5 )
AS2( psrldq xmm1, 15 )
-#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
+#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
AS2( movd edi, xmm1 )
-#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
+#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
AS2( mov WORD_REG(di), xmm1 )
#else
AS2( movd WORD_REG(di), xmm1 )
@@ -729,9 +729,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( shl eax, 8 )
AS2( psrldq xmm0, 15 )
-#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
+#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
AS2( movd edi, xmm0 )
-#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
+#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
AS2( mov WORD_REG(di), xmm0 )
#else
AS2( movd WORD_REG(di), xmm0 )
diff --git a/misc.h b/misc.h
index a888deef..e3980441 100644
--- a/misc.h
+++ b/misc.h
@@ -63,10 +63,18 @@
#if defined(__GNUC__) && defined(__BMI__)
# include <immintrin.h>
# if defined(__clang__)
+#ifndef _tzcnt_u32
# define _tzcnt_u32(x) __tzcnt_u32(x)
+#endif
+#ifndef _tzcnt_u64
# define _tzcnt_u64(x) __tzcnt_u64(x)
+#endif
+#ifndef _blsr_u32
# define _blsr_u32(x) __blsr_u32(x)
+#endif
+#ifndef _blsr_u64
# define _blsr_u64(x) __blsr_u64(x)
+#endif
# endif
#endif
@@ -463,7 +471,7 @@ template <class T> inline const T& STDMAX(const T& a, const T& b)
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
-# if (CRYPTOPP_CLANG_VERSION >= 20800) || (CRYPTOPP_APPLE_CLANG_VERSION >= 30000)
+# if (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) || (CRYPTOPP_APPLE_CLANG_VERSION >= 30000)
# pragma GCC diagnostic ignored "-Wtautological-compare"
# elif (CRYPTOPP_GCC_VERSION >= 40300)
# pragma GCC diagnostic ignored "-Wtype-limits"
diff --git a/panama.h b/panama.h
index b7db323a..e7f20c95 100644
--- a/panama.h
+++ b/panama.h
@@ -11,7 +11,7 @@
#include "secblock.h"
// Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler error with .intel_syntax
-#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30500))
+#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30500))
# define CRYPTOPP_DISABLE_PANAMA_ASM
#endif
@@ -128,7 +128,7 @@ struct PanamaCipherInfo : public FixedKeyLength<32, SimpleKeyingInterface::UNIQU
//! _
template <class B>
-class PanamaCipherPolicy : public AdditiveCipherConcretePolicy<word32, 8>,
+class PanamaCipherPolicy : public AdditiveCipherConcretePolicy<word32, 8>,
public PanamaCipherInfo<B>,
protected Panama<B>
{
diff --git a/rdrand.cpp b/rdrand.cpp
index 6149315e..4edb1bd8 100644
--- a/rdrand.cpp
+++ b/rdrand.cpp
@@ -67,8 +67,8 @@
#endif
#if defined(CRYPTOPP_CPUID_AVAILABLE)
-# define MSC_INTRIN_COMPILER ((CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210))
-# define GCC_INTRIN_COMPILER ((CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210))
+# define MSC_INTRIN_COMPILER ((CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210))
+# define GCC_INTRIN_COMPILER ((CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210))
#else
# define MSC_INTRIN_COMPILER 0
# define GCC_INTRIN_COMPILER 0
diff --git a/rijndael.h b/rijndael.h
index ed856d94..50fdf1eb 100644
--- a/rijndael.h
+++ b/rijndael.h
@@ -12,7 +12,7 @@
#include "secblock.h"
// Clang 3.3 integrated assembler crash on Linux
-#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400))
+#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400))
# define CRYPTOPP_DISABLE_RIJNDAEL_ASM
#endif
diff --git a/sha.h b/sha.h
index 544e8056..c70d9d1f 100644
--- a/sha.h
+++ b/sha.h
@@ -11,7 +11,7 @@
#include "iterhash.h"
// Clang 3.3 integrated assembler crash on Linux
-#if defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400)
+#if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)
# define CRYPTOPP_DISABLE_SHA_ASM
#endif