diff options
Diffstat (limited to 'src/lib/rng')
-rw-r--r-- | src/lib/rng/auto_rng/auto_rng.cpp | 8 | ||||
-rw-r--r-- | src/lib/rng/auto_rng/auto_rng.h | 8 | ||||
-rw-r--r-- | src/lib/rng/hmac_drbg/hmac_drbg.cpp | 12 | ||||
-rw-r--r-- | src/lib/rng/hmac_drbg/hmac_drbg.h | 12 | ||||
-rw-r--r-- | src/lib/rng/rng.cpp | 10 | ||||
-rw-r--r-- | src/lib/rng/rng.h | 32 | ||||
-rw-r--r-- | src/lib/rng/stateful_rng/stateful_rng.cpp | 6 | ||||
-rw-r--r-- | src/lib/rng/stateful_rng/stateful_rng.h | 4 |
8 files changed, 46 insertions, 46 deletions
diff --git a/src/lib/rng/auto_rng/auto_rng.cpp b/src/lib/rng/auto_rng/auto_rng.cpp index e631604c9..ec439e7cf 100644 --- a/src/lib/rng/auto_rng/auto_rng.cpp +++ b/src/lib/rng/auto_rng/auto_rng.cpp @@ -86,7 +86,7 @@ std::string AutoSeeded_RNG::name() const return m_rng->name(); } -void AutoSeeded_RNG::add_entropy(const byte in[], size_t len) +void AutoSeeded_RNG::add_entropy(const uint8_t in[], size_t len) { m_rng->add_entropy(in, len); } @@ -98,13 +98,13 @@ size_t AutoSeeded_RNG::reseed(Entropy_Sources& srcs, return m_rng->reseed(srcs, poll_bits, poll_timeout); } -void AutoSeeded_RNG::randomize(byte output[], size_t output_len) +void AutoSeeded_RNG::randomize(uint8_t output[], size_t output_len) { randomize_with_ts_input(output, output_len); } -void AutoSeeded_RNG::randomize_with_input(byte output[], size_t output_len, - const byte ad[], size_t ad_len) +void AutoSeeded_RNG::randomize_with_input(uint8_t output[], size_t output_len, + const uint8_t ad[], size_t ad_len) { m_rng->randomize_with_input(output, output_len, ad, ad_len); } diff --git a/src/lib/rng/auto_rng/auto_rng.h b/src/lib/rng/auto_rng/auto_rng.h index 9ae9b9c38..f634b8ff2 100644 --- a/src/lib/rng/auto_rng/auto_rng.h +++ b/src/lib/rng/auto_rng/auto_rng.h @@ -20,10 +20,10 @@ class Stateful_RNG; class BOTAN_DLL AutoSeeded_RNG final : public RandomNumberGenerator { public: - void randomize(byte out[], size_t len) override; + void randomize(uint8_t out[], size_t len) override; - void randomize_with_input(byte output[], size_t output_len, - const byte input[], size_t input_len) override; + void randomize_with_input(uint8_t output[], size_t output_len, + const uint8_t input[], size_t input_len) override; bool is_seeded() const override; @@ -36,7 +36,7 @@ class BOTAN_DLL AutoSeeded_RNG final : public RandomNumberGenerator size_t poll_bits = BOTAN_RNG_RESEED_POLL_BITS, std::chrono::milliseconds poll_timeout = BOTAN_RNG_RESEED_DEFAULT_TIMEOUT) override; - void add_entropy(const byte in[], size_t len) override; + void add_entropy(const uint8_t in[], size_t len) override; std::string name() const override; diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.cpp b/src/lib/rng/hmac_drbg/hmac_drbg.cpp index 2e056e726..e47d49628 100644 --- a/src/lib/rng/hmac_drbg/hmac_drbg.cpp +++ b/src/lib/rng/hmac_drbg/hmac_drbg.cpp @@ -81,7 +81,7 @@ void HMAC_DRBG::clear() m_V.resize(m_mac->output_length()); for(size_t i = 0; i != m_V.size(); ++i) m_V[i] = 0x01; - m_mac->set_key(std::vector<byte>(m_mac->output_length(), 0x00)); + m_mac->set_key(std::vector<uint8_t>(m_mac->output_length(), 0x00)); } std::string HMAC_DRBG::name() const @@ -89,7 +89,7 @@ std::string HMAC_DRBG::name() const return "HMAC_DRBG(" + m_mac->name() + ")"; } -void HMAC_DRBG::randomize(byte output[], size_t output_len) +void HMAC_DRBG::randomize(uint8_t output[], size_t output_len) { randomize_with_input(output, output_len, nullptr, 0); } @@ -98,8 +98,8 @@ void HMAC_DRBG::randomize(byte output[], size_t output_len) * HMAC_DRBG generation * See NIST SP800-90A section 10.1.2.5 */ -void HMAC_DRBG::randomize_with_input(byte output[], size_t output_len, - const byte input[], size_t input_len) +void HMAC_DRBG::randomize_with_input(uint8_t output[], size_t output_len, + const uint8_t input[], size_t input_len) { while(output_len > 0) { @@ -133,7 +133,7 @@ void HMAC_DRBG::randomize_with_input(byte output[], size_t output_len, * Reset V and the mac key with new values * See NIST SP800-90A section 10.1.2.2 */ -void HMAC_DRBG::update(const byte input[], size_t input_len) +void HMAC_DRBG::update(const uint8_t input[], size_t input_len) { m_mac->update(m_V); m_mac->update(0x00); @@ -155,7 +155,7 @@ void HMAC_DRBG::update(const byte input[], size_t input_len) } } -void HMAC_DRBG::add_entropy(const byte input[], size_t input_len) +void HMAC_DRBG::add_entropy(const uint8_t input[], size_t input_len) { update(input, input_len); } diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h index 189edbcdf..1c95cb304 100644 --- a/src/lib/rng/hmac_drbg/hmac_drbg.h +++ b/src/lib/rng/hmac_drbg/hmac_drbg.h @@ -134,20 +134,20 @@ class BOTAN_DLL HMAC_DRBG final : public Stateful_RNG void clear() override; - void randomize(byte output[], size_t output_len) override; + void randomize(uint8_t output[], size_t output_len) override; - void randomize_with_input(byte output[], size_t output_len, - const byte input[], size_t input_len) override; + void randomize_with_input(uint8_t output[], size_t output_len, + const uint8_t input[], size_t input_len) override; - void add_entropy(const byte input[], size_t input_len) override; + void add_entropy(const uint8_t input[], size_t input_len) override; size_t security_level() const override; private: - void update(const byte input[], size_t input_len); + void update(const uint8_t input[], size_t input_len); std::unique_ptr<MessageAuthenticationCode> m_mac; - secure_vector<byte> m_V; + secure_vector<uint8_t> m_V; const size_t m_max_number_of_bytes_per_request; }; diff --git a/src/lib/rng/rng.cpp b/src/lib/rng/rng.cpp index a2dd3d3a4..4551ffe83 100644 --- a/src/lib/rng/rng.cpp +++ b/src/lib/rng/rng.cpp @@ -14,21 +14,21 @@ namespace Botan { -void RandomNumberGenerator::randomize_with_ts_input(byte output[], size_t output_len) +void RandomNumberGenerator::randomize_with_ts_input(uint8_t output[], size_t output_len) { /* Form additional input which is provided to the PRNG implementation to paramaterize the KDF output. */ - byte additional_input[16] = { 0 }; + uint8_t additional_input[16] = { 0 }; store_le(OS::get_system_timestamp_ns(), additional_input); store_le(OS::get_processor_timestamp(), additional_input + 8); randomize_with_input(output, output_len, additional_input, sizeof(additional_input)); } -void RandomNumberGenerator::randomize_with_input(byte output[], size_t output_len, - const byte input[], size_t input_len) +void RandomNumberGenerator::randomize_with_input(uint8_t output[], size_t output_len, + const uint8_t input[], size_t input_len) { this->add_entropy(input, input_len); this->randomize(output, output_len); @@ -43,7 +43,7 @@ size_t RandomNumberGenerator::reseed(Entropy_Sources& srcs, void RandomNumberGenerator::reseed_from_rng(RandomNumberGenerator& rng, size_t poll_bits) { - secure_vector<byte> buf(poll_bits / 8); + secure_vector<uint8_t> buf(poll_bits / 8); rng.randomize(buf.data(), buf.size()); this->add_entropy(buf.data(), buf.size()); } diff --git a/src/lib/rng/rng.h b/src/lib/rng/rng.h index acd131b18..d8d3c855f 100644 --- a/src/lib/rng/rng.h +++ b/src/lib/rng/rng.h @@ -40,7 +40,7 @@ class BOTAN_DLL RandomNumberGenerator * @param output the byte array to hold the random output. * @param length the length of the byte array output in bytes. */ - virtual void randomize(byte output[], size_t length) = 0; + virtual void randomize(uint8_t output[], size_t length) = 0; /** * Incorporate some additional data into the RNG state. For @@ -52,7 +52,7 @@ class BOTAN_DLL RandomNumberGenerator * @param input a byte array containg the entropy to be added * @param length the length of the byte array in */ - virtual void add_entropy(const byte input[], size_t length) = 0; + virtual void add_entropy(const uint8_t input[], size_t length) = 0; /** * Incorporate some additional data into the RNG state. @@ -77,8 +77,8 @@ class BOTAN_DLL RandomNumberGenerator * @param input entropy buffer to incorporate * @param input_len size of the input buffer in bytes */ - virtual void randomize_with_input(byte output[], size_t output_len, - const byte input[], size_t input_len); + virtual void randomize_with_input(uint8_t output[], size_t output_len, + const uint8_t input[], size_t input_len); /** * This calls `randomize_with_input` using some timestamps as extra input. @@ -89,7 +89,7 @@ class BOTAN_DLL RandomNumberGenerator * both of the duplicated RNG states later incorporate a timestamp (and the * timestamps don't themselves repeat), their outputs will diverge. */ - virtual void randomize_with_ts_input(byte output[], size_t output_len); + virtual void randomize_with_ts_input(uint8_t output[], size_t output_len); /** * @return the name of this RNG type @@ -130,9 +130,9 @@ class BOTAN_DLL RandomNumberGenerator * @param bytes number of bytes in the result * @return randomized vector of length bytes */ - secure_vector<byte> random_vec(size_t bytes) + secure_vector<uint8_t> random_vec(size_t bytes) { - secure_vector<byte> output(bytes); + secure_vector<uint8_t> output(bytes); this->randomize(output.data(), output.size()); return output; } @@ -141,19 +141,19 @@ class BOTAN_DLL RandomNumberGenerator * Return a random byte * @return random byte */ - byte next_byte() + uint8_t next_byte() { - byte b; + uint8_t b; this->randomize(&b, 1); return b; } /** - * @return a random byte that is not the zero byte + * @return a random byte that is greater than zero */ - byte next_nonzero_byte() + uint8_t next_nonzero_byte() { - byte b = this->next_byte(); + uint8_t b = this->next_byte(); while(b == 0) b = this->next_byte(); return b; @@ -191,12 +191,12 @@ class BOTAN_DLL Null_RNG final : public RandomNumberGenerator void clear() override {} - void randomize(byte[], size_t) override + void randomize(uint8_t[], size_t) override { throw PRNG_Unseeded("Null_RNG called"); } - void add_entropy(const byte[], size_t) override {} + void add_entropy(const uint8_t[], size_t) override {} std::string name() const override { return "Null_RNG"; } }; @@ -210,7 +210,7 @@ class BOTAN_DLL Null_RNG final : public RandomNumberGenerator class BOTAN_DLL Serialized_RNG final : public RandomNumberGenerator { public: - void randomize(byte out[], size_t len) override + void randomize(uint8_t out[], size_t len) override { lock_guard_type<mutex_type> lock(m_mutex); m_rng->randomize(out, len); @@ -242,7 +242,7 @@ class BOTAN_DLL Serialized_RNG final : public RandomNumberGenerator return m_rng->reseed(src, poll_bits, poll_timeout); } - void add_entropy(const byte in[], size_t len) override + void add_entropy(const uint8_t in[], size_t len) override { lock_guard_type<mutex_type> lock(m_mutex); m_rng->add_entropy(in, len); diff --git a/src/lib/rng/stateful_rng/stateful_rng.cpp b/src/lib/rng/stateful_rng/stateful_rng.cpp index 1349c1208..81fe89cca 100644 --- a/src/lib/rng/stateful_rng/stateful_rng.cpp +++ b/src/lib/rng/stateful_rng/stateful_rng.cpp @@ -26,7 +26,7 @@ bool Stateful_RNG::is_seeded() const return m_reseed_counter > 0; } -void Stateful_RNG::initialize_with(const byte input[], size_t len) +void Stateful_RNG::initialize_with(const uint8_t input[], size_t len) { add_entropy(input, len); @@ -36,9 +36,9 @@ void Stateful_RNG::initialize_with(const byte input[], size_t len) } } -void Stateful_RNG::randomize_with_ts_input(byte output[], size_t output_len) +void Stateful_RNG::randomize_with_ts_input(uint8_t output[], size_t output_len) { - byte additional_input[24] = { 0 }; + uint8_t additional_input[24] = { 0 }; store_le(OS::get_system_timestamp_ns(), additional_input); store_le(OS::get_processor_timestamp(), additional_input + 8); store_le(m_last_pid, additional_input + 16); diff --git a/src/lib/rng/stateful_rng/stateful_rng.h b/src/lib/rng/stateful_rng/stateful_rng.h index e2b45f8fa..982747e01 100644 --- a/src/lib/rng/stateful_rng/stateful_rng.h +++ b/src/lib/rng/stateful_rng/stateful_rng.h @@ -71,7 +71,7 @@ class BOTAN_DLL Stateful_RNG : public RandomNumberGenerator * of the length of the input or the current seeded state of * the RNG. */ - void initialize_with(const byte input[], size_t length); + void initialize_with(const uint8_t input[], size_t length); bool is_seeded() const override final; @@ -87,7 +87,7 @@ class BOTAN_DLL Stateful_RNG : public RandomNumberGenerator * Overrides default implementation and also includes the current * process ID and the reseed counter. */ - void randomize_with_ts_input(byte output[], size_t output_len) override final; + void randomize_with_ts_input(uint8_t output[], size_t output_len) override final; /** * Poll provided sources for up to poll_bits bits of entropy |