Crypto++
8.8
Free C++ class library of cryptographic schemes
config_asm.h
Go to the documentation of this file.
1
// config_asm.h - written and placed in public domain by Jeffrey Walton
2
// the bits that make up this source file are from the
3
// library's monolithic config.h.
4
5
/// \file config_asm.h
6
/// \brief Library configuration file
7
/// \details <tt>config_asm.h</tt> provides defines for instruction set
8
/// architectures
9
/// and inline assembly.
10
/// \details <tt>config.h</tt> was split into components in May 2019 to better
11
/// integrate with Autoconf and its feature tests. The splitting occurred so
12
/// users could continue to include <tt>config.h</tt> while allowing Autoconf
13
/// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
14
/// its feature tests.
15
/// \note You should include <tt>config.h</tt> rather than <tt>config_asm.h</tt>
16
/// directly.
17
/// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
18
/// Make config.h more autoconf friendly</A>,
19
/// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>
20
/// on the Crypto++ wiki
21
/// \since Crypto++ 8.3
22
23
#ifndef CRYPTOPP_CONFIG_ASM_H
24
#define CRYPTOPP_CONFIG_ASM_H
25
26
#include "
config_os.h
"
27
#include "
config_cpu.h
"
28
#include "
config_ver.h
"
29
30
// Define this to disable ASM, intrinsics and built-ins. The library will be
31
// compiled using C++ only. The library code will not include SSE2 (and
32
// above), NEON, Aarch32, Aarch64, or Altivec (and above). Note the compiler
33
// may use higher ISAs depending on compiler options, but the library will not
34
// explicitly use the ISAs. When disabling ASM, it is best to do it from
35
// config.h to ensure the library and all programs share the setting.
36
// #define CRYPTOPP_DISABLE_ASM 1
37
38
// https://github.com/weidai11/cryptopp/issues/719
39
#if defined(__native_client__)
40
# undef CRYPTOPP_DISABLE_ASM
41
# define CRYPTOPP_DISABLE_ASM 1
42
#endif
43
44
// Some Clang and SunCC cannot handle mixed asm with positional arguments,
45
// where the body is Intel style with no prefix and the templates are
46
// AT&T style. Define this if the Makefile misdetects the configuration.
47
// Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
48
// #define CRYPTOPP_DISABLE_MIXED_ASM 1
49
50
#if defined(__clang__) || (defined(__APPLE__) && defined(__GNUC__)) || defined(__SUNPRO_CC)
51
# undef CRYPTOPP_DISABLE_MIXED_ASM
52
# define CRYPTOPP_DISABLE_MIXED_ASM 1
53
#endif
54
55
// Define this if you need to disable Android advanced ISAs.
56
// The problem is, Android-mk does not allow us to specify an
57
// ISA option, like -maes or -march=armv8-a+crypto for AES.
58
// Lack of an option results in a compile failure. To avoid
59
// the compile failure, set this define. Also see
60
// https://github.com/weidai11/cryptopp/issues/1015
61
// CRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA 1
62
63
// ***************** IA32 CPU features ********************
64
65
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
66
67
// Apple Clang prior to 5.0 cannot handle SSE2
68
#if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
69
# define CRYPTOPP_DISABLE_ASM 1
70
#endif
71
72
// Sun Studio 12.1 provides GCC inline assembly
73
// http://blogs.oracle.com/x86be/entry/gcc_style_asm_inlining_support
74
#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5100)
75
# define CRYPTOPP_DISABLE_ASM 1
76
#endif
77
78
// Guard everything in CRYPTOPP_DISABLE_ASM
79
#if !defined(CRYPTOPP_DISABLE_ASM)
80
81
#if (defined(_MSC_VER) && defined(_M_IX86)) || ((defined(__GNUC__) && (defined(__i386__)) || defined(__x86_64__)))
82
// C++Builder 2010 does not allow "call label" where label is defined within inline assembly
83
#define CRYPTOPP_X86_ASM_AVAILABLE 1
84
85
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
86
#define CRYPTOPP_SSE2_ASM_AVAILABLE 1
87
#endif
88
89
#if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || CRYPTOPP_GCC_VERSION >= 40300 || defined(__SSSE3__))
90
#define CRYPTOPP_SSSE3_ASM_AVAILABLE 1
91
#endif
92
#endif
93
94
#if defined(_MSC_VER) && defined(_M_X64)
95
#define CRYPTOPP_X64_MASM_AVAILABLE 1
96
#endif
97
98
#if defined(__GNUC__) && defined(__x86_64__)
99
#define CRYPTOPP_X64_ASM_AVAILABLE 1
100
#endif
101
102
// 32-bit SunCC does not enable SSE2 by default.
103
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__) || (__SUNPRO_CC >= 0x5100))
104
#define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1
105
#endif
106
107
#if !defined(CRYPTOPP_DISABLE_SSSE3)
108
# if defined(__SSSE3__) || (_MSC_VER >= 1500) || \
109
(CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \
110
(CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000)
111
#define CRYPTOPP_SSSE3_AVAILABLE 1
112
# endif
113
#endif
114
115
// Intrinsics available in GCC 4.3 (http://gcc.gnu.org/gcc-4.3/changes.html) and
116
// MSVC 2008 (http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx)
117
// SunCC could generate SSE4 at 12.1, but the intrinsics are missing until 12.4.
118
#if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
119
(defined(__SSE4_1__) || (CRYPTOPP_MSC_VERSION >= 1500) || \
120
(CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \
121
(CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
122
#define CRYPTOPP_SSE41_AVAILABLE 1
123
#endif
124
125
#if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
126
(defined(__SSE4_2__) || (CRYPTOPP_MSC_VERSION >= 1500) || (__SUNPRO_CC >= 0x5110) || \
127
(CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || \
128
(CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
129
#define CRYPTOPP_SSE42_AVAILABLE 1
130
#endif
131
132
// Couple to CRYPTOPP_DISABLE_AESNI, but use CRYPTOPP_CLMUL_AVAILABLE so we can selectively
133
// disable for misbehaving platforms and compilers, like Solaris or some Clang.
134
#if defined(CRYPTOPP_DISABLE_AESNI)
135
#define CRYPTOPP_DISABLE_CLMUL 1
136
#endif
137
138
// Requires Sun Studio 12.3 (SunCC 0x5120) in theory.
139
#if !defined(CRYPTOPP_DISABLE_CLMUL) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
140
(defined(__PCLMUL__) || (_MSC_FULL_VER >= 150030729) || (__SUNPRO_CC >= 0x5120) || \
141
(CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
142
(CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
143
#define CRYPTOPP_CLMUL_AVAILABLE 1
144
#endif
145
146
// Requires Sun Studio 12.3 (SunCC 0x5120)
147
#if !defined(CRYPTOPP_DISABLE_AESNI) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
148
(defined(__AES__) || (_MSC_FULL_VER >= 150030729) || (__SUNPRO_CC >= 0x5120) || \
149
(CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
150
(CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
151
#define CRYPTOPP_AESNI_AVAILABLE 1
152
#endif
153
154
// Requires Binutils 2.24
155
#if !defined(CRYPTOPP_DISABLE_AVX) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
156
(defined(__AVX2__) || (CRYPTOPP_MSC_VERSION >= 1800) || (__SUNPRO_CC >= 0x5130) || \
157
(CRYPTOPP_GCC_VERSION >= 40700) || (__INTEL_COMPILER >= 1400) || \
158
(CRYPTOPP_LLVM_CLANG_VERSION >= 30100) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40600))
159
#define CRYPTOPP_AVX_AVAILABLE 1
160
#endif
161
162
// Requires Binutils 2.24
163
#if !defined(CRYPTOPP_DISABLE_AVX2) && defined(CRYPTOPP_AVX_AVAILABLE) && \
164
(defined(__AVX2__) || (CRYPTOPP_MSC_VERSION >= 1800) || (__SUNPRO_CC >= 0x5130) || \
165
(CRYPTOPP_GCC_VERSION >= 40900) || (__INTEL_COMPILER >= 1400) || \
166
(CRYPTOPP_LLVM_CLANG_VERSION >= 30100) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40600))
167
#define CRYPTOPP_AVX2_AVAILABLE 1
168
#endif
169
170
// Guessing at SHA for SunCC. Its not in Sun Studio 12.6. Also see
171
// http://stackoverflow.com/questions/45872180/which-xarch-for-sha-extensions-on-solaris
172
// Guessing for Intel ICPC. A slide deck says SHA support is in version 16.0-beta
173
// https://www.alcf.anl.gov/files/ken_intel_compiler_optimization.pdf
174
#if !defined(CRYPTOPP_DISABLE_SHANI) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
175
(defined(__SHA__) || (CRYPTOPP_MSC_VERSION >= 1900) || (__SUNPRO_CC >= 0x5160) || \
176
(CRYPTOPP_GCC_VERSION >= 40900) || (__INTEL_COMPILER >= 1600) || \
177
(CRYPTOPP_LLVM_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50100))
178
#define CRYPTOPP_SHANI_AVAILABLE 1
179
#endif
180
181
// RDRAND uses byte codes. All we need is x86 ASM for it.
182
// However tie it to AES-NI since SecureKey was available with it.
183
#if !defined(CRYPTOPP_DISABLE_RDRAND) && defined(CRYPTOPP_AESNI_AVAILABLE)
184
#define CRYPTOPP_RDRAND_AVAILABLE 1
185
#endif
186
187
// RDSEED uses byte codes. All we need is x86 ASM for it.
188
// However tie it to AES-NI since SecureKey was available with it.
189
#if !defined(CRYPTOPP_DISABLE_RDSEED) && defined(CRYPTOPP_AESNI_AVAILABLE)
190
#define CRYPTOPP_RDSEED_AVAILABLE 1
191
#endif
192
193
// PadlockRNG uses byte codes. All we need is x86 ASM for it.
194
#if !defined(CRYPTOPP_DISABLE_PADLOCK) && \
195
!(defined(__ANDROID__) || defined(ANDROID) || defined(__APPLE__)) && \
196
defined(CRYPTOPP_X86_ASM_AVAILABLE)
197
#define CRYPTOPP_PADLOCK_AVAILABLE 1
198
#define CRYPTOPP_PADLOCK_RNG_AVAILABLE 1
199
#define CRYPTOPP_PADLOCK_ACE_AVAILABLE 1
200
#define CRYPTOPP_PADLOCK_ACE2_AVAILABLE 1
201
#define CRYPTOPP_PADLOCK_PHE_AVAILABLE 1
202
#define CRYPTOPP_PADLOCK_PMM_AVAILABLE 1
203
#endif
204
205
// Fixup for SunCC 12.1-12.4. Bad code generation in AES_Encrypt and friends.
206
#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5130)
207
# undef CRYPTOPP_AESNI_AVAILABLE
208
#endif
209
210
// Fixup for SunCC 12.1-12.6. Compiler crash on GCM_Reduce_CLMUL.
211
// http://github.com/weidai11/cryptopp/issues/226
212
#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5150)
213
# undef CRYPTOPP_CLMUL_AVAILABLE
214
#endif
215
216
// Clang intrinsic casts, http://bugs.llvm.org/show_bug.cgi?id=20670
217
#define M128_CAST(x) ((__m128i *)(void *)(x))
218
#define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
219
#define M256_CAST(x) ((__m256i *)(void *)(x))
220
#define CONST_M256_CAST(x) ((const __m256i *)(const void *)(x))
221
222
#endif // CRYPTOPP_DISABLE_ASM
223
224
#endif // X86, X32, X64
225
226
// ***************** ARM CPU features ********************
227
228
#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8)
229
230
// We don't have an ARM big endian test rig. Disable
231
// ARM-BE ASM and instrinsics until we can test it.
232
#if (CRYPTOPP_BIG_ENDIAN)
233
# define CRYPTOPP_DISABLE_ASM 1
234
#endif
235
236
// Guard everything in CRYPTOPP_DISABLE_ASM
237
#if !defined(CRYPTOPP_DISABLE_ASM)
238
239
// Requires ACLE 1.0. -mfpu=neon or above must be present
240
// Requires GCC 4.3, Clang 2.8 or Visual Studio 2012
241
// Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.
242
#if !defined(CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_NEON)
243
# if defined(__arm__) || defined(__ARM_NEON) || defined(__ARM_FEATURE_NEON) || defined(_M_ARM)
244
# if (CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) || \
245
(CRYPTOPP_APPLE_CLANG_VERSION >= 30200) || (CRYPTOPP_MSC_VERSION >= 1700)
246
# define CRYPTOPP_ARM_NEON_AVAILABLE 1
247
# endif // Compilers
248
# endif // Platforms
249
#endif
250
251
// ARMv8 and ASIMD. -march=armv8-a or above must be present
252
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
253
// Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.
254
#if !defined(CRYPTOPP_ARM_ASIMD_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_ASIMD)
255
# if defined(__aarch32__) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
256
# if defined(__ARM_NEON) || defined(__ARM_ASIMD) || defined(__ARM_FEATURE_NEON) || defined(__ARM_FEATURE_ASIMD) || \
257
(CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || \
258
(CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (CRYPTOPP_MSC_VERSION >= 1916)
259
# define CRYPTOPP_ARM_NEON_AVAILABLE 1
260
# define CRYPTOPP_ARM_ASIMD_AVAILABLE 1
261
# endif // Compilers
262
# endif // Platforms
263
#endif
264
265
// ARMv8 and ASIMD. -march=armv8-a+crc or above must be present
266
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
267
#if !defined(CRYPTOPP_ARM_CRC32_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_CRC32)
268
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
269
# if defined(__ARM_FEATURE_CRC32) || (CRYPTOPP_GCC_VERSION >= 40800) || \
270
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
271
(CRYPTOPP_MSC_VERSION >= 1916)
272
# define CRYPTOPP_ARM_CRC32_AVAILABLE 1
273
# endif // Compilers
274
# endif // Platforms
275
#endif
276
277
// ARMv8 and AES. -march=armv8-a+crypto or above must be present
278
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
279
#if !defined(CRYPTOPP_ARM_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_AES)
280
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
281
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
282
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
283
(CRYPTOPP_MSC_VERSION >= 1916)
284
# define CRYPTOPP_ARM_AES_AVAILABLE 1
285
# endif // Compilers
286
# endif // Platforms
287
#endif
288
289
// ARMv8 and PMULL. -march=armv8-a+crypto or above must be present
290
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
291
#if !defined(CRYPTOPP_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_PMULL)
292
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
293
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
294
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
295
(CRYPTOPP_MSC_VERSION >= 1916)
296
# define CRYPTOPP_ARM_PMULL_AVAILABLE 1
297
# endif // Compilers
298
# endif // Platforms
299
#endif
300
301
// ARMv8 and SHA-1, SHA-256. -march=armv8-a+crypto or above must be present
302
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
303
#if !defined(CRYPTOPP_ARM_SHA_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
304
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
305
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
306
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
307
(CRYPTOPP_MSC_VERSION >= 1916)
308
# define CRYPTOPP_ARM_SHA1_AVAILABLE 1
309
# define CRYPTOPP_ARM_SHA2_AVAILABLE 1
310
# endif // Compilers
311
# endif // Platforms
312
#endif
313
314
// Buggy Microsoft compiler, https://github.com/weidai11/cryptopp/issues/1096
315
#if defined(_MSC_VER)
316
# undef CRYPTOPP_ARM_SHA1_AVAILABLE
317
# undef CRYPTOPP_ARM_SHA2_AVAILABLE
318
#endif
319
320
// ARMv8 and SHA-512, SHA-3. -march=armv8.2-a+crypto or above must be present
321
// Requires GCC 8.0, Clang 11.0, Apple Clang 12.0 or Visual Studio 20??
322
#if !defined(CRYPTOPP_ARM_SHA3_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
323
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
324
# if defined(__ARM_FEATURE_SHA3) || (CRYPTOPP_GCC_VERSION >= 80000) || \
325
(CRYPTOPP_APPLE_CLANG_VERSION >= 120000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 110000)
326
# define CRYPTOPP_ARM_SHA512_AVAILABLE 1
327
# define CRYPTOPP_ARM_SHA3_AVAILABLE 1
328
# endif // Compilers
329
# endif // Platforms
330
#endif
331
332
// ARMv8 and SM3, SM4. -march=armv8.2-a+crypto or above must be present
333
// Requires GCC 8.0, Clang ??? or Visual Studio 20??
334
// Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.
335
#if !defined(CRYPTOPP_ARM_SM3_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SM3)
336
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
337
# if defined(__ARM_FEATURE_SM3) || (CRYPTOPP_GCC_VERSION >= 80000)
338
# define CRYPTOPP_ARM_SM3_AVAILABLE 1
339
# define CRYPTOPP_ARM_SM4_AVAILABLE 1
340
# endif // Compilers
341
# endif // Platforms
342
#endif
343
344
// Limit the <arm_neon.h> include.
345
#if !defined(CRYPTOPP_ARM_NEON_HEADER)
346
# if defined(CRYPTOPP_ARM_NEON_AVAILABLE) || defined (CRYPTOPP_ARM_ASIMD_AVAILABLE)
347
# if !defined(_M_ARM64)
348
# define CRYPTOPP_ARM_NEON_HEADER 1
349
# endif
350
# endif
351
#endif
352
353
// Limit the <arm_acle.h> include.
354
#if !defined(CRYPTOPP_ARM_ACLE_HEADER)
355
# if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
356
# define CRYPTOPP_ARM_ACLE_HEADER 1
357
# endif
358
#endif
359
360
// Apple M1 hack. Xcode cross-compiles for iOS lack
361
// arm_acle.h. Apple M1 needs arm_acle.h. The problem
362
// in practice is, we can't get CRYPTOPP_ARM_ACLE_HEADER
363
// quite right based on ARM preprocessor macros.
364
#if defined(__APPLE__) && !defined(__ARM_FEATURE_CRC32)
365
# undef CRYPTOPP_ARM_ACLE_HEADER
366
#endif
367
368
// Cryptogams offers an ARM asm implementations for AES and SHA. Crypto++ does
369
// not provide an asm implementation. The Cryptogams AES implementation is
370
// about 50% faster than C/C++, and SHA implementation is about 30% faster
371
// than C/C++. Define this to use the Cryptogams AES and SHA implementations
372
// on GNU Linux systems. When defined, Crypto++ will use aes_armv4.S,
373
// sha1_armv4.S and sha256_armv4.S. https://www.cryptopp.com/wiki/Cryptogams.
374
#if !defined(CRYPTOPP_DISABLE_ARM_NEON)
375
# if defined(__arm__) && defined(__linux__)
376
# if defined(__GNUC__) || defined(__clang__)
377
# define CRYPTOGAMS_ARM_AES 1
378
# define CRYPTOGAMS_ARM_SHA1 1
379
# define CRYPTOGAMS_ARM_SHA256 1
380
# define CRYPTOGAMS_ARM_SHA512 1
381
# endif
382
# endif
383
#endif
384
385
// Clang intrinsic casts, http://bugs.llvm.org/show_bug.cgi?id=20670
386
#define UINT64_CAST(x) ((uint64_t *)(void *)(x))
387
#define CONST_UINT64_CAST(x) ((const uint64_t *)(const void *)(x))
388
389
#endif // CRYPTOPP_DISABLE_ASM
390
391
#endif // ARM32, ARM64
392
393
// ***************** AltiVec and Power8 ********************
394
395
#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
396
397
// Guard everything in CRYPTOPP_DISABLE_ASM
398
#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_ALTIVEC)
399
400
// An old Apple G5 with GCC 4.01 has AltiVec, but its only Power4 or so.
401
#if !defined(CRYPTOPP_ALTIVEC_AVAILABLE)
402
# if defined(_ARCH_PWR4) || defined(__ALTIVEC__) || \
403
(CRYPTOPP_XLC_VERSION >= 100000) || (CRYPTOPP_GCC_VERSION >= 40001) || \
404
(CRYPTOPP_LLVM_CLANG_VERSION >= 20900)
405
# define CRYPTOPP_ALTIVEC_AVAILABLE 1
406
# endif
407
#endif
408
409
#if defined(CRYPTOPP_ALTIVEC_AVAILABLE)
410
411
// We need Power7 for unaligned loads and stores
412
#if !defined(CRYPTOPP_POWER7_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER7)
413
# if defined(_ARCH_PWR7) || (CRYPTOPP_XLC_VERSION >= 100000) || \
414
(CRYPTOPP_GCC_VERSION >= 40100) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30100)
415
# define CRYPTOPP_POWER7_AVAILABLE 1
416
# endif
417
#endif
418
419
#if defined(CRYPTOPP_POWER7_AVAILABLE)
420
421
// We need Power8 for in-core crypto and 64-bit vector types
422
#if !defined(CRYPTOPP_POWER8_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER8)
423
# if defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || \
424
(CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 70000)
425
# define CRYPTOPP_POWER8_AVAILABLE 1
426
# endif
427
#endif
428
429
#if !defined(CRYPTOPP_POWER8_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER8_AES) && defined(CRYPTOPP_POWER8_AVAILABLE)
430
# if defined(__CRYPTO__) || defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || \
431
(CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 70000)
432
//# define CRYPTOPP_POWER8_CRC_AVAILABLE 1
433
# define CRYPTOPP_POWER8_AES_AVAILABLE 1
434
# define CRYPTOPP_POWER8_VMULL_AVAILABLE 1
435
# define CRYPTOPP_POWER8_SHA_AVAILABLE 1
436
# endif
437
#endif
438
439
#if defined(CRYPTOPP_POWER8_AVAILABLE)
440
441
// Power9 for random numbers
442
#if !defined(CRYPTOPP_POWER9_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER9)
443
# if defined(_ARCH_PWR9) || (CRYPTOPP_XLC_VERSION >= 130200) || \
444
(CRYPTOPP_GCC_VERSION >= 70000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 80000)
445
# define CRYPTOPP_POWER9_AVAILABLE 1
446
# endif
447
#endif
448
449
#endif // CRYPTOPP_POWER8_AVAILABLE
450
#endif // CRYPTOPP_POWER7_AVAILABLE
451
#endif // CRYPTOPP_ALTIVEC_AVAILABLE
452
#endif // CRYPTOPP_DISABLE_ASM
453
#endif // PPC32, PPC64
454
455
// https://github.com/weidai11/cryptopp/issues/1015
456
#if defined(CRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA)
457
# if defined(__ANDROID__) || defined(ANDROID)
458
# if (CRYPTOPP_BOOL_X86)
459
# undef CRYPTOPP_SSE41_AVAILABLE
460
# undef CRYPTOPP_SSE42_AVAILABLE
461
# undef CRYPTOPP_CLMUL_AVAILABLE
462
# undef CRYPTOPP_AESNI_AVAILABLE
463
# undef CRYPTOPP_SHANI_AVAILABLE
464
# undef CRYPTOPP_RDRAND_AVAILABLE
465
# undef CRYPTOPP_RDSEED_AVAILABLE
466
# undef CRYPTOPP_AVX_AVAILABLE
467
# undef CRYPTOPP_AVX2_AVAILABLE
468
# endif
469
# if (CRYPTOPP_BOOL_X64)
470
# undef CRYPTOPP_CLMUL_AVAILABLE
471
# undef CRYPTOPP_AESNI_AVAILABLE
472
# undef CRYPTOPP_SHANI_AVAILABLE
473
# undef CRYPTOPP_RDRAND_AVAILABLE
474
# undef CRYPTOPP_RDSEED_AVAILABLE
475
# undef CRYPTOPP_AVX_AVAILABLE
476
# undef CRYPTOPP_AVX2_AVAILABLE
477
# endif
478
# if (CRYPTOPP_BOOL_ARMV8)
479
# undef CRYPTOPP_ARM_CRC32_AVAILABLE
480
# undef CRYPTOPP_ARM_PMULL_AVAILABLE
481
# undef CRYPTOPP_ARM_AES_AVAILABLE
482
# undef CRYPTOPP_ARM_SHA1_AVAILABLE
483
# undef CRYPTOPP_ARM_SHA2_AVAILABLE
484
# endif
485
# endif // ANDROID
486
#endif // CRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA
487
488
#endif // CRYPTOPP_CONFIG_ASM_H
config_cpu.h
Library configuration file.
config_os.h
Library configuration file.
config_ver.h
Library configuration file.
Generated on Fri Jun 14 2024 14:11:58 for Crypto++ by
1.8.17