diff options
| author | Jeffrey Walton <noloader@gmail.com> | 2017-09-19 21:08:37 -0400 |
|---|---|---|
| committer | Jeffrey Walton <noloader@gmail.com> | 2017-09-19 21:08:37 -0400 |
| commit | 6102333fc3c1c73c8c5b05e7cd568ac681741c9d (patch) | |
| tree | 1a54b40f518230ac1727380ea431b85cf7d87495 /sha-simd.cpp | |
| parent | 6440921723695913cfcfffdf2c59f0cf01e59c89 (diff) | |
| download | cryptopp-git-6102333fc3c1c73c8c5b05e7cd568ac681741c9d.tar.gz | |
Add CRYPTOPP_NO_CPU_FEATURE_PROBES (GH #511)
We determine machine capabilities by performing an os/platform *query* first, like getauxv(). If the *query* fails, we move onto a cpu *probe*. The cpu *probe* tries to exeute an instruction and then catches a SIGILL on Linux or the exception EXCEPTION_ILLEGAL_INSTRUCTION on Windows. Some OSes fail to hangle a SIGILL gracefully, like Apple OSes. Apple machines corrupt memory and variables around the probe.
Diffstat (limited to 'sha-simd.cpp')
| -rw-r--r-- | sha-simd.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/sha-simd.cpp b/sha-simd.cpp index 4cf144c8..0dfd733a 100644 --- a/sha-simd.cpp +++ b/sha-simd.cpp @@ -61,7 +61,9 @@ extern "C" { #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
bool CPU_ProbeSHA1()
{
-#if (CRYPTOPP_ARM_SHA_AVAILABLE)
+#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
+ return false;
+#elif (CRYPTOPP_ARM_SHA_AVAILABLE)
# if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
volatile bool result = true;
__try
@@ -83,11 +85,6 @@ bool CPU_ProbeSHA1() return result;
# else
-# if defined(__APPLE__)
- // No SIGILL probes on Apple platforms.
- return false;
-# endif
-
// longjmp and clobber warnings. Volatile is required.
// http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
volatile bool result = true;
@@ -126,7 +123,9 @@ bool CPU_ProbeSHA1() bool CPU_ProbeSHA2()
{
-#if (CRYPTOPP_ARM_SHA_AVAILABLE)
+#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
+ return false;
+#elif (CRYPTOPP_ARM_SHA_AVAILABLE)
# if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
volatile bool result = true;
__try
@@ -147,11 +146,6 @@ bool CPU_ProbeSHA2() return result;
#else
-# if defined(__APPLE__)
- // No SIGILL probes on Apple platforms.
- return false;
-# endif
-
// longjmp and clobber warnings. Volatile is required.
// http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
volatile bool result = true;
|
