Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

rdrand.cpp
Go to the documentation of this file.
1 /*
2 * Entropy Source Using Intel's rdrand instruction
3 * (C) 2012,2015 Jack Lloyd
4 * (C) 2015 Daniel Neus
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9 #include <botan/internal/rdrand.h>
10 #include <botan/rdrand_rng.h>
11 #include <botan/cpuid.h>
12 #include <botan/build.h>
13
14 namespace Botan {
15
16 size_t Intel_Rdrand::poll(RandomNumberGenerator& rng) {
17 if(CPUID::has_rdrand() && BOTAN_ENTROPY_INTEL_RNG_POLLS > 0)
18 {
19 RDRAND_RNG rdrand_rng;
20 secure_vector<uint8_t> buf(4 * BOTAN_ENTROPY_INTEL_RNG_POLLS);
21
22 rdrand_rng.randomize(buf.data(), buf.size());
23 rng.add_entropy(buf.data(), buf.size());
24 }
25
26 // RDRAND is used but not trusted
27 return 0;
28 }
29
30 }
Botan::RandomNumberGenerator::add_entropy
virtual void add_entropy(const uint8_t input[], size_t length)=0
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::RDRAND_RNG::randomize
void randomize(uint8_t out[], size_t out_len) override
Definition: rdrand_rng.cpp:66
Botan::RDRAND_RNG
Definition: rdrand_rng.h:15
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan
Definition: alg_id.cpp:13
Botan::Intel_Rdrand::poll
size_t poll(RandomNumberGenerator &rng) override
Definition: rdrand.cpp:16