Botan 2.19.5 Crypto and TLS for C&

rdrand_rng.h
Go to the documentation of this file.
1/*
2* RDRAND RNG
3* (C) 2016,2019 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_RNG_RDRAND_H_
9#define BOTAN_RNG_RDRAND_H_
10
11#include <botan/rng.h>
12
13 namespace Botan {
14
15 class BOTAN_PUBLIC_API(2,0) RDRAND_RNG final : public Hardware_RNG
16 {
17 public:
18 /**
19 * Constructor will throw if CPU does not have RDRAND bit set
20 */
21 BOTAN_DEPRECATED("Use Processor_RNG instead") RDRAND_RNG();
22
23 /**
24 * Return true if RDRAND is available on the current processor
25 */
26 static bool available();
27
28 bool accepts_input() const override { return false; }
29
30 /**
31 * Uses RDRAND to produce output
32 */
33 void randomize(uint8_t out[], size_t out_len) override;
34
35 /*
36 * No way to provide entropy to RDRAND generator, so add_entropy is ignored
37 */
38 void add_entropy(const uint8_t[], size_t) override
39 { /* no op */ }
40
41 /*
42 * No way to reseed RDRAND generator, so reseed is ignored
43 */
44 size_t reseed(Entropy_Sources&, size_t, std::chrono::milliseconds) override
45 { return 0; /* no op */ }
46
47 std::string name() const override { return "RDRAND"; }
48
49 bool is_seeded() const override { return true; }
50
51 /**
52 * On correctly working hardware, RDRAND is always supposed to
53 * succeed within a set number of retries. If after that many
54 * retries RDRAND has still not suceeded, sets ok = false and
55 * returns 0.
56 */
57 static uint32_t BOTAN_DEPRECATED("Use Processor_RNG::randomize") rdrand_status(bool& ok);
58
59 /*
60 * Calls RDRAND until it succeeds, this could hypothetically
61 * loop forever on broken hardware.
62 */
63 static uint32_t BOTAN_DEPRECATED("Use Processor_RNG::randomize") rdrand();
64 };
65
66}
67
68#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::RDRAND_RNG
Definition: rdrand_rng.h:16
Botan::RDRAND_RNG::is_seeded
bool is_seeded() const override
Definition: rdrand_rng.h:49
Botan::RDRAND_RNG::accepts_input
bool accepts_input() const override
Definition: rdrand_rng.h:28
Botan::RDRAND_RNG::reseed
size_t reseed(Entropy_Sources &, size_t, std::chrono::milliseconds) override
Definition: rdrand_rng.h:44
Botan::RDRAND_RNG::name
std::string name() const override
Definition: rdrand_rng.h:47
Botan::RDRAND_RNG::add_entropy
void add_entropy(const uint8_t[], size_t) override
Definition: rdrand_rng.h:38
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