From f43b7c95cd719285c8b9fef5872239400e53e2ed Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Tue, 10 May 2016 11:58:55 +0200 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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);