Botan 3.14.1
Crypto and TLS for C&
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
12namespace 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*/
20class 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 */
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
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
static bool available()
bool is_seeded() const override
bool accepts_input() const override
const char * name
Definition ffi_tls.h:59