Crypto++
8.0
Free C++ class library of cryptographic schemes
|
Functions for CPU features and intrinsics. More...
Go to the source code of this file.
Macros | |
#define | NEW_LINE |
#define | INTEL_PREFIX |
#define | INTEL_NOPREFIX |
#define | ATT_PREFIX |
#define | ATT_NOPREFIX |
#define | CRYPTOPP_CPUID_AVAILABLE 1 |
Functions | |
IA-32 CPU FEATURES | |
bool | HasSSE2 () |
Determines SSE2 availability. More... | |
bool | HasSSSE3 () |
Determines SSSE3 availability. More... | |
bool | HasSSE41 () |
Determines SSE4.1 availability. More... | |
bool | HasSSE42 () |
Determines SSE4.2 availability. More... | |
bool | HasAESNI () |
Determines AES-NI availability. More... | |
bool | HasCLMUL () |
Determines Carryless Multiply availability. More... | |
bool | HasSHA () |
Determines SHA availability. More... | |
bool | HasADX () |
Determines ADX availability. More... | |
bool | HasAVX () |
Determines AVX availability. More... | |
bool | HasAVX2 () |
Determines AVX2 availability. More... | |
bool | IsP4 () |
Determines if the CPU is an Intel P4. More... | |
bool | HasRDRAND () |
Determines RDRAND availability. More... | |
bool | HasRDSEED () |
Determines RDSEED availability. More... | |
bool | HasPadlockRNG () |
Determines Padlock RNG availability. More... | |
bool | HasPadlockACE () |
Determines Padlock ACE availability. More... | |
bool | HasPadlockACE2 () |
Determines Padlock ACE2 availability. More... | |
bool | HasPadlockPHE () |
Determines Padlock PHE availability. More... | |
bool | HasPadlockPMM () |
Determines Padlock PMM availability. More... | |
int | GetCacheLineSize () |
Provides the cache line size. More... | |
ARM A-32, Aarch32 and AArch64 CPU FEATURES | |
bool | HasARMv7 () |
Determine if an ARM processor is ARMv7 or above. More... | |
bool | HasNEON () |
Determine if an ARM processor has Advanced SIMD available. More... | |
bool | HasPMULL () |
Determine if an ARM processor provides Polynomial Multiplication. More... | |
bool | HasCRC32 () |
Determine if an ARM processor has CRC32 available. More... | |
bool | HasAES () |
Determine if an ARM processor has AES available. More... | |
bool | HasSHA1 () |
Determine if an ARM processor has SHA1 available. More... | |
bool | HasSHA2 () |
Determine if an ARM processor has SHA256 available. More... | |
bool | HasSHA512 () |
Determine if an ARM processor has SHA512 available. More... | |
bool | HasSHA3 () |
Determine if an ARM processor has SHA3 available. More... | |
bool | HasSM3 () |
Determine if an ARM processor has SM3 available. More... | |
bool | HasSM4 () |
Determine if an ARM processor has SM4 available. More... | |
POWERPC CPU FEATURES | |
bool | HasAltivec () |
Determine if a PowerPC processor has Altivec available. More... | |
bool | HasPower7 () |
Determine if a PowerPC processor has Power7 available. More... | |
bool | HasPower8 () |
Determine if a PowerPC processor has Power8 available. More... | |
bool | HasPower9 () |
Determine if a PowerPC processor has Power9 available. More... | |
bool | HasSHA256 () |
Determine if a PowerPC processor has SHA256 available. More... | |
bool | HasDARN () |
Determine if a PowerPC processor has DARN available. More... | |
Functions for CPU features and intrinsics.
The CPU functions are used in IA-32, ARM and PowerPC code paths. The functions provide cpu specific feature testing on IA-32, ARM and PowerPC machines.
Feature detection uses CPUID on IA-32, like Intel and AMD. On other platforms a two-part strategy is used. First, the library attempts to *Query* the OS for a feature, like using Linux getauxval() or android_getCpuFeatures(). If that fails, then *Probe* the cpu executing an instruction and an observe a SIGILL if unsupported. The general pattern used by the library is:
g_hasCRC32 = CPU_QueryCRC32() || CPU_ProbeCRC32(); g_hasPMULL = CPU_QueryPMULL() || CPU_ProbePMULL(); g_hasAES = CPU_QueryAES() || CPU_ProbeAES();
Generally speaking, CPU_Query() is in the source file cpu.cpp
because it does not require special architectural flags. CPU_Probe() is in a source file that recieves architectural flags, like sse_simd.cpp
, neon_simd.cpp
and ppc_simd.cpp
. For example, compiling neon_simd.cpp
on an ARM64 machine will have -march=armv8-a
applied during a compile to make the instruction set architecture (ISA) available.
The cpu probes are expensive when compared to a standard OS feature query. The library also avoids probes on Apple platforms because Apple's signal handling for SIGILLs appears to corrupt memory. CPU_Probe() will unconditionally return false for Apple platforms. OpenSSL experienced the same problem and moved away from SIGILL probes on Apple.
Definition in file cpu.h.
|
inline |
Determines SSE2 availability.
MMX, SSE and SSE2 are core processor features for x86_64, and the function always returns true for the platform.
|
inline |
Determines SSSE3 availability.
HasSSSE3() is a runtime check performed using CPUID
|
inline |
Determines SSE4.1 availability.
HasSSE41() is a runtime check performed using CPUID
|
inline |
Determines SSE4.2 availability.
HasSSE42() is a runtime check performed using CPUID
|
inline |
Determines AES-NI availability.
HasAESNI() is a runtime check performed using CPUID
|
inline |
Determines Carryless Multiply availability.
HasCLMUL() is a runtime check performed using CPUID
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Determines RDRAND availability.
HasRDRAND() is a runtime check performed using CPUID
|
inline |
Determines RDSEED availability.
HasRDSEED() is a runtime check performed using CPUID
|
inline |
Determines Padlock RNG availability.
HasPadlockRNG() is a runtime check performed using CPUID
|
inline |
Determines Padlock ACE availability.
HasPadlockACE() is a runtime check performed using CPUID
|
inline |
Determines Padlock ACE2 availability.
HasPadlockACE2() is a runtime check performed using CPUID
|
inline |
Determines Padlock PHE availability.
HasPadlockPHE() is a runtime check performed using CPUID
|
inline |
Determines Padlock PMM availability.
HasPadlockPMM() is a runtime check performed using CPUID
|
inline |
Provides the cache line size.
GetCacheLineSize() returns the lower bound on the size of a cache line, if it is available. If the value is not available at runtime, then 32 is returned for a 32-bit processor and 64 is returned for a 64-bit processor.
x86/x32/x64 uses CPUID to determine the value and it is usually accurate. PowerPC and AIX also makes the value available to user space and it is also usually accurate. The ARM processor equivalent is a privileged instruction, so a compile time value is returned.
|
inline |
|
inline |
Determine if an ARM processor has Advanced SIMD available.
Advanced SIMD instructions are available under most ARMv7, Aarch32 and Aarch64.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mfpu=neon
(32-bit) or -march=armv8-a
(64-bit). Also see ARM's __ARM_NEON
preprocessor macro.
|
inline |
Determine if an ARM processor provides Polynomial Multiplication.
Determine if a PowerPC processor has Polynomial Multiply available.
The multiplication instructions are available under Aarch32 and Aarch64.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
PMULL is part of the in-crypto extensions on Power8 and Power9.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has CRC32 available.
CRC32 instructions provide access to the processor's CRC-32 and CRC-32C instructions. They are provided by ARM C Language Extensions 2.0 (ACLE 2.0) and available under Aarch32 and Aarch64.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8-a+crc
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRC32
preprocessor macro.
|
inline |
Determine if an ARM processor has AES available.
Determine if a PowerPC processor has AES available.
AES is part of the optional Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
AES is part of the in-crypto extensions on Power8 and Power9.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA1 available.
SHA1 is part of the optional Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA256 available.
SHA256 is part of the optional Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA512 available.
Determine if a PowerPC processor has SHA512 available.
SHA512 is part of the ARMv8.4 Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
SHA is part of the in-crypto extensions on Power8 and Power9.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SHA3 available.
SHA3 is part of the ARMv8.4 Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SM3 available.
SM3 is part of the ARMv8.4 Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if an ARM processor has SM4 available.
SM4 is part of the ARMv8.4 Crypto extensions on Aarch32 and Aarch64. They are accessed using ARM C Language Extensions 2.0 (ACLE 2.0).
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -march=armv8.4-a+crypto
; while Apple requires -arch arm64
. Also see ARM's __ARM_FEATURE_CRYPTO
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Altivec available.
Altivec instructions are available on modern PowerPCs.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power4
; while IBM XL C/C++ compilers require -qarch=pwr6 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Power7 available.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power7
; while IBM XL C/C++ compilers require -qarch=pwr7 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Power8 available.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has Power9 available.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power9
; while IBM XL C/C++ compilers require -qarch=pwr9 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.
|
inline |
Determine if a PowerPC processor has SHA256 available.
SHA is part of the in-crypto extensions on Power8 and Power9.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power8
; while IBM XL C/C++ compilers require -qarch=pwr8 -qaltivec
. Also see PowerPC's __CRYPTO
preprocessor macro.
|
inline |
Determine if a PowerPC processor has DARN available.
Runtime support requires compile time support. When compiling with GCC, you may need to compile with -mcpu=power9
; while IBM XL C/C++ compilers require -qarch=pwr9 -qaltivec
. Also see PowerPC's _ALTIVEC_
preprocessor macro.