Botan
3.14.1
Crypto and TLS for C&
src
lib
rng
processor_rng
processor_rng.h
Go to the documentation of this file.
1
/*
2
* (C) 2016,2019,2020 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#ifndef BOTAN_RNG_PROCESSOR_RNG_H_
8
#define BOTAN_RNG_PROCESSOR_RNG_H_
9
10
#include <botan/rng.h>
11
12
namespace
Botan
{
13
14
/**
15
* Directly invokes a CPU specific instruction to generate random numbers.
16
* On x86, the RDRAND instruction is used.
17
* On POWER, the DARN instruction is used.
18
* On AArch64, the RNDR instruction is used.
19
*/
20
class
BOTAN_PUBLIC_API
(2, 15)
Processor_RNG
final :
public
Hardware_RNG
{
21
public
:
22
/**
23
* Constructor will throw if the CPU does not support the RNG instruction
24
*/
25
Processor_RNG
();
26
27
/**
28
* Return true if RNG instruction is available on the current processor
29
*/
30
static
bool
available
();
31
32
/**
33
* Test whether this RNG accepts externally provided input
34
* @return false if this RNG is known to ignore provided inputs
35
*/
36
bool
accepts_input
()
const override
{
return
false
; }
37
38
/**
39
* Test whether this RNG has been seeded
40
* @return true if this RNG is seeded and ready for use
41
*/
42
bool
is_seeded
()
const override
{
return
true
; }
43
44
/**
45
* Return the name of this RNG type
46
* @return the name of this RNG type
47
*/
48
std::string
name
()
const override
;
49
50
private
:
51
void
fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in)
override
;
52
};
53
54
}
// namespace Botan
55
56
#endif
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition
api.h:21
Botan::Hardware_RNG
Definition
rng.h:402
Botan::Processor_RNG::available
static bool available()
Definition
processor_rng.cpp:29
Botan::Processor_RNG::Processor_RNG
Processor_RNG()
Definition
processor_rng.cpp:53
Botan::Processor_RNG::is_seeded
bool is_seeded() const override
Definition
processor_rng.h:42
Botan::Processor_RNG::accepts_input
bool accepts_input() const override
Definition
processor_rng.h:36
name
const char * name
Definition
ffi_tls.h:59
Botan
Definition
alg_id.cpp:14
Generated by
1.16.1