Botan 2.19.5 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
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*/
19 class BOTAN_PUBLIC_API(2,15) Processor_RNG final : public Hardware_RNG
20 {
21 public:
22 /**
23 * Constructor will throw if CPU does not have RDRAND bit set
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 bool accepts_input() const override { return false; }
33 bool is_seeded() const override { return true; }
34
35 void randomize(uint8_t out[], size_t out_len) override;
36
37 /*
38 * No way to provide entropy to RDRAND generator, so add_entropy is ignored
39 */
40 void add_entropy(const uint8_t[], size_t) override;
41
42 /*
43 * No way to reseed processor provided generator, so reseed is ignored
44 */
45 size_t reseed(Entropy_Sources&, size_t, std::chrono::milliseconds) override;
46
47 std::string name() const override;
48 };
49
50}
51
52#endif
Botan::Entropy_Sources
Definition: entropy_src.h:57
Botan::Hardware_RNG
Definition: rng.h:197
Botan::Processor_RNG
Definition: processor_rng.h:20
Botan::Processor_RNG::is_seeded
bool is_seeded() const override
Definition: processor_rng.h:33
Botan::Processor_RNG::accepts_input
bool accepts_input() const override
Definition: processor_rng.h:32
name
std::string name
Definition: commoncrypto_hash.cpp:24
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan
Definition: alg_id.cpp:13