aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-11-05 03:47:06 -0500
committerJack Lloyd <[email protected]>2020-11-06 11:31:22 -0500
commita55e4b22b6cbeeb30ca787d4ea4e3933ccccbdf1 (patch)
tree3d066440f30d30a46179caded3f1273d06a4dd95 /src/lib/rng
parent7c27982e27b953682554de3c4b22843e0e7461e7 (diff)
Remove deprecated headers, make more headers internal
Now modules default to internal headers instead of defaulting to public; making a new public API should be a visible and intentional choice. Brings the public header count from over 300 to around 150. Also removes the deprecated tls_blocking interface
Diffstat (limited to 'src/lib/rng')
-rw-r--r--src/lib/rng/auto_rng/info.txt4
-rw-r--r--src/lib/rng/chacha_rng/info.txt4
-rw-r--r--src/lib/rng/hmac_drbg/info.txt4
-rw-r--r--src/lib/rng/info.txt4
-rw-r--r--src/lib/rng/processor_rng/info.txt4
-rw-r--r--src/lib/rng/processor_rng/processor_rng.cpp2
-rw-r--r--src/lib/rng/rdrand_rng/info.txt13
-rw-r--r--src/lib/rng/rdrand_rng/rdrand_rng.cpp67
-rw-r--r--src/lib/rng/rdrand_rng/rdrand_rng.h68
-rw-r--r--src/lib/rng/rng.cpp2
-rw-r--r--src/lib/rng/stateful_rng/info.txt4
-rw-r--r--src/lib/rng/stateful_rng/stateful_rng.cpp2
-rw-r--r--src/lib/rng/system_rng/info.txt4
-rw-r--r--src/lib/rng/system_rng/system_rng.cpp2
14 files changed, 32 insertions, 152 deletions
diff --git a/src/lib/rng/auto_rng/info.txt b/src/lib/rng/auto_rng/info.txt
index f1adcc800..18fb3cecb 100644
--- a/src/lib/rng/auto_rng/info.txt
+++ b/src/lib/rng/auto_rng/info.txt
@@ -6,3 +6,7 @@ AUTO_RNG -> 20161126
<requires>
hmac_drbg
</requires>
+
+<header:public>
+auto_rng.h
+</header:public>
diff --git a/src/lib/rng/chacha_rng/info.txt b/src/lib/rng/chacha_rng/info.txt
index 3f51bf4d0..1c0654cd1 100644
--- a/src/lib/rng/chacha_rng/info.txt
+++ b/src/lib/rng/chacha_rng/info.txt
@@ -8,3 +8,7 @@ sha2_32
chacha
stateful_rng
</requires>
+
+<header:public>
+chacha_rng.h
+</header:public>
diff --git a/src/lib/rng/hmac_drbg/info.txt b/src/lib/rng/hmac_drbg/info.txt
index a8922bdf0..ea724702c 100644
--- a/src/lib/rng/hmac_drbg/info.txt
+++ b/src/lib/rng/hmac_drbg/info.txt
@@ -6,3 +6,7 @@ HMAC_DRBG -> 20140319
hmac
stateful_rng
</requires>
+
+<header:public>
+hmac_drbg.h
+</header:public>
diff --git a/src/lib/rng/info.txt b/src/lib/rng/info.txt
index 4c88ba382..bce39fb6b 100644
--- a/src/lib/rng/info.txt
+++ b/src/lib/rng/info.txt
@@ -1,3 +1,7 @@
<requires>
entropy
</requires>
+
+<header:public>
+rng.h
+</header:public>
diff --git a/src/lib/rng/processor_rng/info.txt b/src/lib/rng/processor_rng/info.txt
index ec1c7faf3..5be5117fd 100644
--- a/src/lib/rng/processor_rng/info.txt
+++ b/src/lib/rng/processor_rng/info.txt
@@ -14,3 +14,7 @@ x86_32
x86_64
ppc64
</arch>
+
+<header:public>
+processor_rng.h
+</header:public>
diff --git a/src/lib/rng/processor_rng/processor_rng.cpp b/src/lib/rng/processor_rng/processor_rng.cpp
index ca52d05e6..6e9aa8680 100644
--- a/src/lib/rng/processor_rng/processor_rng.cpp
+++ b/src/lib/rng/processor_rng/processor_rng.cpp
@@ -5,7 +5,7 @@
*/
#include <botan/processor_rng.h>
-#include <botan/loadstor.h>
+#include <botan/internal/loadstor.h>
#include <botan/cpuid.h>
#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY) && !defined(BOTAN_USE_GCC_INLINE_ASM)
diff --git a/src/lib/rng/rdrand_rng/info.txt b/src/lib/rng/rdrand_rng/info.txt
deleted file mode 100644
index 5cc616dea..000000000
--- a/src/lib/rng/rdrand_rng/info.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-<defines>
-RDRAND_RNG -> 20160619
-</defines>
-
-<requires>
-processor_rng
-</requires>
-
-# Avoid building RDRAND_RNG on non-x86 since that would be confusing
-<arch>
-x86_32
-x86_64
-</arch>
diff --git a/src/lib/rng/rdrand_rng/rdrand_rng.cpp b/src/lib/rng/rdrand_rng/rdrand_rng.cpp
deleted file mode 100644
index fade5a199..000000000
--- a/src/lib/rng/rdrand_rng/rdrand_rng.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* RDRAND RNG
-* (C) 2016,2019 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/rdrand_rng.h>
-#include <botan/processor_rng.h>
-#include <botan/loadstor.h>
-
-namespace Botan {
-
-void RDRAND_RNG::randomize(uint8_t out[], size_t out_len)
- {
- Processor_RNG rng;
- rng.randomize(out, out_len);
- }
-
-RDRAND_RNG::RDRAND_RNG()
- {
- // Will throw if instruction is not available
- Processor_RNG rng;
- }
-
-//static
-bool RDRAND_RNG::available()
- {
- return Processor_RNG::available();
- }
-
-//static
-uint32_t RDRAND_RNG::rdrand()
- {
- Processor_RNG rng;
-
- for(;;)
- {
- try
- {
- uint8_t out[4];
- rng.randomize(out, 4);
- return load_le<uint32_t>(out, 0);
- }
- catch(PRNG_Unseeded&) {}
- }
- }
-
-//static
-uint32_t RDRAND_RNG::rdrand_status(bool& ok)
- {
- ok = false;
- Processor_RNG rng;
-
- try
- {
- uint8_t out[4];
- rng.randomize(out, 4);
- ok = true;
- return load_le<uint32_t>(out, 0);
- }
- catch(PRNG_Unseeded&) {}
-
- return 0;
- }
-
-}
diff --git a/src/lib/rng/rdrand_rng/rdrand_rng.h b/src/lib/rng/rdrand_rng/rdrand_rng.h
deleted file mode 100644
index 1b6977eac..000000000
--- a/src/lib/rng/rdrand_rng/rdrand_rng.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* RDRAND RNG
-* (C) 2016,2019 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_RNG_RDRAND_H_
-#define BOTAN_RNG_RDRAND_H_
-
-#include <botan/rng.h>
-
-namespace Botan {
-
-class BOTAN_PUBLIC_API(2,0) RDRAND_RNG final : public Hardware_RNG
- {
- public:
- /**
- * Constructor will throw if CPU does not have RDRAND bit set
- */
- BOTAN_DEPRECATED("Use Processor_RNG instead") RDRAND_RNG();
-
- /**
- * Return true if RDRAND is available on the current processor
- */
- static bool available();
-
- bool accepts_input() const override { return false; }
-
- /**
- * Uses RDRAND to produce output
- */
- void randomize(uint8_t out[], size_t out_len) override;
-
- /*
- * No way to provide entropy to RDRAND generator, so add_entropy is ignored
- */
- void add_entropy(const uint8_t[], size_t) override
- { /* no op */ }
-
- /*
- * No way to reseed RDRAND generator, so reseed is ignored
- */
- size_t reseed(Entropy_Sources&, size_t, std::chrono::milliseconds) override
- { return 0; /* no op */ }
-
- std::string name() const override { return "RDRAND"; }
-
- bool is_seeded() const override { return true; }
-
- /**
- * On correctly working hardware, RDRAND is always supposed to
- * succeed within a set number of retries. If after that many
- * retries RDRAND has still not suceeded, sets ok = false and
- * returns 0.
- */
- static uint32_t BOTAN_DEPRECATED("Use Processor_RNG::randomize") rdrand_status(bool& ok);
-
- /*
- * Calls RDRAND until it succeeds, this could hypothetically
- * loop forever on broken hardware.
- */
- static uint32_t BOTAN_DEPRECATED("Use Processor_RNG::randomize") rdrand();
- };
-
-}
-
-#endif
diff --git a/src/lib/rng/rng.cpp b/src/lib/rng/rng.cpp
index 743f7c7aa..85022e5db 100644
--- a/src/lib/rng/rng.cpp
+++ b/src/lib/rng/rng.cpp
@@ -6,7 +6,7 @@
#include <botan/rng.h>
#include <botan/entropy_src.h>
-#include <botan/loadstor.h>
+#include <botan/internal/loadstor.h>
#include <botan/internal/os_utils.h>
#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
diff --git a/src/lib/rng/stateful_rng/info.txt b/src/lib/rng/stateful_rng/info.txt
index edc2d9169..3892b92fd 100644
--- a/src/lib/rng/stateful_rng/info.txt
+++ b/src/lib/rng/stateful_rng/info.txt
@@ -1,3 +1,7 @@
<defines>
STATEFUL_RNG -> 20160819
</defines>
+
+<header:public>
+stateful_rng.h
+</header:public>
diff --git a/src/lib/rng/stateful_rng/stateful_rng.cpp b/src/lib/rng/stateful_rng/stateful_rng.cpp
index c7b3484ee..e9ab21212 100644
--- a/src/lib/rng/stateful_rng/stateful_rng.cpp
+++ b/src/lib/rng/stateful_rng/stateful_rng.cpp
@@ -6,7 +6,7 @@
#include <botan/stateful_rng.h>
#include <botan/internal/os_utils.h>
-#include <botan/loadstor.h>
+#include <botan/internal/loadstor.h>
#if defined(BOTAN_HAS_SYSTEM_RNG)
#include <botan/system_rng.h>
diff --git a/src/lib/rng/system_rng/info.txt b/src/lib/rng/system_rng/info.txt
index e77328b82..64962aa5b 100644
--- a/src/lib/rng/system_rng/info.txt
+++ b/src/lib/rng/system_rng/info.txt
@@ -16,3 +16,7 @@ uwp -> bcrypt
<requires>
rtlgenrandom?dyn_load
</requires>
+
+<header:public>
+system_rng.h
+</header:public>
diff --git a/src/lib/rng/system_rng/system_rng.cpp b/src/lib/rng/system_rng/system_rng.cpp
index 0c5641e60..2a783fd14 100644
--- a/src/lib/rng/system_rng/system_rng.cpp
+++ b/src/lib/rng/system_rng/system_rng.cpp
@@ -8,7 +8,7 @@
#include <botan/system_rng.h>
#if defined(BOTAN_TARGET_OS_HAS_RTLGENRANDOM)
- #include <botan/dyn_load.h>
+ #include <botan/internal/dyn_load.h>
#define NOMINMAX 1
#define _WINSOCKAPI_ // stop windows.h including winsock.h
#include <windows.h>