diff options
author | Jack Lloyd <[email protected]> | 2016-12-11 15:28:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-18 16:48:24 -0500 |
commit | f3cb3edb512bdcab498d825886c3366c341b3f78 (patch) | |
tree | 645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/rng/rng.h | |
parent | c1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff) |
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency,
eg make_u32bit becomes make_uint32. The old typedefs remain for now
since probably lots of application code uses them.
Diffstat (limited to 'src/lib/rng/rng.h')
-rw-r--r-- | src/lib/rng/rng.h | 32 |
1 files changed, 16 insertions, 16 deletions
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); |