Botan  2.4.0
Crypto and TLS for C++11
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 
13 namespace Botan {
14 
16  if(CPUID::has_rdrand() && BOTAN_ENTROPY_INTEL_RNG_POLLS > 0)
17  {
18  RDRAND_RNG rdrand_rng;
19  secure_vector<uint8_t> buf(4 * BOTAN_ENTROPY_INTEL_RNG_POLLS);
20 
21  rdrand_rng.randomize(buf.data(), buf.size());
22  rng.add_entropy(buf.data(), buf.size());
23  }
24 
25  // RDRAND is used but not trusted
26  return 0;
27  }
28 
29 }
virtual void add_entropy(const uint8_t input[], size_t length)=0
void randomize(uint8_t out[], size_t out_len) override
Definition: rdrand_rng.cpp:64
Definition: alg_id.cpp:13
size_t poll(RandomNumberGenerator &rng) override
Definition: rdrand.cpp:15
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88