Botan
3.10.0
Crypto and TLS for C&
src
lib
utils
cpuid
cpuid_x86
cpuid_features.h
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
#ifndef BOTAN_CPUID_FEATURES_H_
8
#define BOTAN_CPUID_FEATURES_H_
9
10
#include <botan/api.h>
11
#include <cstdint>
12
#include <optional>
13
#include <string>
14
#include <string_view>
15
16
namespace
Botan
{
17
18
class
BOTAN_TEST_API
CPUFeature
{
19
public
:
20
enum
Bit
: uint32_t
/* NOLINT(*-use-enum-class) */
{
21
SSE2 = (1U << 0),
22
SSSE3 = (1U << 1),
23
AVX2 = (1U << 2),
24
AVX512 = (1U << 3),
25
26
RDTSC = (1U << 6),
27
ADX = (1U << 7),
28
BMI = (1U << 8),
29
GFNI = (1U << 9),
30
RDRAND = (1U << 10),
31
RDSEED = (1U << 11),
32
33
// Crypto-specific ISAs
34
AESNI = (1U << 16),
35
CLMUL = (1U << 17),
36
SHA = (1U << 20),
37
SHA512 = (1U << 21),
38
AVX2_AES = (1U << 22),
39
AVX512_AES = (1U << 23),
40
AVX2_CLMUL = (1U << 24),
41
AVX512_CLMUL = (1U << 25),
42
SM3
= (1U << 26),
43
SM4
= (1U << 27),
44
45
SIMD_4X32 = SSSE3,
46
HW_AES = AESNI,
47
HW_CLMUL = CLMUL,
48
};
49
50
CPUFeature
(
Bit
b) : m_bit(b) {}
// NOLINT(*-explicit-conversions)
51
52
uint32_t
as_u32
()
const
{
return
static_cast<
uint32_t
>
(m_bit); }
53
54
std::string
to_string
()
const
;
55
56
static
std::optional<CPUFeature>
from_string
(std::string_view s);
57
58
private
:
59
Bit
m_bit;
60
};
61
62
}
// namespace Botan
63
64
#endif
BOTAN_TEST_API
#define BOTAN_TEST_API
Definition
api.h:41
Botan::CPUFeature
Definition
cpuid_features.h:18
Botan::CPUFeature::as_u32
uint32_t as_u32() const
Definition
cpuid_features.h:52
Botan::CPUFeature::CPUFeature
CPUFeature(Bit b)
Definition
cpuid_features.h:50
Botan::CPUFeature::Bit
Bit
Definition
cpuid_features.h:20
Botan::CPUFeature::from_string
static std::optional< CPUFeature > from_string(std::string_view s)
Botan::CPUFeature::to_string
std::string to_string() const
Botan::SM3
Definition
sm3.h:18
Botan::SM4
Definition
sm4.h:19
Botan
Definition
alg_id.cpp:13
Generated by
1.12.0