VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/Crypto')
-rw-r--r--src/Crypto/Whirlpool.c9
-rw-r--r--src/Crypto/config.h16
-rw-r--r--src/Crypto/cpu.h53
3 files changed, 45 insertions, 33 deletions
diff --git a/src/Crypto/Whirlpool.c b/src/Crypto/Whirlpool.c
index 86b3ebf6..308f4812 100644
--- a/src/Crypto/Whirlpool.c
+++ b/src/Crypto/Whirlpool.c
@@ -80,6 +80,15 @@
#include "misc.h"
#include "Whirlpool.h"
+// "Inline assembly operands don't work with .intel_syntax",
+// http://llvm.org/bugs/show_bug.cgi?id=24232
+#if defined(CRYPTOPP_DISABLE_INTEL_ASM)
+# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+# undef CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE
+# define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
+# define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
+#endif
+
/*
* The number of rounds of the internal dedicated block cipher.
*/
diff --git a/src/Crypto/config.h b/src/Crypto/config.h
index 792ac678..03b1ecb4 100644
--- a/src/Crypto/config.h
+++ b/src/Crypto/config.h
@@ -9,6 +9,12 @@
#define VC_INLINE static inline
#endif
+// Clang pretends to be VC++, too.
+// See http://github.com/weidai11/cryptopp/issues/147
+#if defined(_MSC_VER) && defined(__clang__)
+# error: "Unsupported configuration"
+#endif
+
#ifdef __GNUC__
#define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
@@ -16,15 +22,17 @@
// 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_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+ #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 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)
-#define CRYPTOPP_DISABLE_INTEL_ASM 1
+#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
#ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
diff --git a/src/Crypto/cpu.h b/src/Crypto/cpu.h
index ab372cf8..05ce9d8f 100644
--- a/src/Crypto/cpu.h
+++ b/src/Crypto/cpu.h
@@ -4,6 +4,27 @@
#include "Common/Tcdefs.h"
#include "config.h"
+// Applies to both X86/X32/X64 and ARM32/ARM64
+#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;"
+ #define ATT_PREFIX ".att_syntax;"
+ #define ATT_NOPREFIX ".att_syntax;"
+#elif defined(__GNUC__)
+ #define NEW_LINE
+ #define INTEL_PREFIX ".intel_syntax prefix;"
+ #define INTEL_NOPREFIX ".intel_syntax noprefix;"
+ #define ATT_PREFIX ".att_syntax prefix;"
+ #define ATT_NOPREFIX ".att_syntax noprefix;"
+#else
+ #define NEW_LINE
+ #define INTEL_PREFIX
+ #define INTEL_NOPREFIX
+ #define ATT_PREFIX
+ #define ATT_NOPREFIX
+#endif
+
#ifdef CRYPTOPP_GENERATE_X64_MASM
#define CRYPTOPP_X86_ASM_AVAILABLE
@@ -218,6 +239,8 @@ extern int g_hasMMX;
#endif
+#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
+
#ifdef CRYPTOPP_GENERATE_X64_MASM
#define AS1(x) x*newline*
#define AS2(x, y) x, y*newline*
@@ -241,20 +264,6 @@ extern int g_hasMMX;
#else
#define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
- #if defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)
- #define NEW_LINE "\n"
- #define INTEL_PREFIX ".intel_syntax;"
- #define INTEL_NOPREFIX ".intel_syntax;"
- #define ATT_PREFIX ".att_syntax;"
- #define ATT_NOPREFIX ".att_syntax;"
- #else
- #define NEW_LINE
- #define INTEL_PREFIX ".intel_syntax prefix;"
- #define INTEL_NOPREFIX ".intel_syntax noprefix;"
- #define ATT_PREFIX ".att_syntax prefix;"
- #define ATT_NOPREFIX ".att_syntax noprefix;"
- #endif
-
// define these in two steps to allow arguments to be expanded
#define GNU_AS1(x) #x ";" NEW_LINE
#define GNU_AS2(x, y) #x ", " #y ";" NEW_LINE
@@ -275,21 +284,6 @@ extern int g_hasMMX;
#define IF0(y)
#define IF1(y) y
-// Should be confined to GCC, but its used to help manage Clang 3.4 compiler error.
-// Also see LLVM Bug 24232, http://llvm.org/bugs/show_bug.cgi?id=24232 .
-#ifndef INTEL_PREFIX
-#define INTEL_PREFIX
-#endif
-#ifndef INTEL_NOPREFIX
-#define INTEL_NOPREFIX
-#endif
-#ifndef ATT_PREFIX
-#define ATT_PREFIX
-#endif
-#ifndef ATT_NOPREFIX
-#define ATT_NOPREFIX
-#endif
-
#ifdef CRYPTOPP_GENERATE_X64_MASM
#define ASM_MOD(x, y) ((x) MOD (y))
#define XMMWORD_PTR XMMWORD PTR
@@ -420,6 +414,7 @@ extern int g_hasMMX;
ASL(labelPrefix##9)\
AS2( add outputPtr, increment*16)
+#endif // X86/X32/X64
#if defined(TC_WINDOWS_DRIVER) || defined (_UEFI)
#ifdef __cplusplus