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/base | |
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/base')
-rw-r--r-- | src/lib/base/buf_comp.h | 39 | ||||
-rw-r--r-- | src/lib/base/sym_algo.h | 6 | ||||
-rw-r--r-- | src/lib/base/symkey.cpp | 8 | ||||
-rw-r--r-- | src/lib/base/symkey.h | 16 |
4 files changed, 34 insertions, 35 deletions
diff --git a/src/lib/base/buf_comp.h b/src/lib/base/buf_comp.h index 264b16bd0..ca5ecd4ff 100644 --- a/src/lib/base/buf_comp.h +++ b/src/lib/base/buf_comp.h @@ -31,13 +31,13 @@ class BOTAN_DLL Buffered_Computation * @param in the input to process as a byte array * @param length of param in in bytes */ - void update(const byte in[], size_t length) { add_data(in, length); } + void update(const uint8_t in[], size_t length) { add_data(in, length); } /** * Add new input to process. * @param in the input to process as a secure_vector */ - void update(const secure_vector<byte>& in) + void update(const secure_vector<uint8_t>& in) { add_data(in.data(), in.size()); } @@ -46,7 +46,7 @@ class BOTAN_DLL Buffered_Computation * Add new input to process. * @param in the input to process as a std::vector */ - void update(const std::vector<byte>& in) + void update(const std::vector<uint8_t>& in) { add_data(in.data(), in.size()); } @@ -59,7 +59,7 @@ class BOTAN_DLL Buffered_Computation { for(size_t i = 0; i != sizeof(T); ++i) { - byte b = get_byte(i, in); + uint8_t b = get_byte(i, in); add_data(&b, 1); } } @@ -67,19 +67,18 @@ class BOTAN_DLL Buffered_Computation /** * Add new input to process. * @param str the input to process as a std::string. Will be interpreted - * as a byte array based on - * the strings encoding. + * as a byte array based on the strings encoding. */ void update(const std::string& str) { - add_data(reinterpret_cast<const byte*>(str.data()), str.size()); + add_data(reinterpret_cast<const uint8_t*>(str.data()), str.size()); } /** * Process a single byte. * @param in the byte to process */ - void update(byte in) { add_data(&in, 1); } + void update(uint8_t in) { add_data(&in, 1); } /** * Complete the computation and retrieve the @@ -87,29 +86,29 @@ class BOTAN_DLL Buffered_Computation * @param out The byte array to be filled with the result. * Must be of length output_length() */ - void final(byte out[]) { final_result(out); } + void final(uint8_t out[]) { final_result(out); } /** * Complete the computation and retrieve the * final result. * @return secure_vector holding the result */ - secure_vector<byte> final() + secure_vector<uint8_t> final() { - secure_vector<byte> output(output_length()); + secure_vector<uint8_t> output(output_length()); final_result(output.data()); return output; } - std::vector<byte> final_stdvec() + std::vector<uint8_t> final_stdvec() { - std::vector<byte> output(output_length()); + std::vector<uint8_t> output(output_length()); final_result(output.data()); return output; } template<typename Alloc> - void final(std::vector<byte, Alloc>& out) + void final(std::vector<uint8_t, Alloc>& out) { out.resize(output_length()); final_result(out.data()); @@ -122,7 +121,7 @@ class BOTAN_DLL Buffered_Computation * @param length the length of the byte array * @result the result of the call to final() */ - secure_vector<byte> process(const byte in[], size_t length) + secure_vector<uint8_t> process(const uint8_t in[], size_t length) { add_data(in, length); return final(); @@ -134,7 +133,7 @@ class BOTAN_DLL Buffered_Computation * @param in the input to process * @result the result of the call to final() */ - secure_vector<byte> process(const secure_vector<byte>& in) + secure_vector<uint8_t> process(const secure_vector<uint8_t>& in) { add_data(in.data(), in.size()); return final(); @@ -146,7 +145,7 @@ class BOTAN_DLL Buffered_Computation * @param in the input to process * @result the result of the call to final() */ - secure_vector<byte> process(const std::vector<byte>& in) + secure_vector<uint8_t> process(const std::vector<uint8_t>& in) { add_data(in.data(), in.size()); return final(); @@ -158,7 +157,7 @@ class BOTAN_DLL Buffered_Computation * @param in the input to process as a string * @result the result of the call to final() */ - secure_vector<byte> process(const std::string& in) + secure_vector<uint8_t> process(const std::string& in) { update(in); return final(); @@ -171,13 +170,13 @@ class BOTAN_DLL Buffered_Computation * @param input is an input buffer * @param length is the length of input in bytes */ - virtual void add_data(const byte input[], size_t length) = 0; + virtual void add_data(const uint8_t input[], size_t length) = 0; /** * Write the final output to out * @param out is an output buffer of output_length() */ - virtual void final_result(byte out[]) = 0; + virtual void final_result(uint8_t out[]) = 0; }; } diff --git a/src/lib/base/sym_algo.h b/src/lib/base/sym_algo.h index a3f301b37..b573beaef 100644 --- a/src/lib/base/sym_algo.h +++ b/src/lib/base/sym_algo.h @@ -69,7 +69,7 @@ class BOTAN_DLL SymmetricAlgorithm } template<typename Alloc> - void set_key(const std::vector<byte, Alloc>& key) + void set_key(const std::vector<uint8_t, Alloc>& key) { set_key(key.data(), key.size()); } @@ -79,7 +79,7 @@ class BOTAN_DLL SymmetricAlgorithm * @param key the to be set as a byte array. * @param length in bytes of key param */ - void set_key(const byte key[], size_t length) + void set_key(const uint8_t key[], size_t length) { if(!valid_keylength(length)) throw Invalid_Key_Length(name(), length); @@ -97,7 +97,7 @@ class BOTAN_DLL SymmetricAlgorithm * @param key the key * @param length of key */ - virtual void key_schedule(const byte key[], size_t length) = 0; + virtual void key_schedule(const uint8_t key[], size_t length) = 0; }; } diff --git a/src/lib/base/symkey.cpp b/src/lib/base/symkey.cpp index d5a02a45d..a012773ff 100644 --- a/src/lib/base/symkey.cpp +++ b/src/lib/base/symkey.cpp @@ -33,7 +33,7 @@ OctetString::OctetString(const std::string& hex_string) /* * Create an OctetString from a byte string */ -OctetString::OctetString(const byte in[], size_t n) +OctetString::OctetString(const uint8_t in[], size_t n) { m_data.assign(in, in + n); } @@ -43,7 +43,7 @@ OctetString::OctetString(const byte in[], size_t n) */ void OctetString::set_odd_parity() { - const byte ODD_PARITY[256] = { + const uint8_t ODD_PARITY[256] = { 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, 0x08, 0x08, 0x0B, 0x0B, 0x0D, 0x0D, 0x0E, 0x0E, 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16, 0x19, 0x19, 0x1A, 0x1A, 0x1C, 0x1C, 0x1F, 0x1F, 0x20, 0x20, 0x23, 0x23, @@ -110,7 +110,7 @@ bool operator!=(const OctetString& s1, const OctetString& s2) */ OctetString operator+(const OctetString& k1, const OctetString& k2) { - secure_vector<byte> out; + secure_vector<uint8_t> out; out += k1.bits_of(); out += k2.bits_of(); return OctetString(out); @@ -121,7 +121,7 @@ OctetString operator+(const OctetString& k1, const OctetString& k2) */ OctetString operator^(const OctetString& k1, const OctetString& k2) { - secure_vector<byte> out(std::max(k1.length(), k2.length())); + secure_vector<uint8_t> out(std::max(k1.length(), k2.length())); copy_mem(out.data(), k1.begin(), k1.length()); xor_buf(out.data(), k2.begin(), k2.length()); diff --git a/src/lib/base/symkey.h b/src/lib/base/symkey.h index c780e5239..dc523f82e 100644 --- a/src/lib/base/symkey.h +++ b/src/lib/base/symkey.h @@ -26,19 +26,19 @@ class BOTAN_DLL OctetString size_t size() const { return m_data.size(); } /** - * @return this object as a secure_vector<byte> + * @return this object as a secure_vector<uint8_t> */ - secure_vector<byte> bits_of() const { return m_data; } + secure_vector<uint8_t> bits_of() const { return m_data; } /** * @return start of this string */ - const byte* begin() const { return m_data.data(); } + const uint8_t* begin() const { return m_data.data(); } /** * @return end of this string */ - const byte* end() const { return begin() + m_data.size(); } + const uint8_t* end() const { return begin() + m_data.size(); } /** * @return this encoded as hex @@ -75,22 +75,22 @@ class BOTAN_DLL OctetString * @param in is an array * @param len is the length of in in bytes */ - OctetString(const byte in[], size_t len); + OctetString(const uint8_t in[], size_t len); /** * Create a new OctetString * @param in a bytestring */ - OctetString(const secure_vector<byte>& in) : m_data(in) {} + OctetString(const secure_vector<uint8_t>& in) : m_data(in) {} /** * Create a new OctetString * @param in a bytestring */ - OctetString(const std::vector<byte>& in) : m_data(in.begin(), in.end()) {} + OctetString(const std::vector<uint8_t>& in) : m_data(in.begin(), in.end()) {} private: - secure_vector<byte> m_data; + secure_vector<uint8_t> m_data; }; /** |