Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

rdrand_rng.h
Go to the documentation of this file.
1 /*
2 * RDRAND RNG
3 * (C) 2016 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_DLL RDRAND_RNG : public Hardware_RNG
16 {
17 public:
18 /**
19 * On correctly working hardware, RDRAND is always supposed to
20 * succeed within a set number of retries. If after that many
21 * retries RDRAND has still not suceeded, sets ok = false and
22 * returns 0.
23 */
24 static uint32_t rdrand_status(bool& ok);
25
26 /*
27 * Calls RDRAND until it succeeds, this could hypothetically
28 * loop forever on broken hardware.
29 */
30 static uint32_t rdrand();
31
32 /**
33 * Constructor will throw if CPU does not have RDRAND bit set
34 */
35 RDRAND_RNG();
36
37 /**
38 * Uses RDRAND to produce output
39 */
40 void randomize(uint8_t out[], size_t out_len) override;
41
42 /*
43 * No way to provide entropy to RDRAND generator, so add_entropy is ignored
44 */
45 void add_entropy(const uint8_t[], size_t) override
46 { /* no op */ }
47
48 /*
49 * No way to reseed RDRAND generator, so reseed is ignored
50 */
51 size_t reseed(Entropy_Sources&, size_t, std::chrono::milliseconds) override
52 { return 0; /* no op */ }
53
54 std::string name() const override { return "RDRAND"; }
55
56 bool is_seeded() const override { return true; }
57
58 void clear() override {}
59 };
60
61 }
62
63 #endif
Botan::RDRAND_RNG::is_seeded
bool is_seeded() const override
Definition: rdrand_rng.h:56
Botan::RDRAND_RNG::clear
void clear() override
Definition: rdrand_rng.h:58
Botan::RDRAND_RNG::reseed
size_t reseed(Entropy_Sources &, size_t, std::chrono::milliseconds) override
Definition: rdrand_rng.h:51
Botan::RDRAND_RNG
Definition: rdrand_rng.h:15
Botan::RDRAND_RNG::add_entropy
void add_entropy(const uint8_t[], size_t) override
Definition: rdrand_rng.h:45
Botan
Definition: alg_id.cpp:13
Botan::RDRAND_RNG::name
std::string name() const override
Definition: rdrand_rng.h:54
Botan::Entropy_Sources
Definition: entropy_src.h:51
Botan::Hardware_RNG
Definition: rng.h:180