aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp')
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp b/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp
new file mode 100644
index 0000000000..6a5b0f7c44
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp
@@ -0,0 +1,29 @@
+/*
+* Entropy Source Using Intel's rdrand instruction
+* (C) 2012,2015 Jack Lloyd
+* (C) 2015 Daniel Neus
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/rdrand.h>
+#include <botan/rdrand_rng.h>
+#include <botan/cpuid.h>
+
+namespace Botan {
+
+size_t Intel_Rdrand::poll(RandomNumberGenerator& rng) {
+ if(CPUID::has_rdrand() && BOTAN_ENTROPY_INTEL_RNG_POLLS > 0)
+ {
+ RDRAND_RNG rdrand_rng;
+ secure_vector<uint8_t> buf(4 * BOTAN_ENTROPY_INTEL_RNG_POLLS);
+
+ rdrand_rng.randomize(buf.data(), buf.size());
+ rng.add_entropy(buf.data(), buf.size());
+ }
+
+ // RDRAND is used but not trusted
+ return 0;
+ }
+
+}