aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/botan/src/lib/entropy
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/entropy')
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp30
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.h28
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/info.txt16
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.cpp123
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.h37
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/dev_random/info.txt11
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/entropy_src.h87
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/entropy_srcs.cpp198
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.cpp35
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.h28
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/getentropy/info.txt11
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/info.txt7
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/proc_walk/info.txt11
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.cpp154
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.h45
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdrand/info.txt11
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.cpp29
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.h28
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdseed/info.txt16
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.cpp48
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.h28
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.cpp121
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.h27
-rw-r--r--src/libs/3rdparty/botan/src/lib/entropy/win32_stats/info.txt19
24 files changed, 1148 insertions, 0 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp b/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp
new file mode 100644
index 0000000000..1e36136155
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp
@@ -0,0 +1,30 @@
+/*
+* Darwin SecRandomCopyBytes EntropySource
+* (C) 2015 Daniel Seither (Kullo GmbH)
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/darwin_secrandom.h>
+#include <Security/Security.h>
+#include <Security/SecRandom.h>
+
+namespace Botan {
+
+/**
+* Gather entropy from SecRandomCopyBytes
+*/
+size_t Darwin_SecRandom::poll(RandomNumberGenerator& rng)
+ {
+ secure_vector<uint8_t> buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);
+
+ if(0 == SecRandomCopyBytes(kSecRandomDefault, buf.size(), buf.data()))
+ {
+ rng.add_entropy(buf.data(), buf.size());
+ return buf.size() * 8;
+ }
+
+ return 0;
+ }
+
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.h b/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.h
new file mode 100644
index 0000000000..83b4da4f50
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/darwin_secrandom.h
@@ -0,0 +1,28 @@
+/*
+* Darwin SecRandomCopyBytes EntropySource
+* (C) 2015 Daniel Seither (Kullo GmbH)
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_DARWIN_SECRANDOM_H_
+#define BOTAN_ENTROPY_SRC_DARWIN_SECRANDOM_H_
+
+#include <botan/entropy_src.h>
+
+namespace Botan {
+
+/**
+* Entropy source using SecRandomCopyBytes from Darwin's Security.framework
+*/
+class Darwin_SecRandom final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "darwin_secrandom"; }
+
+ size_t poll(RandomNumberGenerator& rng) override;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/info.txt
new file mode 100644
index 0000000000..c1943a04a4
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/darwin_secrandom/info.txt
@@ -0,0 +1,16 @@
+<defines>
+ENTROPY_SRC_DARWIN_SECRANDOM -> 20150925
+</defines>
+
+<header:internal>
+darwin_secrandom.h
+</header:internal>
+
+<os_features>
+security_framework
+</os_features>
+
+<frameworks>
+darwin -> Security
+ios -> Security
+</frameworks>
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.cpp b/src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.cpp
new file mode 100644
index 0000000000..56552228a3
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.cpp
@@ -0,0 +1,123 @@
+/*
+* Reader of /dev/random and company
+* (C) 1999-2009,2013 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/dev_random.h>
+#include <botan/exceptn.h>
+
+#include <sys/types.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+
+namespace Botan {
+
+/**
+Device_EntropySource constructor
+Open a file descriptor to each (available) device in fsnames
+*/
+Device_EntropySource::Device_EntropySource(const std::vector<std::string>& fsnames)
+ {
+#ifndef O_NONBLOCK
+ #define O_NONBLOCK 0
+#endif
+
+#ifndef O_NOCTTY
+ #define O_NOCTTY 0
+#endif
+
+ const int flags = O_RDONLY | O_NONBLOCK | O_NOCTTY;
+
+ m_max_fd = 0;
+
+ for(auto fsname : fsnames)
+ {
+ int fd = ::open(fsname.c_str(), flags);
+
+ if(fd < 0)
+ {
+ /*
+ ENOENT or EACCES is normal as some of the named devices may not exist
+ on this system. But any other errno value probably indicates
+ either a bug in the application or file descriptor exhaustion.
+ */
+ if(errno != ENOENT && errno != EACCES)
+ throw Exception("Opening OS RNG device failed with errno " +
+ std::to_string(errno));
+ }
+ else
+ {
+ if(fd > FD_SETSIZE)
+ {
+ ::close(fd);
+ throw Exception("Open of OS RNG succeeded but fd is too large for fd_set");
+ }
+
+ m_dev_fds.push_back(fd);
+ m_max_fd = std::max(m_max_fd, fd);
+ }
+ }
+ }
+
+/**
+Device_EntropySource destructor: close all open devices
+*/
+Device_EntropySource::~Device_EntropySource()
+ {
+ for(int fd : m_dev_fds)
+ {
+ // ignoring return value here, can't throw in destructor anyway
+ ::close(fd);
+ }
+ }
+
+/**
+* Gather entropy from a RNG device
+*/
+size_t Device_EntropySource::poll(RandomNumberGenerator& rng)
+ {
+ size_t bits = 0;
+
+ if(m_dev_fds.size() > 0)
+ {
+ fd_set read_set;
+ FD_ZERO(&read_set);
+
+ for(int dev_fd : m_dev_fds)
+ {
+ FD_SET(dev_fd, &read_set);
+ }
+
+ secure_vector<uint8_t> io_buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);
+
+ struct ::timeval timeout;
+ timeout.tv_sec = (BOTAN_SYSTEM_RNG_POLL_TIMEOUT_MS / 1000);
+ timeout.tv_usec = (BOTAN_SYSTEM_RNG_POLL_TIMEOUT_MS % 1000) * 1000;
+
+ if(::select(m_max_fd + 1, &read_set, nullptr, nullptr, &timeout) > 0)
+ {
+ for(int dev_fd : m_dev_fds)
+ {
+ if(FD_ISSET(dev_fd, &read_set))
+ {
+ const ssize_t got = ::read(dev_fd, io_buf.data(), io_buf.size());
+
+ if(got > 0)
+ {
+ rng.add_entropy(io_buf.data(), static_cast<size_t>(got));
+ bits += got * 8;
+ }
+ }
+ }
+ }
+ }
+
+ return bits;
+ }
+
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.h b/src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.h
new file mode 100644
index 0000000000..6195f85648
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/dev_random/dev_random.h
@@ -0,0 +1,37 @@
+/*
+* /dev/random EntropySource
+* (C) 1999-2009 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_DEVICE_H_
+#define BOTAN_ENTROPY_SRC_DEVICE_H_
+
+#include <botan/entropy_src.h>
+#include <vector>
+#include <string>
+
+namespace Botan {
+
+/**
+* Entropy source reading from kernel devices like /dev/random
+*/
+class Device_EntropySource final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "dev_random"; }
+
+ size_t poll(RandomNumberGenerator& rng) override;
+
+ explicit Device_EntropySource(const std::vector<std::string>& fsnames);
+
+ ~Device_EntropySource();
+ private:
+ std::vector<int> m_dev_fds;
+ int m_max_fd;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/dev_random/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/dev_random/info.txt
new file mode 100644
index 0000000000..3872411f30
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/dev_random/info.txt
@@ -0,0 +1,11 @@
+<defines>
+ENTROPY_SRC_DEV_RANDOM -> 20131128
+</defines>
+
+<header:internal>
+dev_random.h
+</header:internal>
+
+<os_features>
+dev_random,posix1
+</os_features>
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/entropy_src.h b/src/libs/3rdparty/botan/src/lib/entropy/entropy_src.h
new file mode 100644
index 0000000000..56e5bd53e5
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/entropy_src.h
@@ -0,0 +1,87 @@
+/*
+* EntropySource
+* (C) 2008,2009,2014,2015,2016 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_H_
+#define BOTAN_ENTROPY_H_
+
+#include <botan/secmem.h>
+#include <botan/rng.h>
+#include <string>
+#include <chrono>
+#include <memory>
+#include <vector>
+
+namespace Botan {
+
+class RandomNumberGenerator;
+
+/**
+* Abstract interface to a source of entropy
+*/
+class BOTAN_PUBLIC_API(2,0) Entropy_Source
+ {
+ public:
+ /**
+ * Return a new entropy source of a particular type, or null
+ * Each entropy source may require substantial resources (eg, a file handle
+ * or socket instance), so try to share them among multiple RNGs, or just
+ * use the preconfigured global list accessed by Entropy_Sources::global_sources()
+ */
+ static std::unique_ptr<Entropy_Source> create(const std::string& type);
+
+ /**
+ * @return name identifying this entropy source
+ */
+ virtual std::string name() const = 0;
+
+ /**
+ * Perform an entropy gathering poll
+ * @param rng will be provided with entropy via calls to add_entropy
+ * @return conservative estimate of actual entropy added to rng during poll
+ */
+ virtual size_t poll(RandomNumberGenerator& rng) = 0;
+
+ Entropy_Source() = default;
+ Entropy_Source(const Entropy_Source& other) = delete;
+ Entropy_Source(Entropy_Source&& other) = delete;
+ Entropy_Source& operator=(const Entropy_Source& other) = delete;
+
+ virtual ~Entropy_Source() = default;
+ };
+
+class BOTAN_PUBLIC_API(2,0) Entropy_Sources final
+ {
+ public:
+ static Entropy_Sources& global_sources();
+
+ void add_source(std::unique_ptr<Entropy_Source> src);
+
+ std::vector<std::string> enabled_sources() const;
+
+ size_t poll(RandomNumberGenerator& rng,
+ size_t bits,
+ std::chrono::milliseconds timeout);
+
+ /**
+ * Poll just a single named source. Ordinally only used for testing
+ */
+ size_t poll_just(RandomNumberGenerator& rng, const std::string& src);
+
+ Entropy_Sources() = default;
+ explicit Entropy_Sources(const std::vector<std::string>& sources);
+
+ Entropy_Sources(const Entropy_Sources& other) = delete;
+ Entropy_Sources(Entropy_Sources&& other) = delete;
+ Entropy_Sources& operator=(const Entropy_Sources& other) = delete;
+
+ private:
+ std::vector<std::unique_ptr<Entropy_Source>> m_srcs;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/entropy_srcs.cpp b/src/libs/3rdparty/botan/src/lib/entropy/entropy_srcs.cpp
new file mode 100644
index 0000000000..c04b3b5b26
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/entropy_srcs.cpp
@@ -0,0 +1,198 @@
+/*
+* Entropy Source Polling
+* (C) 2008-2010,2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/entropy_src.h>
+#include <botan/rng.h>
+
+#if defined(BOTAN_HAS_SYSTEM_RNG)
+ #include <botan/system_rng.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND)
+ #include <botan/internal/rdrand.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_RDSEED)
+ #include <botan/internal/rdseed.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM)
+ #include <botan/internal/dev_random.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32)
+ #include <botan/internal/es_win32.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER)
+ #include <botan/internal/proc_walk.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_DARWIN_SECRANDOM)
+ #include <botan/internal/darwin_secrandom.h>
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_GETENTROPY)
+ #include <botan/internal/getentropy.h>
+#endif
+
+namespace Botan {
+
+#if defined(BOTAN_HAS_SYSTEM_RNG)
+
+namespace {
+
+class System_RNG_EntropySource final : public Entropy_Source
+ {
+ public:
+ size_t poll(RandomNumberGenerator& rng) override
+ {
+ const size_t poll_bits = BOTAN_RNG_RESEED_POLL_BITS;
+ rng.reseed_from_rng(system_rng(), poll_bits);
+ return poll_bits;
+ }
+
+ std::string name() const override { return "system_rng"; }
+ };
+
+}
+
+#endif
+
+std::unique_ptr<Entropy_Source> Entropy_Source::create(const std::string& name)
+ {
+#if defined(BOTAN_HAS_SYSTEM_RNG)
+ if(name == "system_rng" || name == "win32_cryptoapi")
+ {
+ return std::unique_ptr<Entropy_Source>(new System_RNG_EntropySource);
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_RDRAND)
+ if(name == "rdrand")
+ {
+ return std::unique_ptr<Entropy_Source>(new Intel_Rdrand);
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_RDSEED)
+ if(name == "rdseed")
+ {
+ return std::unique_ptr<Entropy_Source>(new Intel_Rdseed);
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_DARWIN_SECRANDOM)
+ if(name == "darwin_secrandom")
+ {
+ return std::unique_ptr<Entropy_Source>(new Darwin_SecRandom);
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_GETENTROPY)
+ if(name == "getentropy")
+ {
+ return std::unique_ptr<Entropy_Source>(new Getentropy);
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM)
+ if(name == "dev_random")
+ {
+ return std::unique_ptr<Entropy_Source>(new Device_EntropySource(BOTAN_SYSTEM_RNG_POLL_DEVICES));
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_PROC_WALKER)
+ if(name == "proc_walk")
+ {
+ const std::string root_dir = BOTAN_ENTROPY_PROC_FS_PATH;
+ if(!root_dir.empty())
+ return std::unique_ptr<Entropy_Source>(new ProcWalking_EntropySource(root_dir));
+ }
+#endif
+
+#if defined(BOTAN_HAS_ENTROPY_SRC_WIN32)
+ if(name == "system_stats")
+ {
+ return std::unique_ptr<Entropy_Source>(new Win32_EntropySource);
+ }
+#endif
+
+ BOTAN_UNUSED(name);
+ return std::unique_ptr<Entropy_Source>();
+ }
+
+void Entropy_Sources::add_source(std::unique_ptr<Entropy_Source> src)
+ {
+ if(src.get())
+ {
+ m_srcs.push_back(std::move(src));
+ }
+ }
+
+std::vector<std::string> Entropy_Sources::enabled_sources() const
+ {
+ std::vector<std::string> sources;
+ for(size_t i = 0; i != m_srcs.size(); ++i)
+ {
+ sources.push_back(m_srcs[i]->name());
+ }
+ return sources;
+ }
+
+size_t Entropy_Sources::poll(RandomNumberGenerator& rng,
+ size_t poll_bits,
+ std::chrono::milliseconds timeout)
+ {
+ typedef std::chrono::system_clock clock;
+
+ auto deadline = clock::now() + timeout;
+
+ size_t bits_collected = 0;
+
+ for(size_t i = 0; i != m_srcs.size(); ++i)
+ {
+ bits_collected += m_srcs[i]->poll(rng);
+
+ if (bits_collected >= poll_bits || clock::now() > deadline)
+ break;
+ }
+
+ return bits_collected;
+ }
+
+size_t Entropy_Sources::poll_just(RandomNumberGenerator& rng, const std::string& the_src)
+ {
+ for(size_t i = 0; i != m_srcs.size(); ++i)
+ {
+ if(m_srcs[i]->name() == the_src)
+ {
+ return m_srcs[i]->poll(rng);
+ }
+ }
+
+ return 0;
+ }
+
+Entropy_Sources::Entropy_Sources(const std::vector<std::string>& sources)
+ {
+ for(auto&& src_name : sources)
+ {
+ add_source(Entropy_Source::create(src_name));
+ }
+ }
+
+Entropy_Sources& Entropy_Sources::global_sources()
+ {
+ static Entropy_Sources global_entropy_sources(BOTAN_ENTROPY_DEFAULT_SOURCES);
+
+ return global_entropy_sources;
+ }
+
+}
+
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.cpp b/src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.cpp
new file mode 100644
index 0000000000..15bd8abe87
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.cpp
@@ -0,0 +1,35 @@
+/*
+* System Call getentropy(2)
+* (C) 2017 Alexander Bluhm (genua GmbH)
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/getentropy.h>
+
+#if defined(BOTAN_TARGET_OS_IS_DARWIN)
+ #include <sys/random.h>
+#else
+ #include <unistd.h>
+#endif
+
+namespace Botan {
+
+/**
+* Gather 256 bytes entropy from getentropy(2). Note that maximum
+* buffer size is limited to 256 bytes. On OpenBSD this does neither
+* block nor fail.
+*/
+size_t Getentropy::poll(RandomNumberGenerator& rng)
+ {
+ secure_vector<uint8_t> buf(256);
+
+ if(::getentropy(buf.data(), buf.size()) == 0)
+ {
+ rng.add_entropy(buf.data(), buf.size());
+ return buf.size() * 8;
+ }
+
+ return 0;
+ }
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.h b/src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.h
new file mode 100644
index 0000000000..26783cf78a
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/getentropy/getentropy.h
@@ -0,0 +1,28 @@
+/*
+* Entropy Source Using OpenBSD getentropy(2) system call
+* (C) 2017 Alexander Bluhm (genua GmbH)
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_GETENTROPY_H_
+#define BOTAN_ENTROPY_SRC_GETENTROPY_H_
+
+#include <botan/entropy_src.h>
+
+namespace Botan {
+
+/**
+* Entropy source using the getentropy(2) system call first introduced in
+* OpenBSD 5.6 and added to Solaris 11.3.
+*/
+class Getentropy final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "getentropy"; }
+ size_t poll(RandomNumberGenerator& rng) override;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/getentropy/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/getentropy/info.txt
new file mode 100644
index 0000000000..886e57151f
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/getentropy/info.txt
@@ -0,0 +1,11 @@
+<defines>
+ENTROPY_SRC_GETENTROPY -> 20170327
+</defines>
+
+<header:internal>
+getentropy.h
+</header:internal>
+
+<os_features>
+getentropy
+</os_features>
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/info.txt
new file mode 100644
index 0000000000..57f1930b99
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/info.txt
@@ -0,0 +1,7 @@
+<defines>
+ENTROPY_SOURCE -> 20151120
+</defines>
+
+<requires>
+rng
+</requires>
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/info.txt
new file mode 100644
index 0000000000..2bba7e276b
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/info.txt
@@ -0,0 +1,11 @@
+<defines>
+ENTROPY_SRC_PROC_WALKER -> 20131128
+</defines>
+
+<header:internal>
+proc_walk.h
+</header:internal>
+
+<os_features>
+posix1,proc_fs
+</os_features>
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.cpp b/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.cpp
new file mode 100644
index 0000000000..d780cbf739
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.cpp
@@ -0,0 +1,154 @@
+/*
+* Entropy source based on reading files in /proc on the assumption
+* that a remote attacker will have difficulty guessing some of them.
+*
+* (C) 1999-2008,2012 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/proc_walk.h>
+#include <deque>
+
+#ifndef _POSIX_C_SOURCE
+ #define _POSIX_C_SOURCE 199309
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <fcntl.h>
+
+namespace Botan {
+
+namespace {
+
+class Directory_Walker final : public File_Descriptor_Source
+ {
+ public:
+ explicit Directory_Walker(const std::string& root) :
+ m_cur_dir(std::make_pair<DIR*, std::string>(nullptr, ""))
+ {
+ if(DIR* root_dir = ::opendir(root.c_str()))
+ m_cur_dir = std::make_pair(root_dir, root);
+ }
+
+ ~Directory_Walker()
+ {
+ if(m_cur_dir.first)
+ ::closedir(m_cur_dir.first);
+ }
+
+ int next_fd() override;
+ private:
+ std::pair<struct dirent*, std::string> get_next_dirent();
+
+ std::pair<DIR*, std::string> m_cur_dir;
+ std::deque<std::string> m_dirlist;
+ };
+
+std::pair<struct dirent*, std::string> Directory_Walker::get_next_dirent()
+ {
+ while(m_cur_dir.first)
+ {
+ if(struct dirent* dir = ::readdir(m_cur_dir.first))
+ return std::make_pair(dir, m_cur_dir.second);
+
+ ::closedir(m_cur_dir.first);
+ m_cur_dir = std::make_pair<DIR*, std::string>(nullptr, "");
+
+ while(!m_dirlist.empty() && !m_cur_dir.first)
+ {
+ const std::string next_dir_name = m_dirlist[0];
+ m_dirlist.pop_front();
+
+ if(DIR* next_dir = ::opendir(next_dir_name.c_str()))
+ m_cur_dir = std::make_pair(next_dir, next_dir_name);
+ }
+ }
+
+ return std::make_pair<struct dirent*, std::string>(nullptr, ""); // nothing left
+ }
+
+int Directory_Walker::next_fd()
+ {
+ while(true)
+ {
+ std::pair<struct dirent*, std::string> entry = get_next_dirent();
+
+ if(!entry.first)
+ break; // no more dirs
+
+ const std::string filename = entry.first->d_name;
+
+ if(filename == "." || filename == "..")
+ continue;
+
+ const std::string full_path = entry.second + "/" + filename;
+
+ struct stat stat_buf;
+ if(::lstat(full_path.c_str(), &stat_buf) == -1)
+ continue;
+
+ if(S_ISDIR(stat_buf.st_mode))
+ {
+ m_dirlist.push_back(full_path);
+ }
+ else if(S_ISREG(stat_buf.st_mode) && (stat_buf.st_mode & S_IROTH))
+ {
+ int fd = ::open(full_path.c_str(), O_RDONLY | O_NOCTTY);
+
+ if(fd >= 0)
+ return fd;
+ }
+ }
+
+ return -1;
+ }
+
+}
+
+size_t ProcWalking_EntropySource::poll(RandomNumberGenerator& rng)
+ {
+ const size_t MAX_FILES_READ_PER_POLL = 2048;
+
+ lock_guard_type<mutex_type> lock(m_mutex);
+
+ if(!m_dir)
+ m_dir.reset(new Directory_Walker(m_path));
+
+ m_buf.resize(4096);
+
+ size_t bits = 0;
+
+ for(size_t i = 0; i != MAX_FILES_READ_PER_POLL; ++i)
+ {
+ int fd = m_dir->next_fd();
+
+ // If we've exhaused this walk of the directory, halt the poll
+ if(fd == -1)
+ {
+ m_dir.reset();
+ break;
+ }
+
+ ssize_t got = ::read(fd, m_buf.data(), m_buf.size());
+ ::close(fd);
+
+ if(got > 0)
+ {
+ rng.add_entropy(m_buf.data(), static_cast<size_t>(got));
+
+ // Conservative estimate of 4 bits per file
+ bits += 4;
+ }
+
+ if(bits > 128)
+ break;
+ }
+
+ return bits;
+ }
+
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.h b/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.h
new file mode 100644
index 0000000000..4c5013d29c
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/proc_walk/proc_walk.h
@@ -0,0 +1,45 @@
+/*
+* File Tree Walking EntropySource
+* (C) 1999-2008 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_PROC_WALK_H_
+#define BOTAN_ENTROPY_SRC_PROC_WALK_H_
+
+#include <botan/entropy_src.h>
+#include <botan/mutex.h>
+
+namespace Botan {
+
+class File_Descriptor_Source
+ {
+ public:
+ virtual int next_fd() = 0;
+ virtual ~File_Descriptor_Source() = default;
+ };
+
+/**
+* File Tree Walking Entropy Source
+*/
+class ProcWalking_EntropySource final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "proc_walk"; }
+
+ size_t poll(RandomNumberGenerator& rng) override;
+
+ explicit ProcWalking_EntropySource(const std::string& root_dir) :
+ m_path(root_dir), m_dir(nullptr) {}
+
+ private:
+ const std::string m_path;
+ mutex_type m_mutex;
+ std::unique_ptr<File_Descriptor_Source> m_dir;
+ secure_vector<uint8_t> m_buf;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/rdrand/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/rdrand/info.txt
new file mode 100644
index 0000000000..6abe8765d3
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/rdrand/info.txt
@@ -0,0 +1,11 @@
+<defines>
+ENTROPY_SRC_RDRAND -> 20131128
+</defines>
+
+<requires>
+rdrand_rng
+</requires>
+
+<header:internal>
+rdrand.h
+</header:internal>
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;
+ }
+
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.h b/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.h
new file mode 100644
index 0000000000..6544fe57f9
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/rdrand/rdrand.h
@@ -0,0 +1,28 @@
+/*
+* Entropy Source Using Intel's rdrand instruction
+* (C) 2012 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_RDRAND_H_
+#define BOTAN_ENTROPY_SRC_RDRAND_H_
+
+#include <botan/entropy_src.h>
+
+namespace Botan {
+
+/**
+* Entropy source using the rdrand instruction first introduced on
+* Intel's Ivy Bridge architecture.
+*/
+class Intel_Rdrand final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "rdrand"; }
+ size_t poll(RandomNumberGenerator& rng) override;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/rdseed/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/rdseed/info.txt
new file mode 100644
index 0000000000..d4432e6c7f
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/rdseed/info.txt
@@ -0,0 +1,16 @@
+<defines>
+ENTROPY_SRC_RDSEED -> 20151218
+</defines>
+
+need_isa rdseed
+
+<header:internal>
+rdseed.h
+</header:internal>
+
+<cc>
+gcc
+clang
+icc
+msvc
+</cc>
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.cpp b/src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.cpp
new file mode 100644
index 0000000000..fbb8f921e7
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.cpp
@@ -0,0 +1,48 @@
+/*
+* Entropy Source Using Intel's rdseed instruction
+* (C) 2015 Jack Lloyd, Daniel Neus
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/rdseed.h>
+#include <botan/cpuid.h>
+
+#if !defined(BOTAN_USE_GCC_INLINE_ASM)
+ #include <immintrin.h>
+#endif
+
+namespace Botan {
+
+BOTAN_FUNC_ISA("rdseed")
+size_t Intel_Rdseed::poll(RandomNumberGenerator& rng) {
+ if(CPUID::has_rdseed())
+ {
+ for(size_t p = 0; p != BOTAN_ENTROPY_INTEL_RNG_POLLS; ++p)
+ {
+ for(size_t i = 0; i != BOTAN_ENTROPY_RDSEED_RETRIES; ++i)
+ {
+ uint32_t r = 0;
+
+#if defined(BOTAN_USE_GCC_INLINE_ASM)
+ int cf = 0;
+
+ // Encoding of rdseed %eax
+ asm(".byte 0x0F, 0xC7, 0xF8; adcl $0,%1" :
+ "=a" (r), "=r" (cf) : "0" (r), "1" (cf) : "cc");
+#else
+ int cf = _rdseed32_step(&r);
+#endif
+ if(1 == cf)
+ {
+ rng.add_entropy_T(r);
+ break;
+ }
+ }
+ }
+ }
+
+ return 0;
+ }
+
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.h b/src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.h
new file mode 100644
index 0000000000..da94bc0a10
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/rdseed/rdseed.h
@@ -0,0 +1,28 @@
+/*
+* Entropy Source Using Intel's rdseed instruction
+* (C) 2015 Jack Lloyd, Daniel Neus
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_RDSEED_H_
+#define BOTAN_ENTROPY_SRC_RDSEED_H_
+
+#include <botan/entropy_src.h>
+
+namespace Botan {
+
+/**
+* Entropy source using the rdseed instruction first introduced on
+* Intel's Broadwell architecture.
+*/
+class Intel_Rdseed final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "rdseed"; }
+ size_t poll(RandomNumberGenerator& rng) override;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.cpp b/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.cpp
new file mode 100644
index 0000000000..86d1f2cafb
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.cpp
@@ -0,0 +1,121 @@
+/*
+* Win32 EntropySource
+* (C) 1999-2009,2016 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/es_win32.h>
+
+#define NOMINMAX 1
+#define _WINSOCKAPI_ // stop windows.h including winsock.h
+#include <windows.h>
+#include <tlhelp32.h>
+
+namespace Botan {
+
+/**
+* Win32 poll using stats functions including Tooltip32
+*/
+size_t Win32_EntropySource::poll(RandomNumberGenerator& rng)
+ {
+ const size_t POLL_TARGET = 128;
+ const size_t EST_ENTROPY_HEAP_INFO = 4;
+ const size_t EST_ENTROPY_THREAD_INFO = 2;
+
+ /*
+ First query a bunch of basic statistical stuff
+ */
+ rng.add_entropy_T(::GetTickCount());
+ rng.add_entropy_T(::GetMessagePos());
+ rng.add_entropy_T(::GetMessageTime());
+ rng.add_entropy_T(::GetInputState());
+
+ rng.add_entropy_T(::GetCurrentProcessId());
+ rng.add_entropy_T(::GetCurrentThreadId());
+
+ SYSTEM_INFO sys_info;
+ ::GetSystemInfo(&sys_info);
+ rng.add_entropy_T(sys_info);
+
+ MEMORYSTATUSEX mem_info;
+ ::GlobalMemoryStatusEx(&mem_info);
+ rng.add_entropy_T(mem_info);
+
+ POINT point;
+ ::GetCursorPos(&point);
+ rng.add_entropy_T(point);
+
+ ::GetCaretPos(&point);
+ rng.add_entropy_T(point);
+
+ /*
+ Now use the Tooltip library to iterate through various objects on
+ the system, including processes, threads, and heap objects.
+ */
+
+ HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
+ size_t collected = 0;
+
+#define TOOLHELP32_ITER(DATA_TYPE, FUNC_FIRST, FUNC_NEXT) \
+ if(collected < POLL_TARGET) \
+ { \
+ DATA_TYPE info; \
+ info.dwSize = sizeof(DATA_TYPE); \
+ if(FUNC_FIRST(snapshot, &info)) \
+ { \
+ do \
+ { \
+ rng.add_entropy_T(info); \
+ collected += EST_ENTROPY_THREAD_INFO; \
+ if(collected >= POLL_TARGET) \
+ break; \
+ } while(FUNC_NEXT(snapshot, &info)); \
+ } \
+ }
+
+ TOOLHELP32_ITER(MODULEENTRY32, ::Module32First, ::Module32Next);
+ TOOLHELP32_ITER(PROCESSENTRY32, ::Process32First, ::Process32Next);
+ TOOLHELP32_ITER(THREADENTRY32, ::Thread32First, ::Thread32Next);
+
+#undef TOOLHELP32_ITER
+
+ if(collected < POLL_TARGET)
+ {
+ HEAPLIST32 heap_list;
+ heap_list.dwSize = sizeof(HEAPLIST32);
+
+ if(::Heap32ListFirst(snapshot, &heap_list))
+ {
+ do
+ {
+ rng.add_entropy_T(heap_list);
+
+ HEAPENTRY32 heap_entry;
+ heap_entry.dwSize = sizeof(HEAPENTRY32);
+ if(::Heap32First(&heap_entry,
+ heap_list.th32ProcessID,
+ heap_list.th32HeapID))
+ {
+ do
+ {
+ rng.add_entropy_T(heap_entry);
+ collected += EST_ENTROPY_HEAP_INFO;
+ if(collected >= POLL_TARGET)
+ break;
+ } while(::Heap32Next(&heap_entry));
+ }
+
+ if(collected >= POLL_TARGET)
+ break;
+
+ } while(::Heap32ListNext(snapshot, &heap_list));
+ }
+ }
+
+ ::CloseHandle(snapshot);
+
+ return collected;
+ }
+
+}
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.h b/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.h
new file mode 100644
index 0000000000..2b11ee0801
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/es_win32.h
@@ -0,0 +1,27 @@
+/*
+* Win32 EntropySource
+* (C) 1999-2009 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_WIN32_H_
+#define BOTAN_ENTROPY_SRC_WIN32_H_
+
+#include <botan/entropy_src.h>
+
+namespace Botan {
+
+/**
+* Win32 Entropy Source
+*/
+class Win32_EntropySource final : public Entropy_Source
+ {
+ public:
+ std::string name() const override { return "system_stats"; }
+ size_t poll(RandomNumberGenerator& rng) override;
+ };
+
+}
+
+#endif
diff --git a/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/info.txt b/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/info.txt
new file mode 100644
index 0000000000..3e3268183e
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/entropy/win32_stats/info.txt
@@ -0,0 +1,19 @@
+<defines>
+ENTROPY_SRC_WIN32 -> 20131128
+</defines>
+
+<warning>
+This module can cause false positives with antivirus systems
+</warning>
+
+<header:internal>
+es_win32.h
+</header:internal>
+
+<os_features>
+win32
+</os_features>
+
+<libs>
+windows -> user32.lib
+</libs>