Botan 3.9.0
Crypto and TLS for C&
cpuid_features.cpp
Go to the documentation of this file.
1/**
2* (C) 2025 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/cpuid_features.h>
8
9#include <botan/exceptn.h>
10
11namespace Botan {
12
13std::string CPUFeature::to_string() const {
14 switch(m_bit) {
15 case CPUFeature::Bit::NEON:
16 return "neon";
17 case CPUFeature::Bit::SHA1:
18 return "armv8sha1";
19 case CPUFeature::Bit::SHA2:
20 return "armv8sha2";
21 case CPUFeature::Bit::AES:
22 return "armv8aes";
23 case CPUFeature::Bit::PMULL:
24 return "armv8pmull";
25 }
26 throw Invalid_State("CPUFeature invalid bit");
27}
28
29//static
30std::optional<CPUFeature> CPUFeature::from_string(std::string_view tok) {
31 // TODO(Botan4) remove the "armv8" strings here
32 if(tok == "neon" || tok == "simd") {
33 return CPUFeature::Bit::NEON;
34 } else if(tok == "armv8sha1" || tok == "arm_sha1") {
35 return CPUFeature::Bit::SHA1;
36 } else if(tok == "armv8sha2" || tok == "arm_sha2") {
37 return CPUFeature::Bit::SHA2;
38 } else if(tok == "armv8aes" || tok == "arm_aes") {
39 return CPUFeature::Bit::AES;
40 } else if(tok == "armv8pmull" || tok == "arm_pmull") {
41 return CPUFeature::Bit::PMULL;
42 } else {
43 return {};
44 }
45}
46
47} // namespace Botan
static std::optional< CPUFeature > from_string(std::string_view)
Definition cpuid.cpp:24
std::string to_string() const
Definition cpuid.cpp:28