aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/cpuid
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-05-06 09:10:21 -0400
committerJack Lloyd <[email protected]>2020-05-06 09:10:21 -0400
commit213eca6b830787a98d3b274c76bd8eb86b1ce506 (patch)
tree2d0a1fbce06ed49890e2053275b7b9b40fb30190 /src/lib/utils/cpuid
parenta4a237e7f69be2742da6ee1c5a35412081e2c789 (diff)
Consolidate the logic for hardware AES
We can safely assume there is only one hardware instruction set. (Well, at least until VAES support is added, we can address that when it happens)
Diffstat (limited to 'src/lib/utils/cpuid')
-rw-r--r--src/lib/utils/cpuid/cpuid.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/utils/cpuid/cpuid.h b/src/lib/utils/cpuid/cpuid.h
index d9e6b97b3..d9e0a74a6 100644
--- a/src/lib/utils/cpuid/cpuid.h
+++ b/src/lib/utils/cpuid/cpuid.h
@@ -335,6 +335,22 @@ class BOTAN_PUBLIC_API(2,1) CPUID final
}
/**
+ * Check if the processor supports hardware AES instructions
+ */
+ static bool has_hw_aes()
+ {
+#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY)
+ return has_aes_ni();
+#elif defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY)
+ return has_arm_aes();
+#elif defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
+ return has_power_crypto();
+#else
+ return false;
+#endif
+ }
+
+ /**
* Check if the processor supports carryless multiply
* (CLMUL, PMULL)
*/