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 SCALAR_AES:
16 return "scalar_aes";
17 case SCALAR_SHA256:
18 return "scalar_sha256";
19 case SCALAR_SM3:
20 return "scalar_sm3";
21 case SCALAR_SM4:
22 return "scalar_sm4";
23 case VECTOR:
24 return "vector";
25 case VECTOR_AES:
26 return "vector_aes";
27 case VECTOR_SHA256:
28 return "vector_sha256";
29 case VECTOR_SM3:
30 return "vector_sm3";
31 case VECTOR_SM4:
32 return "vector_sm4";
33 }
34 throw Invalid_State("CPUFeature invalid bit");
35}
36
37//static
38std::optional<CPUFeature> CPUFeature::from_string(std::string_view tok) {
39 if(tok == "scalar_aes") {
40 return SCALAR_AES;
41 } else if(tok == "scalar_sha256") {
42 return SCALAR_SHA256;
43 } else if(tok == "scalar_sm3") {
44 return SCALAR_SM3;
45 } else if(tok == "scalar_sm4") {
46 return SCALAR_SM4;
47 } else if(tok == "vector") {
48 return VECTOR;
49 } else if(tok == "vector_aes") {
50 return VECTOR_AES;
51 } else if(tok == "vector_sha256") {
52 return VECTOR_SHA256;
53 } else if(tok == "vector_sm3") {
54 return VECTOR_SM3;
55 } else if(tok == "vector_sm4") {
56 return VECTOR_SM4;
57 } else {
58 return {};
59 }
60}
61
62} // namespace Botan
static std::optional< CPUFeature > from_string(std::string_view)
Definition cpuid.cpp:24
std::string to_string() const
Definition cpuid.cpp:28