From f3cb3edb512bdcab498d825886c3366c341b3f78 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 11 Dec 2016 15:28:38 -0500 Subject: 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. --- src/lib/mac/siphash/siphash.cpp | 24 ++++++++++++------------ src/lib/mac/siphash/siphash.h | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/lib/mac/siphash') diff --git a/src/lib/mac/siphash/siphash.cpp b/src/lib/mac/siphash/siphash.cpp index cb72f771c..c6ef68889 100644 --- a/src/lib/mac/siphash/siphash.cpp +++ b/src/lib/mac/siphash/siphash.cpp @@ -11,9 +11,9 @@ namespace Botan { namespace { -void SipRounds(u64bit M, secure_vector& V, size_t r) +void SipRounds(uint64_t M, secure_vector& V, size_t r) { - u64bit V0 = V[0], V1 = V[1], V2 = V[2], V3 = V[3]; + uint64_t V0 = V[0], V1 = V[1], V2 = V[2], V3 = V[3]; V3 ^= M; for(size_t i = 0; i != r; ++i) @@ -37,7 +37,7 @@ void SipRounds(u64bit M, secure_vector& V, size_t r) } -void SipHash::add_data(const byte input[], size_t length) +void SipHash::add_data(const uint8_t input[], size_t length) { m_words += length; @@ -45,7 +45,7 @@ void SipHash::add_data(const byte input[], size_t length) { while(length && m_mbuf_pos != 8) { - m_mbuf = (m_mbuf >> 8) | (static_cast(input[0]) << 56); + m_mbuf = (m_mbuf >> 8) | (static_cast(input[0]) << 56); ++m_mbuf_pos; ++input; length--; @@ -61,37 +61,37 @@ void SipHash::add_data(const byte input[], size_t length) while(length >= 8) { - SipRounds(load_le(input, 0), m_V, m_C); + SipRounds(load_le(input, 0), m_V, m_C); input += 8; length -= 8; } for(size_t i = 0; i != length; ++i) { - m_mbuf = (m_mbuf >> 8) | (static_cast(input[i]) << 56); + m_mbuf = (m_mbuf >> 8) | (static_cast(input[i]) << 56); m_mbuf_pos++; } } -void SipHash::final_result(byte mac[]) +void SipHash::final_result(uint8_t mac[]) { - m_mbuf = (m_mbuf >> (64-m_mbuf_pos*8)) | (static_cast(m_words) << 56); + m_mbuf = (m_mbuf >> (64-m_mbuf_pos*8)) | (static_cast(m_words) << 56); SipRounds(m_mbuf, m_V, m_C); m_V[2] ^= 0xFF; SipRounds(0, m_V, m_D); - const u64bit X = m_V[0] ^ m_V[1] ^ m_V[2] ^ m_V[3]; + const uint64_t X = m_V[0] ^ m_V[1] ^ m_V[2] ^ m_V[3]; store_le(X, mac); clear(); } -void SipHash::key_schedule(const byte key[], size_t) +void SipHash::key_schedule(const uint8_t key[], size_t) { - const u64bit K0 = load_le(key, 0); - const u64bit K1 = load_le(key, 1); + const uint64_t K0 = load_le(key, 0); + const uint64_t K1 = load_le(key, 1); m_V.resize(4); m_V[0] = K0 ^ 0x736F6D6570736575; diff --git a/src/lib/mac/siphash/siphash.h b/src/lib/mac/siphash/siphash.h index d774fe5e7..ebae6a91d 100644 --- a/src/lib/mac/siphash/siphash.h +++ b/src/lib/mac/siphash/siphash.h @@ -29,15 +29,15 @@ class BOTAN_DLL SipHash final : public MessageAuthenticationCode return Key_Length_Specification(16); } private: - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; - void key_schedule(const byte[], size_t) override; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; + void key_schedule(const uint8_t[], size_t) override; const size_t m_C, m_D; - secure_vector m_V; - u64bit m_mbuf = 0; + secure_vector m_V; + uint64_t m_mbuf = 0; size_t m_mbuf_pos = 0; - byte m_words = 0; + uint8_t m_words = 0; }; } -- cgit v1.2.3