13 #if (CRYPTOPP_SSE42_AVAILABLE) 14 # include <nmmintrin.h> 17 #if (CRYPTOPP_ARM_ACLE_HEADER) 19 # include <arm_acle.h> 22 #if (CRYPTOPP_ARM_CRC32_AVAILABLE) 26 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 31 #if CRYPTOPP_MSC_VERSION 32 # pragma warning(disable: 4244) 35 #ifndef EXCEPTION_EXECUTE_HANDLER 36 # define EXCEPTION_EXECUTE_HANDLER 1 39 #define CONST_WORD32_CAST(x) ((const word32 *)(void*)(x)) 40 #define CONST_WORD64_CAST(x) ((const word64 *)(void*)(x)) 43 extern const char CRC_SIMD_FNAME[] = __FILE__;
47 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 49 typedef void (*SigHandler)(int);
51 static jmp_buf s_jmpSIGILL;
52 static void SigIllHandler(
int)
54 longjmp(s_jmpSIGILL, 1);
57 #endif // Not CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 59 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8) 63 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) 65 #elif (CRYPTOPP_ARM_CRC32_AVAILABLE) 66 # if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY) 67 volatile bool result =
true;
78 __except (EXCEPTION_EXECUTE_HANDLER)
87 volatile bool result =
true;
89 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
90 if (oldHandler == SIG_ERR)
93 volatile sigset_t oldMask;
94 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
96 signal(SIGILL, oldHandler);
100 if (setjmp(s_jmpSIGILL))
114 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
115 signal(SIGILL, oldHandler);
120 #endif // CRYPTOPP_ARM_CRC32_AVAILABLE 122 #endif // ARM32 or ARM64 124 #if (CRYPTOPP_ARM_CRC32_AVAILABLE) 125 void CRC32_Update_ARMV8(
const byte *s,
size_t n,
word32& c)
127 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
130 for(; n >= 16; s+=16, n-=16)
131 c =
CRC32Wx4(c, CONST_WORD32_CAST(s));
133 for(; n >= 4; s+=4, n-=4)
134 c =
CRC32W(c, *CONST_WORD32_CAST(s));
136 for(; n > 0; s++, n--)
140 void CRC32C_Update_ARMV8(
const byte *s,
size_t n,
word32& c)
142 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
145 for(; n >= 16; s+=16, n-=16)
148 for(; n >= 4; s+=4, n-=4)
149 c =
CRC32CW(c, *CONST_WORD32_CAST(s));
151 for(; n > 0; s++, n--)
156 #if (CRYPTOPP_SSE42_AVAILABLE) 157 void CRC32C_Update_SSE42(
const byte *s,
size_t n,
word32& c)
163 #if CRYPTOPP_BOOL_X64 164 for(; !IsAligned<word64>(s) && n > 0; s++, n--)
165 v = _mm_crc32_u8(v, *s);
167 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
168 v = _mm_crc32_u8(v, *s);
171 #if CRYPTOPP_BOOL_X64 172 for(; n >= 32; s+=32, n-=32)
174 v = _mm_crc32_u64(_mm_crc32_u64(_mm_crc32_u64(_mm_crc32_u64(v,
175 *CONST_WORD64_CAST(s+ 0)), *CONST_WORD64_CAST(s+ 8)),
176 *CONST_WORD64_CAST(s+16)), *CONST_WORD64_CAST(s+24));
180 for(; n >= 16; s+=16, n-=16)
182 v = _mm_crc32_u32(_mm_crc32_u32(_mm_crc32_u32(_mm_crc32_u32(v,
183 *CONST_WORD32_CAST(s+ 0)), *CONST_WORD32_CAST(s+ 4)),
184 *CONST_WORD32_CAST(s+ 8)), *CONST_WORD32_CAST(s+12));
187 for(; n >= 4; s+=4, n-=4)
188 v = _mm_crc32_u32(v, *CONST_WORD32_CAST(s));
190 for(; n > 0; s++, n--)
191 v = _mm_crc32_u8(v, *s);
193 c =
static_cast<word32>(v);
Utility functions for the Crypto++ library.
unsigned int word32
32-bit unsigned datatype
Library configuration file.
uint32_t CRC32W(uint32_t crc, uint32_t val)
CRC32 checksum.
uint32_t CRC32B(uint32_t crc, uint8_t val)
CRC32 checksum.
uint32_t CRC32CWx4(uint32_t crc, const uint32_t vals[4])
CRC32-C checksum.
unsigned char byte
8-bit unsigned datatype
Crypto++ library namespace.
uint32_t CRC32CB(uint32_t crc, uint8_t val)
CRC32-C checksum.
uint32_t CRC32Wx4(uint32_t crc, const uint32_t vals[4])
CRC32 checksum.
uint32_t CRC32CW(uint32_t crc, uint32_t val)
CRC32-C checksum.
Support functions for ARM and vector operations.