Botan
3.14.1
Crypto and TLS for C&
src
lib
utils
hwrng
hwrng.h
Go to the documentation of this file.
1
/*
2
* (C) 2026 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#ifndef BOTAN_HWRNG_H_
8
#define BOTAN_HWRNG_H_
9
10
#include <botan/types.h>
11
#include <botan/internal/cpuid.h>
12
#include <optional>
13
14
namespace
Botan::HWRNG
{
15
16
/**
17
* Return true if the current CPU supports the hardware RNG instruction
18
*/
19
BOTAN_TEST_API
bool
available
();
20
21
/**
22
* Read 64 bits from the hardware RNG
23
*
24
* Returns nullopt if the instruction repeatedly failed to produce an output,
25
* which indicates a hardware fault.
26
*
27
* Must only be called if available() returns true
28
*/
29
BOTAN_TEST_API
std::optional<uint64_t>
read
();
30
31
/*
32
* The following functions are implemented by the architecture specific submodule
33
*/
34
35
/**
36
* Return the CPUID feature which indicates the hardware RNG is available
37
*/
38
CPUID::Feature
feature
();
39
40
/**
41
* Make a single attempt to read 64 bits from the hardware RNG
42
*
43
* Returns nullopt if the instruction indicated failure
44
*
45
* Must only be called if available() returns true
46
*/
47
std::optional<uint64_t>
read_once
();
48
49
}
// namespace Botan::HWRNG
50
51
#endif
BOTAN_TEST_API
#define BOTAN_TEST_API
Definition
api.h:41
Botan::CPUID::Feature
CPUFeature Feature
Definition
cpuid.h:44
Botan::HWRNG
Definition
hwrng.cpp:9
Botan::HWRNG::read_once
std::optional< uint64_t > read_once()
Definition
hwrng_aarch64.cpp:23
Botan::HWRNG::feature
CPUID::Feature feature()
Definition
hwrng_aarch64.cpp:19
Botan::HWRNG::available
bool available()
Definition
hwrng.cpp:11
Botan::HWRNG::read
std::optional< uint64_t > read()
Definition
hwrng.cpp:15
Generated by
1.16.1