diff options
Diffstat (limited to 'src/lib/hash')
43 files changed, 365 insertions, 365 deletions
diff --git a/src/lib/hash/blake2/blake2b.cpp b/src/lib/hash/blake2/blake2b.cpp index 928f344d7..b478af106 100644 --- a/src/lib/hash/blake2/blake2b.cpp +++ b/src/lib/hash/blake2/blake2b.cpp @@ -16,14 +16,14 @@ namespace Botan { namespace { -const u64bit blake2b_IV[BLAKE2B_IVU64COUNT] = { +const uint64_t blake2b_IV[BLAKE2B_IVU64COUNT] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL }; -const u64bit blake2b_sigma[12][16] = { +const uint64_t blake2b_sigma[12][16] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } , { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } , @@ -57,17 +57,17 @@ Blake2b::Blake2b(size_t output_bits) : void Blake2b::state_init() { std::copy(std::begin(blake2b_IV), std::end(blake2b_IV), m_H.begin()); - m_H[0] ^= 0x01010000 ^ static_cast<byte>(output_length()); + m_H[0] ^= 0x01010000 ^ static_cast<uint8_t>(output_length()); m_T[0] = m_T[1] = 0; m_F[0] = m_F[1] = 0; } void Blake2b::compress(bool lastblock) { - u64bit m[16]; - u64bit v[16]; - u64bit* const H = m_H.data(); - const byte* const block = m_buffer.data(); + uint64_t m[16]; + uint64_t v[16]; + uint64_t* const H = m_H.data(); + const uint8_t* const block = m_buffer.data(); if(lastblock) { @@ -76,7 +76,7 @@ void Blake2b::compress(bool lastblock) for(int i = 0; i < 16; i++) { - m[i] = load_le<u64bit>(block, i); + m[i] = load_le<uint64_t>(block, i); } for(int i = 0; i < 8; i++) @@ -93,13 +93,13 @@ void Blake2b::compress(bool lastblock) #define G(r, i, a, b, c, d) \ do { \ a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \ - d = rotate_right<u64bit>(d ^ a, 32); \ + d = rotate_right<uint64_t>(d ^ a, 32); \ c = c + d; \ - b = rotate_right<u64bit>(b ^ c, 24); \ + b = rotate_right<uint64_t>(b ^ c, 24); \ a = a + b + m[blake2b_sigma[r][2 * i + 1]]; \ - d = rotate_right<u64bit>(d ^ a, 16); \ + d = rotate_right<uint64_t>(d ^ a, 16); \ c = c + d; \ - b = rotate_right<u64bit>(b ^ c, 63); \ + b = rotate_right<uint64_t>(b ^ c, 63); \ } while(0) #define ROUND(r) \ @@ -136,7 +136,7 @@ void Blake2b::compress(bool lastblock) #undef ROUND } -void Blake2b::increment_counter(const u64bit inc) +void Blake2b::increment_counter(const uint64_t inc) { m_T[0] += inc; if(m_T[0] < inc) @@ -145,14 +145,14 @@ void Blake2b::increment_counter(const u64bit inc) } } -void Blake2b::add_data(const byte input[], size_t length) +void Blake2b::add_data(const uint8_t input[], size_t length) { if(!input || length == 0) { return; } - byte* const buffer = m_buffer.data(); + uint8_t* const buffer = m_buffer.data(); while(length > 0) { @@ -175,22 +175,22 @@ void Blake2b::add_data(const byte input[], size_t length) } } -void Blake2b::final_result(byte output[]) +void Blake2b::final_result(uint8_t output[]) { if(!output) { return; } - byte* const buffer = m_buffer.data(); - const u64bit* const H = static_cast<const u64bit*>(m_H.data()); - u16bit outlen = static_cast<u16bit>(output_length()); + uint8_t* const buffer = m_buffer.data(); + const uint64_t* const H = static_cast<const uint64_t*>(m_H.data()); + uint16_t outlen = static_cast<uint16_t>(output_length()); std::memset(buffer + m_buflen, 0, BLAKE2B_BLOCKBYTES - m_buflen); increment_counter(m_buflen); compress(true); - for (u16bit i = 0; i < outlen; i++) + for (uint16_t i = 0; i < outlen; i++) { output[i] = (H[i >> 3] >> (8 * (i & 7))) & 0xFF; } diff --git a/src/lib/hash/blake2/blake2b.h b/src/lib/hash/blake2/blake2b.h index 343f276b5..473352174 100644 --- a/src/lib/hash/blake2/blake2b.h +++ b/src/lib/hash/blake2/blake2b.h @@ -39,21 +39,21 @@ class BOTAN_DLL Blake2b final : public HashFunction void clear() override; private: - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; inline void state_init(); - inline void increment_counter(const u64bit inc); + inline void increment_counter(const uint64_t inc); void compress(bool lastblock = false); size_t m_output_bits; - secure_vector<byte> m_buffer; + secure_vector<uint8_t> m_buffer; size_t m_buflen; - secure_vector<u64bit> m_H; - u64bit m_T[2]; - u64bit m_F[2]; + secure_vector<uint64_t> m_H; + uint64_t m_T[2]; + uint64_t m_F[2]; }; } diff --git a/src/lib/hash/checksum/adler32/adler32.cpp b/src/lib/hash/checksum/adler32/adler32.cpp index 304c664dd..b7f6356c4 100644 --- a/src/lib/hash/checksum/adler32/adler32.cpp +++ b/src/lib/hash/checksum/adler32/adler32.cpp @@ -12,11 +12,11 @@ namespace Botan { namespace { -void adler32_update(const byte input[], size_t length, - u16bit& S1, u16bit& S2) +void adler32_update(const uint8_t input[], size_t length, + uint16_t& S1, uint16_t& S2) { - u32bit S1x = S1; - u32bit S2x = S2; + uint32_t S1x = S1; + uint32_t S2x = S2; while(length >= 16) { @@ -55,7 +55,7 @@ void adler32_update(const byte input[], size_t length, /* * Update an Adler32 Checksum */ -void Adler32::add_data(const byte input[], size_t length) +void Adler32::add_data(const uint8_t input[], size_t length) { const size_t PROCESS_AMOUNT = 5552; @@ -72,7 +72,7 @@ void Adler32::add_data(const byte input[], size_t length) /* * Finalize an Adler32 Checksum */ -void Adler32::final_result(byte output[]) +void Adler32::final_result(uint8_t output[]) { store_be(output, m_S2, m_S1); clear(); diff --git a/src/lib/hash/checksum/adler32/adler32.h b/src/lib/hash/checksum/adler32/adler32.h index 73df6134a..eaf57c656 100644 --- a/src/lib/hash/checksum/adler32/adler32.h +++ b/src/lib/hash/checksum/adler32/adler32.h @@ -27,9 +27,9 @@ class BOTAN_DLL Adler32 final : public HashFunction Adler32() { clear(); } ~Adler32() { clear(); } private: - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; - u16bit m_S1, m_S2; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; + uint16_t m_S1, m_S2; }; } diff --git a/src/lib/hash/checksum/crc24/crc24.cpp b/src/lib/hash/checksum/crc24/crc24.cpp index 6f1eea453..923433d7e 100644 --- a/src/lib/hash/checksum/crc24/crc24.cpp +++ b/src/lib/hash/checksum/crc24/crc24.cpp @@ -13,9 +13,9 @@ namespace Botan { /* * Update a CRC24 Checksum */ -void CRC24::add_data(const byte input[], size_t length) +void CRC24::add_data(const uint8_t input[], size_t length) { - const u32bit TABLE[256] = { + const uint32_t TABLE[256] = { 0x00000000, 0x00864CFB, 0x008AD50D, 0x000C99F6, 0x0093E6E1, 0x0015AA1A, 0x001933EC, 0x009F7F17, 0x00A18139, 0x0027CDC2, 0x002B5434, 0x00AD18CF, 0x003267D8, 0x00B42B23, 0x00B8B2D5, 0x003EFE2E, 0x00C54E89, 0x00430272, @@ -60,7 +60,7 @@ void CRC24::add_data(const byte input[], size_t length) 0x00FA48FA, 0x007C0401, 0x0042FA2F, 0x00C4B6D4, 0x00C82F22, 0x004E63D9, 0x00D11CCE, 0x00575035, 0x005BC9C3, 0x00DD8538 }; - u32bit tmp = m_crc; + uint32_t tmp = m_crc; while(length >= 16) { tmp = TABLE[((tmp >> 16) ^ input[ 0]) & 0xFF] ^ (tmp << 8); @@ -92,7 +92,7 @@ void CRC24::add_data(const byte input[], size_t length) /* * Finalize a CRC24 Checksum */ -void CRC24::final_result(byte output[]) +void CRC24::final_result(uint8_t output[]) { for(size_t i = 0; i != 3; ++i) output[i] = get_byte(i+1, m_crc); diff --git a/src/lib/hash/checksum/crc24/crc24.h b/src/lib/hash/checksum/crc24/crc24.h index f80ee1c2a..95977bc48 100644 --- a/src/lib/hash/checksum/crc24/crc24.h +++ b/src/lib/hash/checksum/crc24/crc24.h @@ -27,9 +27,9 @@ class BOTAN_DLL CRC24 final : public HashFunction CRC24() { clear(); } ~CRC24() { clear(); } private: - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; - u32bit m_crc; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; + uint32_t m_crc; }; } diff --git a/src/lib/hash/checksum/crc32/crc32.cpp b/src/lib/hash/checksum/crc32/crc32.cpp index ca8c87c5f..1bbc35ac8 100644 --- a/src/lib/hash/checksum/crc32/crc32.cpp +++ b/src/lib/hash/checksum/crc32/crc32.cpp @@ -13,9 +13,9 @@ namespace Botan { /* * Update a CRC32 Checksum */ -void CRC32::add_data(const byte input[], size_t length) +void CRC32::add_data(const uint8_t input[], size_t length) { - const u32bit TABLE[256] = { + const uint32_t TABLE[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, @@ -60,7 +60,7 @@ void CRC32::add_data(const byte input[], size_t length) 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; - u32bit tmp = m_crc; + uint32_t tmp = m_crc; while(length >= 16) { tmp = TABLE[(tmp ^ input[ 0]) & 0xFF] ^ (tmp >> 8); @@ -92,7 +92,7 @@ void CRC32::add_data(const byte input[], size_t length) /* * Finalize a CRC32 Checksum */ -void CRC32::final_result(byte output[]) +void CRC32::final_result(uint8_t output[]) { m_crc ^= 0xFFFFFFFF; store_be(m_crc, output); diff --git a/src/lib/hash/checksum/crc32/crc32.h b/src/lib/hash/checksum/crc32/crc32.h index 987f34608..fd9db1b3e 100644 --- a/src/lib/hash/checksum/crc32/crc32.h +++ b/src/lib/hash/checksum/crc32/crc32.h @@ -27,9 +27,9 @@ class BOTAN_DLL CRC32 final : public HashFunction CRC32() { clear(); } ~CRC32() { clear(); } private: - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; - u32bit m_crc; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; + uint32_t m_crc; }; } diff --git a/src/lib/hash/comb4p/comb4p.cpp b/src/lib/hash/comb4p/comb4p.cpp index 4659ace77..ece8c9051 100644 --- a/src/lib/hash/comb4p/comb4p.cpp +++ b/src/lib/hash/comb4p/comb4p.cpp @@ -12,9 +12,9 @@ namespace Botan { namespace { -void comb4p_round(secure_vector<byte>& out, - const secure_vector<byte>& in, - byte round_no, +void comb4p_round(secure_vector<uint8_t>& out, + const secure_vector<uint8_t>& in, + uint8_t round_no, HashFunction& h1, HashFunction& h2) { @@ -24,7 +24,7 @@ void comb4p_round(secure_vector<byte>& out, h1.update(in.data(), in.size()); h2.update(in.data(), in.size()); - secure_vector<byte> h_buf = h1.final(); + secure_vector<uint8_t> h_buf = h1.final(); xor_buf(out.data(), h_buf.data(), std::min(out.size(), h_buf.size())); h_buf = h2.final(); @@ -69,16 +69,16 @@ void Comb4P::clear() m_hash2->update(0); } -void Comb4P::add_data(const byte input[], size_t length) +void Comb4P::add_data(const uint8_t input[], size_t length) { m_hash1->update(input, length); m_hash2->update(input, length); } -void Comb4P::final_result(byte out[]) +void Comb4P::final_result(uint8_t out[]) { - secure_vector<byte> h1 = m_hash1->final(); - secure_vector<byte> h2 = m_hash2->final(); + secure_vector<uint8_t> h1 = m_hash1->final(); + secure_vector<uint8_t> h2 = m_hash2->final(); // First round xor_buf(h1.data(), h2.data(), std::min(h1.size(), h2.size())); diff --git a/src/lib/hash/comb4p/comb4p.h b/src/lib/hash/comb4p/comb4p.h index cb78914e7..a578b56c8 100644 --- a/src/lib/hash/comb4p/comb4p.h +++ b/src/lib/hash/comb4p/comb4p.h @@ -44,8 +44,8 @@ class BOTAN_DLL Comb4P final : public HashFunction void clear() override; private: - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; std::unique_ptr<HashFunction> m_hash1, m_hash2; }; diff --git a/src/lib/hash/gost_3411/gost_3411.cpp b/src/lib/hash/gost_3411/gost_3411.cpp index 17c590a5c..62028e496 100644 --- a/src/lib/hash/gost_3411/gost_3411.cpp +++ b/src/lib/hash/gost_3411/gost_3411.cpp @@ -34,7 +34,7 @@ void GOST_34_11::clear() /** * Hash additional inputs */ -void GOST_34_11::add_data(const byte input[], size_t length) +void GOST_34_11::add_data(const uint8_t input[], size_t length) { m_count += length; @@ -64,26 +64,26 @@ void GOST_34_11::add_data(const byte input[], size_t length) /** * The GOST 34.11 compression function */ -void GOST_34_11::compress_n(const byte input[], size_t blocks) +void GOST_34_11::compress_n(const uint8_t input[], size_t blocks) { for(size_t i = 0; i != blocks; ++i) { - for(u16bit j = 0, carry = 0; j != 32; ++j) + for(uint16_t j = 0, carry = 0; j != 32; ++j) { - u16bit s = m_sum[j] + input[32*i+j] + carry; + uint16_t s = m_sum[j] + input[32*i+j] + carry; carry = get_byte(0, s); m_sum[j] = get_byte(1, s); } - byte S[32] = { 0 }; + uint8_t S[32] = { 0 }; - u64bit U[4], V[4]; + uint64_t U[4], V[4]; load_be(U, m_hash.data(), 4); load_be(V, input + 32*i, 4); for(size_t j = 0; j != 4; ++j) { - byte key[32] = { 0 }; + uint8_t key[32] = { 0 }; // P transformation for(size_t k = 0; k != 4; ++k) @@ -97,7 +97,7 @@ void GOST_34_11::compress_n(const byte input[], size_t blocks) break; // A(x) - u64bit A_U = U[0]; + uint64_t A_U = U[0]; U[0] = U[1]; U[1] = U[2]; U[2] = U[3]; @@ -112,15 +112,15 @@ void GOST_34_11::compress_n(const byte input[], size_t blocks) } // A(A(x)) - u64bit AA_V_1 = V[0] ^ V[1]; - u64bit AA_V_2 = V[1] ^ V[2]; + uint64_t AA_V_1 = V[0] ^ V[1]; + uint64_t AA_V_2 = V[1] ^ V[2]; V[0] = V[2]; V[1] = V[3]; V[2] = AA_V_1; V[3] = AA_V_2; } - byte S2[32] = { 0 }; + uint8_t S2[32] = { 0 }; // 12 rounds of psi S2[ 0] = S[24]; @@ -214,7 +214,7 @@ void GOST_34_11::compress_n(const byte input[], size_t blocks) /** * Produce the final GOST 34.11 output */ -void GOST_34_11::final_result(byte out[]) +void GOST_34_11::final_result(uint8_t out[]) { if(m_position) { @@ -222,11 +222,11 @@ void GOST_34_11::final_result(byte out[]) compress_n(m_buffer.data(), 1); } - secure_vector<byte> length_buf(32); - const u64bit bit_count = m_count * 8; + secure_vector<uint8_t> length_buf(32); + const uint64_t bit_count = m_count * 8; store_le(bit_count, length_buf.data()); - secure_vector<byte> sum_buf = m_sum; + secure_vector<uint8_t> sum_buf = m_sum; compress_n(length_buf.data(), 1); compress_n(sum_buf.data(), 1); diff --git a/src/lib/hash/gost_3411/gost_3411.h b/src/lib/hash/gost_3411/gost_3411.h index 16f6a4954..e18ab56fa 100644 --- a/src/lib/hash/gost_3411/gost_3411.h +++ b/src/lib/hash/gost_3411/gost_3411.h @@ -28,15 +28,15 @@ class BOTAN_DLL GOST_34_11 final : public HashFunction GOST_34_11(); private: - void compress_n(const byte input[], size_t blocks); + void compress_n(const uint8_t input[], size_t blocks); - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; GOST_28147_89 m_cipher; - secure_vector<byte> m_buffer, m_sum, m_hash; + secure_vector<uint8_t> m_buffer, m_sum, m_hash; size_t m_position; - u64bit m_count; + uint64_t m_count; }; } diff --git a/src/lib/hash/keccak/keccak.cpp b/src/lib/hash/keccak/keccak.cpp index e0c67131b..1d2747ff2 100644 --- a/src/lib/hash/keccak/keccak.cpp +++ b/src/lib/hash/keccak/keccak.cpp @@ -42,14 +42,14 @@ void Keccak_1600::clear() m_S_pos = 0; } -void Keccak_1600::add_data(const byte input[], size_t length) +void Keccak_1600::add_data(const uint8_t input[], size_t length) { m_S_pos = SHA_3::absorb(m_bitrate, m_S, m_S_pos, input, length); } -void Keccak_1600::final_result(byte output[]) +void Keccak_1600::final_result(uint8_t output[]) { - std::vector<byte> padding(m_bitrate / 8 - m_S_pos); + std::vector<uint8_t> padding(m_bitrate / 8 - m_S_pos); padding[0] = 0x01; padding[padding.size()-1] |= 0x80; diff --git a/src/lib/hash/keccak/keccak.h b/src/lib/hash/keccak/keccak.h index ac50d4c52..a2c14c65a 100644 --- a/src/lib/hash/keccak/keccak.h +++ b/src/lib/hash/keccak/keccak.h @@ -35,11 +35,11 @@ class BOTAN_DLL Keccak_1600 final : public HashFunction void clear() override; private: - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; size_t m_output_bits, m_bitrate; - secure_vector<u64bit> m_S; + secure_vector<uint64_t> m_S; size_t m_S_pos; }; diff --git a/src/lib/hash/md4/md4.cpp b/src/lib/hash/md4/md4.cpp index d22f2d1ac..014ba8c2c 100644 --- a/src/lib/hash/md4/md4.cpp +++ b/src/lib/hash/md4/md4.cpp @@ -14,7 +14,7 @@ namespace { /* * MD4 FF Function */ -inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S) +inline void FF(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t M, uint8_t S) { A += (D ^ (B & (C ^ D))) + M; A = rotate_left(A, S); @@ -23,7 +23,7 @@ inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S) /* * MD4 GG Function */ -inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S) +inline void GG(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t M, uint8_t S) { A += ((B & C) | (D & (B | C))) + M + 0x5A827999; A = rotate_left(A, S); @@ -32,7 +32,7 @@ inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S) /* * MD4 HH Function */ -inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S) +inline void HH(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t M, uint8_t S) { A += (B ^ C ^ D) + M + 0x6ED9EBA1; A = rotate_left(A, S); @@ -43,9 +43,9 @@ inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit M, byte S) /* * MD4 Compression Function */ -void MD4::compress_n(const byte input[], size_t blocks) +void MD4::compress_n(const uint8_t input[], size_t blocks) { - u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3]; + uint32_t A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3]; for(size_t i = 0; i != blocks; ++i) { @@ -90,7 +90,7 @@ void MD4::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void MD4::copy_out(byte output[]) +void MD4::copy_out(uint8_t output[]) { copy_out_vec_le(output, output_length(), m_digest); } diff --git a/src/lib/hash/md4/md4.h b/src/lib/hash/md4/md4.h index 8b7ab5d70..ebd0bdedd 100644 --- a/src/lib/hash/md4/md4.h +++ b/src/lib/hash/md4/md4.h @@ -27,19 +27,19 @@ class BOTAN_DLL MD4 final : public MDx_HashFunction MD4() : MDx_HashFunction(64, false, true), m_M(16), m_digest(4) { clear(); } protected: - void compress_n(const byte input[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t input[], size_t blocks) override; + void copy_out(uint8_t[]) override; private: /** * The message buffer */ - secure_vector<u32bit> m_M; + secure_vector<uint32_t> m_M; /** * The digest value */ - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; }; } diff --git a/src/lib/hash/md5/md5.cpp b/src/lib/hash/md5/md5.cpp index 439dbde7b..0612ba956 100644 --- a/src/lib/hash/md5/md5.cpp +++ b/src/lib/hash/md5/md5.cpp @@ -14,8 +14,8 @@ namespace { /* * MD5 FF Function */ -inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, - byte S, u32bit magic) +inline void FF(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg, + uint8_t S, uint32_t magic) { A += (D ^ (B & (C ^ D))) + msg + magic; A = rotate_left(A, S) + B; @@ -24,8 +24,8 @@ inline void FF(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, /* * MD5 GG Function */ -inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, - byte S, u32bit magic) +inline void GG(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg, + uint8_t S, uint32_t magic) { A += (C ^ (D & (B ^ C))) + msg + magic; A = rotate_left(A, S) + B; @@ -34,8 +34,8 @@ inline void GG(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, /* * MD5 HH Function */ -inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, - byte S, u32bit magic) +inline void HH(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg, + uint8_t S, uint32_t magic) { A += (B ^ C ^ D) + msg + magic; A = rotate_left(A, S) + B; @@ -44,8 +44,8 @@ inline void HH(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, /* * MD5 II Function */ -inline void II(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, - byte S, u32bit magic) +inline void II(uint32_t& A, uint32_t B, uint32_t C, uint32_t D, uint32_t msg, + uint8_t S, uint32_t magic) { A += (C ^ (B | ~D)) + msg + magic; A = rotate_left(A, S) + B; @@ -56,9 +56,9 @@ inline void II(u32bit& A, u32bit B, u32bit C, u32bit D, u32bit msg, /* * MD5 Compression Function */ -void MD5::compress_n(const byte input[], size_t blocks) +void MD5::compress_n(const uint8_t input[], size_t blocks) { - u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3]; + uint32_t A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3]; for(size_t i = 0; i != blocks; ++i) { @@ -112,7 +112,7 @@ void MD5::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void MD5::copy_out(byte output[]) +void MD5::copy_out(uint8_t output[]) { copy_out_vec_le(output, output_length(), m_digest); } diff --git a/src/lib/hash/md5/md5.h b/src/lib/hash/md5/md5.h index bbeffee50..13a423594 100644 --- a/src/lib/hash/md5/md5.h +++ b/src/lib/hash/md5/md5.h @@ -27,19 +27,19 @@ class BOTAN_DLL MD5 final : public MDx_HashFunction MD5() : MDx_HashFunction(64, false, true), m_M(16), m_digest(4) { clear(); } protected: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; private: /** * The message buffer */ - secure_vector<u32bit> m_M; + secure_vector<uint32_t> m_M; /** * The digest value */ - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; }; } diff --git a/src/lib/hash/mdx_hash/mdx_hash.cpp b/src/lib/hash/mdx_hash/mdx_hash.cpp index f21b4ac34..c2fb320ec 100644 --- a/src/lib/hash/mdx_hash/mdx_hash.cpp +++ b/src/lib/hash/mdx_hash/mdx_hash.cpp @@ -38,7 +38,7 @@ void MDx_HashFunction::clear() /* * Update the hash */ -void MDx_HashFunction::add_data(const byte input[], size_t length) +void MDx_HashFunction::add_data(const uint8_t input[], size_t length) { m_count += length; @@ -68,7 +68,7 @@ void MDx_HashFunction::add_data(const byte input[], size_t length) /* * Finalize a hash */ -void MDx_HashFunction::final_result(byte output[]) +void MDx_HashFunction::final_result(uint8_t output[]) { m_buffer[m_position] = (BIG_BIT_ENDIAN ? 0x80 : 0x01); for(size_t i = m_position+1; i != m_buffer.size(); ++i) @@ -90,14 +90,14 @@ void MDx_HashFunction::final_result(byte output[]) /* * Write the count bits to the buffer */ -void MDx_HashFunction::write_count(byte out[]) +void MDx_HashFunction::write_count(uint8_t out[]) { if(COUNT_SIZE < 8) throw Invalid_State("MDx_HashFunction::write_count: COUNT_SIZE < 8"); if(COUNT_SIZE >= output_length() || COUNT_SIZE >= hash_block_size()) throw Invalid_Argument("MDx_HashFunction: COUNT_SIZE is too big"); - const u64bit bit_count = m_count * 8; + const uint64_t bit_count = m_count * 8; if(BIG_BYTE_ENDIAN) store_be(bit_count, out + COUNT_SIZE - 8); diff --git a/src/lib/hash/mdx_hash/mdx_hash.h b/src/lib/hash/mdx_hash/mdx_hash.h index 4b2f9bad0..649cf387d 100644 --- a/src/lib/hash/mdx_hash/mdx_hash.h +++ b/src/lib/hash/mdx_hash/mdx_hash.h @@ -31,15 +31,15 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction size_t hash_block_size() const override { return m_buffer.size(); } protected: - void add_data(const byte input[], size_t length) override; - void final_result(byte output[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t output[]) override; /** * Run the hash's compression function over a set of blocks * @param blocks the input * @param block_n the number of blocks */ - virtual void compress_n(const byte blocks[], size_t block_n) = 0; + virtual void compress_n(const uint8_t blocks[], size_t block_n) = 0; void clear() override; @@ -47,16 +47,16 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction * Copy the output to the buffer * @param buffer to put the output into */ - virtual void copy_out(byte buffer[]) = 0; + virtual void copy_out(uint8_t buffer[]) = 0; /** * Write the count, if used, to this spot * @param out where to write the counter to */ - virtual void write_count(byte out[]); + virtual void write_count(uint8_t out[]); private: - secure_vector<byte> m_buffer; - u64bit m_count; + secure_vector<uint8_t> m_buffer; + uint64_t m_count; size_t m_position; const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN; diff --git a/src/lib/hash/par_hash/par_hash.cpp b/src/lib/hash/par_hash/par_hash.cpp index 7320afee3..2a1ef7c9c 100644 --- a/src/lib/hash/par_hash/par_hash.cpp +++ b/src/lib/hash/par_hash/par_hash.cpp @@ -10,15 +10,15 @@ namespace Botan { -void Parallel::add_data(const byte input[], size_t length) +void Parallel::add_data(const uint8_t input[], size_t length) { for(auto&& hash : m_hashes) hash->update(input, length); } -void Parallel::final_result(byte out[]) +void Parallel::final_result(uint8_t out[]) { - u32bit offset = 0; + uint32_t offset = 0; for(auto&& hash : m_hashes) { diff --git a/src/lib/hash/par_hash/par_hash.h b/src/lib/hash/par_hash/par_hash.h index 67d026c2f..cbc2ad591 100644 --- a/src/lib/hash/par_hash/par_hash.h +++ b/src/lib/hash/par_hash/par_hash.h @@ -36,8 +36,8 @@ class BOTAN_DLL Parallel final : public HashFunction private: Parallel() {} - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; std::vector<std::unique_ptr<HashFunction>> m_hashes; }; diff --git a/src/lib/hash/rmd160/rmd160.cpp b/src/lib/hash/rmd160/rmd160.cpp index a48b97882..8d190a74f 100644 --- a/src/lib/hash/rmd160/rmd160.cpp +++ b/src/lib/hash/rmd160/rmd160.cpp @@ -14,8 +14,8 @@ namespace { /* * RIPEMD-160 F1 Function */ -inline void F1(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, - u32bit msg, u32bit shift) +inline void F1(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E, + uint32_t msg, uint32_t shift) { A += (B ^ C ^ D) + msg; A = rotate_left(A, shift) + E; @@ -25,8 +25,8 @@ inline void F1(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, /* * RIPEMD-160 F2 Function */ -inline void F2(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, - u32bit msg, u32bit shift, u32bit magic) +inline void F2(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E, + uint32_t msg, uint32_t shift, uint32_t magic) { A += (D ^ (B & (C ^ D))) + msg + magic; A = rotate_left(A, shift) + E; @@ -36,8 +36,8 @@ inline void F2(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, /* * RIPEMD-160 F3 Function */ -inline void F3(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, - u32bit msg, u32bit shift, u32bit magic) +inline void F3(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E, + uint32_t msg, uint32_t shift, uint32_t magic) { A += (D ^ (B | ~C)) + msg + magic; A = rotate_left(A, shift) + E; @@ -47,8 +47,8 @@ inline void F3(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, /* * RIPEMD-160 F4 Function */ -inline void F4(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, - u32bit msg, u32bit shift, u32bit magic) +inline void F4(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E, + uint32_t msg, uint32_t shift, uint32_t magic) { A += (C ^ (D & (B ^ C))) + msg + magic; A = rotate_left(A, shift) + E; @@ -58,8 +58,8 @@ inline void F4(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, /* * RIPEMD-160 F5 Function */ -inline void F5(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, - u32bit msg, u32bit shift, u32bit magic) +inline void F5(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E, + uint32_t msg, uint32_t shift, uint32_t magic) { A += (B ^ (C | ~D)) + msg + magic; A = rotate_left(A, shift) + E; @@ -71,9 +71,9 @@ inline void F5(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E, /* * RIPEMD-160 Compression Function */ -void RIPEMD_160::compress_n(const byte input[], size_t blocks) +void RIPEMD_160::compress_n(const uint8_t input[], size_t blocks) { - const u32bit MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1, + const uint32_t MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1, MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0xA953FD4E, MAGIC6 = 0x50A28BE6, MAGIC7 = 0x5C4DD124, MAGIC8 = 0x6D703EF3, MAGIC9 = 0x7A6D76E9; @@ -82,7 +82,7 @@ void RIPEMD_160::compress_n(const byte input[], size_t blocks) { load_le(m_M.data(), input, m_M.size()); - u32bit A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1, + uint32_t A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1, C1 = m_digest[2], C2 = C1, D1 = m_digest[3], D2 = D1, E1 = m_digest[4], E2 = E1; @@ -185,7 +185,7 @@ void RIPEMD_160::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void RIPEMD_160::copy_out(byte output[]) +void RIPEMD_160::copy_out(uint8_t output[]) { copy_out_vec_le(output, output_length(), m_digest); } diff --git a/src/lib/hash/rmd160/rmd160.h b/src/lib/hash/rmd160/rmd160.h index 0e4103101..9e2d1de87 100644 --- a/src/lib/hash/rmd160/rmd160.h +++ b/src/lib/hash/rmd160/rmd160.h @@ -27,10 +27,10 @@ class BOTAN_DLL RIPEMD_160 final : public MDx_HashFunction RIPEMD_160() : MDx_HashFunction(64, false, true), m_M(16), m_digest(5) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u32bit> m_M, m_digest; + secure_vector<uint32_t> m_M, m_digest; }; } diff --git a/src/lib/hash/sha1/sha160.cpp b/src/lib/hash/sha1/sha160.cpp index 87738fb00..735789cab 100644 --- a/src/lib/hash/sha1/sha160.cpp +++ b/src/lib/hash/sha1/sha160.cpp @@ -17,7 +17,7 @@ namespace { /* * SHA-160 F1 Function */ -inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F1(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += (D ^ (B & (C ^ D))) + msg + 0x5A827999 + rotate_left(A, 5); B = rotate_left(B, 30); @@ -26,7 +26,7 @@ inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 F2 Function */ -inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F2(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += (B ^ C ^ D) + msg + 0x6ED9EBA1 + rotate_left(A, 5); B = rotate_left(B, 30); @@ -35,7 +35,7 @@ inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 F3 Function */ -inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F3(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += ((B & C) | ((B | C) & D)) + msg + 0x8F1BBCDC + rotate_left(A, 5); B = rotate_left(B, 30); @@ -44,7 +44,7 @@ inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 F4 Function */ -inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F4(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += (B ^ C ^ D) + msg + 0xCA62C1D6 + rotate_left(A, 5); B = rotate_left(B, 30); @@ -57,7 +57,7 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 Compression Function */ -void SHA_160::compress_n(const byte input[], size_t blocks) +void SHA_160::compress_n(const uint8_t input[], size_t blocks) { using namespace SHA1_F; @@ -69,7 +69,7 @@ void SHA_160::compress_n(const byte input[], size_t blocks) #endif - u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], + uint32_t A = m_digest[0], B = m_digest[1], C = m_digest[2], D = m_digest[3], E = m_digest[4]; m_W.resize(80); @@ -147,7 +147,7 @@ void SHA_160::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void SHA_160::copy_out(byte output[]) +void SHA_160::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } diff --git a/src/lib/hash/sha1/sha160.h b/src/lib/hash/sha1/sha160.h index d7860834f..7ba7257af 100644 --- a/src/lib/hash/sha1/sha160.h +++ b/src/lib/hash/sha1/sha160.h @@ -30,26 +30,26 @@ class BOTAN_DLL SHA_160 final : public MDx_HashFunction } private: - void compress_n(const byte[], size_t blocks) override; + void compress_n(const uint8_t[], size_t blocks) override; #if defined(BOTAN_HAS_SHA1_SSE2) - static void sse2_compress_n(secure_vector<u32bit>& digest, - const byte blocks[], + static void sse2_compress_n(secure_vector<uint32_t>& digest, + const uint8_t blocks[], size_t block_count); #endif - void copy_out(byte[]) override; + void copy_out(uint8_t[]) override; /** * The digest value */ - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; /** * The message buffer */ - secure_vector<u32bit> m_W; + secure_vector<uint32_t> m_W; }; typedef SHA_160 SHA_1; diff --git a/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp b/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp index 0f88bb4c2..8c7785051 100644 --- a/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp +++ b/src/lib/hash/sha1/sha1_sse2/sha1_sse2.cpp @@ -111,7 +111,7 @@ W0 = W[t]..W[t+3] /* * SHA-160 F1 Function */ -inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F1(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += (D ^ (B & (C ^ D))) + msg + rotate_left(A, 5); B = rotate_left(B, 30); @@ -120,7 +120,7 @@ inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 F2 Function */ -inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F2(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += (B ^ C ^ D) + msg + rotate_left(A, 5); B = rotate_left(B, 30); @@ -129,7 +129,7 @@ inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 F3 Function */ -inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F3(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += ((B & C) | ((B | C) & D)) + msg + rotate_left(A, 5); B = rotate_left(B, 30); @@ -138,7 +138,7 @@ inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) /* * SHA-160 F4 Function */ -inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) +inline void F4(uint32_t A, uint32_t& B, uint32_t C, uint32_t D, uint32_t& E, uint32_t msg) { E += (B ^ C ^ D) + msg + rotate_left(A, 5); B = rotate_left(B, 30); @@ -153,7 +153,7 @@ inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, u32bit msg) */ //static BOTAN_FUNC_ISA("sse2") -void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const byte input[], size_t blocks) +void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const uint8_t input[], size_t blocks) { using namespace SHA1_SSE2_F; @@ -162,7 +162,7 @@ void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const byte input[ const __m128i K40_59 = _mm_set1_epi32(0x8F1BBCDC); const __m128i K60_79 = _mm_set1_epi32(0xCA62C1D6); - u32bit A = digest[0], + uint32_t A = digest[0], B = digest[1], C = digest[2], D = digest[3], @@ -173,7 +173,7 @@ void SHA_160::sse2_compress_n(secure_vector<uint32_t>& digest, const byte input[ for(size_t i = 0; i != blocks; ++i) { union v4si { - u32bit u32[4]; + uint32_t u32[4]; __m128i u128; }; diff --git a/src/lib/hash/sha2_32/sha2_32.cpp b/src/lib/hash/sha2_32/sha2_32.cpp index 46551431c..2a748a6aa 100644 --- a/src/lib/hash/sha2_32/sha2_32.cpp +++ b/src/lib/hash/sha2_32/sha2_32.cpp @@ -17,7 +17,7 @@ namespace SHA2_32 { /* * SHA-256 Rho Function */ -inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3) +inline uint32_t rho(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3) { return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ rotate_right(X, rot3)); @@ -26,7 +26,7 @@ inline u32bit rho(u32bit X, u32bit rot1, u32bit rot2, u32bit rot3) /* * SHA-256 Sigma Function */ -inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift) +inline uint32_t sigma(uint32_t X, uint32_t rot1, uint32_t rot2, uint32_t shift) { return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift)); } @@ -48,31 +48,31 @@ inline u32bit sigma(u32bit X, u32bit rot1, u32bit rot2, u32bit shift) /* * SHA-224 / SHA-256 compression function */ -void compress(secure_vector<u32bit>& digest, - const byte input[], size_t blocks) +void compress(secure_vector<uint32_t>& digest, + const uint8_t input[], size_t blocks) { - u32bit A = digest[0], B = digest[1], C = digest[2], + uint32_t A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4], F = digest[5], G = digest[6], H = digest[7]; for(size_t i = 0; i != blocks; ++i) { - u32bit W00 = load_be<u32bit>(input, 0); - u32bit W01 = load_be<u32bit>(input, 1); - u32bit W02 = load_be<u32bit>(input, 2); - u32bit W03 = load_be<u32bit>(input, 3); - u32bit W04 = load_be<u32bit>(input, 4); - u32bit W05 = load_be<u32bit>(input, 5); - u32bit W06 = load_be<u32bit>(input, 6); - u32bit W07 = load_be<u32bit>(input, 7); - u32bit W08 = load_be<u32bit>(input, 8); - u32bit W09 = load_be<u32bit>(input, 9); - u32bit W10 = load_be<u32bit>(input, 10); - u32bit W11 = load_be<u32bit>(input, 11); - u32bit W12 = load_be<u32bit>(input, 12); - u32bit W13 = load_be<u32bit>(input, 13); - u32bit W14 = load_be<u32bit>(input, 14); - u32bit W15 = load_be<u32bit>(input, 15); + uint32_t W00 = load_be<uint32_t>(input, 0); + uint32_t W01 = load_be<uint32_t>(input, 1); + uint32_t W02 = load_be<uint32_t>(input, 2); + uint32_t W03 = load_be<uint32_t>(input, 3); + uint32_t W04 = load_be<uint32_t>(input, 4); + uint32_t W05 = load_be<uint32_t>(input, 5); + uint32_t W06 = load_be<uint32_t>(input, 6); + uint32_t W07 = load_be<uint32_t>(input, 7); + uint32_t W08 = load_be<uint32_t>(input, 8); + uint32_t W09 = load_be<uint32_t>(input, 9); + uint32_t W10 = load_be<uint32_t>(input, 10); + uint32_t W11 = load_be<uint32_t>(input, 11); + uint32_t W12 = load_be<uint32_t>(input, 12); + uint32_t W13 = load_be<uint32_t>(input, 13); + uint32_t W14 = load_be<uint32_t>(input, 14); + uint32_t W15 = load_be<uint32_t>(input, 15); SHA2_32_F(A, B, C, D, E, F, G, H, W00, W14, W09, W01, 0x428A2F98); SHA2_32_F(H, A, B, C, D, E, F, G, W01, W15, W10, W02, 0x71374491); @@ -159,7 +159,7 @@ void compress(secure_vector<u32bit>& digest, /* * SHA-224 compression function */ -void SHA_224::compress_n(const byte input[], size_t blocks) +void SHA_224::compress_n(const uint8_t input[], size_t blocks) { SHA2_32::compress(m_digest, input, blocks); } @@ -167,7 +167,7 @@ void SHA_224::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void SHA_224::copy_out(byte output[]) +void SHA_224::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } @@ -191,7 +191,7 @@ void SHA_224::clear() /* * SHA-256 compression function */ -void SHA_256::compress_n(const byte input[], size_t blocks) +void SHA_256::compress_n(const uint8_t input[], size_t blocks) { SHA2_32::compress(m_digest, input, blocks); } @@ -199,7 +199,7 @@ void SHA_256::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void SHA_256::copy_out(byte output[]) +void SHA_256::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } diff --git a/src/lib/hash/sha2_32/sha2_32.h b/src/lib/hash/sha2_32/sha2_32.h index 528fe9cfd..78e08c97a 100644 --- a/src/lib/hash/sha2_32/sha2_32.h +++ b/src/lib/hash/sha2_32/sha2_32.h @@ -28,10 +28,10 @@ class BOTAN_DLL SHA_224 final : public MDx_HashFunction SHA_224() : MDx_HashFunction(64, true, true), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; }; /** @@ -49,10 +49,10 @@ class BOTAN_DLL SHA_256 final : public MDx_HashFunction SHA_256() : MDx_HashFunction(64, true, true), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u32bit> m_digest; + secure_vector<uint32_t> m_digest; }; } diff --git a/src/lib/hash/sha2_64/sha2_64.cpp b/src/lib/hash/sha2_64/sha2_64.cpp index d7c3f1325..59242ee9c 100644 --- a/src/lib/hash/sha2_64/sha2_64.cpp +++ b/src/lib/hash/sha2_64/sha2_64.cpp @@ -16,7 +16,7 @@ namespace SHA2_64 { /* * SHA-{384,512} Rho Function */ -inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3) +inline uint64_t rho(uint64_t X, uint32_t rot1, uint32_t rot2, uint32_t rot3) { return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ rotate_right(X, rot3)); @@ -25,7 +25,7 @@ inline u64bit rho(u64bit X, u32bit rot1, u32bit rot2, u32bit rot3) /* * SHA-{384,512} Sigma Function */ -inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift) +inline uint64_t sigma(uint64_t X, uint32_t rot1, uint32_t rot2, uint32_t shift) { return (rotate_right(X, rot1) ^ rotate_right(X, rot2) ^ (X >> shift)); } @@ -47,31 +47,31 @@ inline u64bit sigma(u64bit X, u32bit rot1, u32bit rot2, u32bit shift) /* * SHA-{384,512} Compression Function */ -void compress(secure_vector<u64bit>& digest, - const byte input[], size_t blocks) +void compress(secure_vector<uint64_t>& digest, + const uint8_t input[], size_t blocks) { - u64bit A = digest[0], B = digest[1], C = digest[2], + uint64_t A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4], F = digest[5], G = digest[6], H = digest[7]; for(size_t i = 0; i != blocks; ++i) { - u64bit W00 = load_be<u64bit>(input, 0); - u64bit W01 = load_be<u64bit>(input, 1); - u64bit W02 = load_be<u64bit>(input, 2); - u64bit W03 = load_be<u64bit>(input, 3); - u64bit W04 = load_be<u64bit>(input, 4); - u64bit W05 = load_be<u64bit>(input, 5); - u64bit W06 = load_be<u64bit>(input, 6); - u64bit W07 = load_be<u64bit>(input, 7); - u64bit W08 = load_be<u64bit>(input, 8); - u64bit W09 = load_be<u64bit>(input, 9); - u64bit W10 = load_be<u64bit>(input, 10); - u64bit W11 = load_be<u64bit>(input, 11); - u64bit W12 = load_be<u64bit>(input, 12); - u64bit W13 = load_be<u64bit>(input, 13); - u64bit W14 = load_be<u64bit>(input, 14); - u64bit W15 = load_be<u64bit>(input, 15); + uint64_t W00 = load_be<uint64_t>(input, 0); + uint64_t W01 = load_be<uint64_t>(input, 1); + uint64_t W02 = load_be<uint64_t>(input, 2); + uint64_t W03 = load_be<uint64_t>(input, 3); + uint64_t W04 = load_be<uint64_t>(input, 4); + uint64_t W05 = load_be<uint64_t>(input, 5); + uint64_t W06 = load_be<uint64_t>(input, 6); + uint64_t W07 = load_be<uint64_t>(input, 7); + uint64_t W08 = load_be<uint64_t>(input, 8); + uint64_t W09 = load_be<uint64_t>(input, 9); + uint64_t W10 = load_be<uint64_t>(input, 10); + uint64_t W11 = load_be<uint64_t>(input, 11); + uint64_t W12 = load_be<uint64_t>(input, 12); + uint64_t W13 = load_be<uint64_t>(input, 13); + uint64_t W14 = load_be<uint64_t>(input, 14); + uint64_t W15 = load_be<uint64_t>(input, 15); SHA2_64_F(A, B, C, D, E, F, G, H, W00, W14, W09, W01, 0x428A2F98D728AE22); SHA2_64_F(H, A, B, C, D, E, F, G, W01, W15, W10, W02, 0x7137449123EF65CD); @@ -171,32 +171,32 @@ void compress(secure_vector<u64bit>& digest, } -void SHA_512_256::compress_n(const byte input[], size_t blocks) +void SHA_512_256::compress_n(const uint8_t input[], size_t blocks) { SHA2_64::compress(m_digest, input, blocks); } -void SHA_384::compress_n(const byte input[], size_t blocks) +void SHA_384::compress_n(const uint8_t input[], size_t blocks) { SHA2_64::compress(m_digest, input, blocks); } -void SHA_512::compress_n(const byte input[], size_t blocks) +void SHA_512::compress_n(const uint8_t input[], size_t blocks) { SHA2_64::compress(m_digest, input, blocks); } -void SHA_512_256::copy_out(byte output[]) +void SHA_512_256::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } -void SHA_384::copy_out(byte output[]) +void SHA_384::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } -void SHA_512::copy_out(byte output[]) +void SHA_512::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } diff --git a/src/lib/hash/sha2_64/sha2_64.h b/src/lib/hash/sha2_64/sha2_64.h index a38f12dae..51bdb2b77 100644 --- a/src/lib/hash/sha2_64/sha2_64.h +++ b/src/lib/hash/sha2_64/sha2_64.h @@ -27,10 +27,10 @@ class BOTAN_DLL SHA_384 final : public MDx_HashFunction SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u64bit> m_digest; + secure_vector<uint64_t> m_digest; }; /** @@ -48,10 +48,10 @@ class BOTAN_DLL SHA_512 final : public MDx_HashFunction SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u64bit> m_digest; + secure_vector<uint64_t> m_digest; }; /** @@ -68,10 +68,10 @@ class BOTAN_DLL SHA_512_256 final : public MDx_HashFunction SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; - secure_vector<u64bit> m_digest; + secure_vector<uint64_t> m_digest; }; } diff --git a/src/lib/hash/sha3/sha3.cpp b/src/lib/hash/sha3/sha3.cpp index 2361d7d5b..f1c769e6b 100644 --- a/src/lib/hash/sha3/sha3.cpp +++ b/src/lib/hash/sha3/sha3.cpp @@ -12,9 +12,9 @@ namespace Botan { //static -void SHA_3::permute(u64bit A[25]) +void SHA_3::permute(uint64_t A[25]) { - static const u64bit RC[24] = { + static const uint64_t RC[24] = { 0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000, 0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, 0x000000000000008A, @@ -27,43 +27,43 @@ void SHA_3::permute(u64bit A[25]) for(size_t i = 0; i != 24; ++i) { - const u64bit C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20]; - const u64bit C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21]; - const u64bit C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22]; - const u64bit C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23]; - const u64bit C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24]; - - const u64bit D0 = rotate_left(C0, 1) ^ C3; - const u64bit D1 = rotate_left(C1, 1) ^ C4; - const u64bit D2 = rotate_left(C2, 1) ^ C0; - const u64bit D3 = rotate_left(C3, 1) ^ C1; - const u64bit D4 = rotate_left(C4, 1) ^ C2; - - const u64bit B00 = A[ 0] ^ D1; - const u64bit B10 = rotate_left(A[ 1] ^ D2, 1); - const u64bit B20 = rotate_left(A[ 2] ^ D3, 62); - const u64bit B05 = rotate_left(A[ 3] ^ D4, 28); - const u64bit B15 = rotate_left(A[ 4] ^ D0, 27); - const u64bit B16 = rotate_left(A[ 5] ^ D1, 36); - const u64bit B01 = rotate_left(A[ 6] ^ D2, 44); - const u64bit B11 = rotate_left(A[ 7] ^ D3, 6); - const u64bit B21 = rotate_left(A[ 8] ^ D4, 55); - const u64bit B06 = rotate_left(A[ 9] ^ D0, 20); - const u64bit B07 = rotate_left(A[10] ^ D1, 3); - const u64bit B17 = rotate_left(A[11] ^ D2, 10); - const u64bit B02 = rotate_left(A[12] ^ D3, 43); - const u64bit B12 = rotate_left(A[13] ^ D4, 25); - const u64bit B22 = rotate_left(A[14] ^ D0, 39); - const u64bit B23 = rotate_left(A[15] ^ D1, 41); - const u64bit B08 = rotate_left(A[16] ^ D2, 45); - const u64bit B18 = rotate_left(A[17] ^ D3, 15); - const u64bit B03 = rotate_left(A[18] ^ D4, 21); - const u64bit B13 = rotate_left(A[19] ^ D0, 8); - const u64bit B14 = rotate_left(A[20] ^ D1, 18); - const u64bit B24 = rotate_left(A[21] ^ D2, 2); - const u64bit B09 = rotate_left(A[22] ^ D3, 61); - const u64bit B19 = rotate_left(A[23] ^ D4, 56); - const u64bit B04 = rotate_left(A[24] ^ D0, 14); + const uint64_t C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20]; + const uint64_t C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21]; + const uint64_t C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22]; + const uint64_t C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23]; + const uint64_t C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24]; + + const uint64_t D0 = rotate_left(C0, 1) ^ C3; + const uint64_t D1 = rotate_left(C1, 1) ^ C4; + const uint64_t D2 = rotate_left(C2, 1) ^ C0; + const uint64_t D3 = rotate_left(C3, 1) ^ C1; + const uint64_t D4 = rotate_left(C4, 1) ^ C2; + + const uint64_t B00 = A[ 0] ^ D1; + const uint64_t B10 = rotate_left(A[ 1] ^ D2, 1); + const uint64_t B20 = rotate_left(A[ 2] ^ D3, 62); + const uint64_t B05 = rotate_left(A[ 3] ^ D4, 28); + const uint64_t B15 = rotate_left(A[ 4] ^ D0, 27); + const uint64_t B16 = rotate_left(A[ 5] ^ D1, 36); + const uint64_t B01 = rotate_left(A[ 6] ^ D2, 44); + const uint64_t B11 = rotate_left(A[ 7] ^ D3, 6); + const uint64_t B21 = rotate_left(A[ 8] ^ D4, 55); + const uint64_t B06 = rotate_left(A[ 9] ^ D0, 20); + const uint64_t B07 = rotate_left(A[10] ^ D1, 3); + const uint64_t B17 = rotate_left(A[11] ^ D2, 10); + const uint64_t B02 = rotate_left(A[12] ^ D3, 43); + const uint64_t B12 = rotate_left(A[13] ^ D4, 25); + const uint64_t B22 = rotate_left(A[14] ^ D0, 39); + const uint64_t B23 = rotate_left(A[15] ^ D1, 41); + const uint64_t B08 = rotate_left(A[16] ^ D2, 45); + const uint64_t B18 = rotate_left(A[17] ^ D3, 15); + const uint64_t B03 = rotate_left(A[18] ^ D4, 21); + const uint64_t B13 = rotate_left(A[19] ^ D0, 8); + const uint64_t B14 = rotate_left(A[20] ^ D1, 18); + const uint64_t B24 = rotate_left(A[21] ^ D2, 2); + const uint64_t B09 = rotate_left(A[22] ^ D3, 61); + const uint64_t B19 = rotate_left(A[23] ^ D4, 56); + const uint64_t B04 = rotate_left(A[24] ^ D0, 14); A[ 0] = B00 ^ (~B01 & B02); A[ 1] = B01 ^ (~B02 & B03); @@ -128,7 +128,7 @@ void SHA_3::clear() //static size_t SHA_3::absorb(size_t bitrate, secure_vector<uint64_t>& S, size_t S_pos, - const byte input[], size_t length) + const uint8_t input[], size_t length) { while(length > 0) { @@ -138,7 +138,7 @@ size_t SHA_3::absorb(size_t bitrate, while(to_take && S_pos % 8) { - S[S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (S_pos % 8)); + S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8)); ++S_pos; ++input; @@ -147,7 +147,7 @@ size_t SHA_3::absorb(size_t bitrate, while(to_take && to_take % 8 == 0) { - S[S_pos / 8] ^= load_le<u64bit>(input, 0); + S[S_pos / 8] ^= load_le<uint64_t>(input, 0); S_pos += 8; input += 8; to_take -= 8; @@ -155,7 +155,7 @@ size_t SHA_3::absorb(size_t bitrate, while(to_take) { - S[S_pos / 8] ^= static_cast<u64bit>(input[0]) << (8 * (S_pos % 8)); + S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8)); ++S_pos; ++input; @@ -175,7 +175,7 @@ size_t SHA_3::absorb(size_t bitrate, //static void SHA_3::expand(size_t bitrate, secure_vector<uint64_t>& S, - byte output[], size_t output_length) + uint8_t output[], size_t output_length) { BOTAN_ARG_CHECK(bitrate % 8 == 0); @@ -200,14 +200,14 @@ void SHA_3::expand(size_t bitrate, } } -void SHA_3::add_data(const byte input[], size_t length) +void SHA_3::add_data(const uint8_t input[], size_t length) { m_S_pos = SHA_3::absorb(m_bitrate, m_S, m_S_pos, input, length); } -void SHA_3::final_result(byte output[]) +void SHA_3::final_result(uint8_t output[]) { - std::vector<byte> padding(m_bitrate / 8 - m_S_pos); + std::vector<uint8_t> padding(m_bitrate / 8 - m_S_pos); padding[0] = 0x06; padding[padding.size()-1] |= 0x80; diff --git a/src/lib/hash/sha3/sha3.h b/src/lib/hash/sha3/sha3.h index 649aa12fd..e7905b5c4 100644 --- a/src/lib/hash/sha3/sha3.h +++ b/src/lib/hash/sha3/sha3.h @@ -46,7 +46,7 @@ class BOTAN_DLL SHA_3 : public HashFunction */ static size_t absorb(size_t bitrate, secure_vector<uint64_t>& S, size_t S_pos, - const byte input[], size_t length); + const uint8_t input[], size_t length); /** * Expand from provided state @@ -57,19 +57,19 @@ class BOTAN_DLL SHA_3 : public HashFunction */ static void expand(size_t bitrate, secure_vector<uint64_t>& S, - byte output[], size_t output_length); + uint8_t output[], size_t output_length); /** * The bare Keccak-1600 permutation */ - static void permute(u64bit A[25]); + static void permute(uint64_t A[25]); private: - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; size_t m_output_bits, m_bitrate; - secure_vector<u64bit> m_S; + secure_vector<uint64_t> m_S; size_t m_S_pos; }; diff --git a/src/lib/hash/shake/shake.cpp b/src/lib/hash/shake/shake.cpp index 1ff6f1fd3..97ee0c4da 100644 --- a/src/lib/hash/shake/shake.cpp +++ b/src/lib/hash/shake/shake.cpp @@ -36,14 +36,14 @@ void SHAKE_128::clear() m_S_pos = 0; } -void SHAKE_128::add_data(const byte input[], size_t length) +void SHAKE_128::add_data(const uint8_t input[], size_t length) { m_S_pos = SHA_3::absorb(SHAKE_128_BITRATE, m_S, m_S_pos, input, length); } -void SHAKE_128::final_result(byte output[]) +void SHAKE_128::final_result(uint8_t output[]) { - std::vector<byte> padding(SHAKE_128_BITRATE / 8 - m_S_pos); + std::vector<uint8_t> padding(SHAKE_128_BITRATE / 8 - m_S_pos); padding[0] = 0x1F; padding[padding.size()-1] |= 0x80; @@ -79,14 +79,14 @@ void SHAKE_256::clear() m_S_pos = 0; } -void SHAKE_256::add_data(const byte input[], size_t length) +void SHAKE_256::add_data(const uint8_t input[], size_t length) { m_S_pos = SHA_3::absorb(SHAKE_256_BITRATE, m_S, m_S_pos, input, length); } -void SHAKE_256::final_result(byte output[]) +void SHAKE_256::final_result(uint8_t output[]) { - std::vector<byte> padding(SHAKE_256_BITRATE / 8 - m_S_pos); + std::vector<uint8_t> padding(SHAKE_256_BITRATE / 8 - m_S_pos); padding[0] = 0x1F; padding[padding.size()-1] |= 0x80; diff --git a/src/lib/hash/shake/shake.h b/src/lib/hash/shake/shake.h index 96c171323..f24fda4fa 100644 --- a/src/lib/hash/shake/shake.h +++ b/src/lib/hash/shake/shake.h @@ -35,13 +35,13 @@ class BOTAN_DLL SHAKE_128 : public HashFunction void clear() override; private: - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; static const size_t SHAKE_128_BITRATE = 1600 - 256; size_t m_output_bits; - secure_vector<u64bit> m_S; + secure_vector<uint64_t> m_S; size_t m_S_pos; }; @@ -66,13 +66,13 @@ class BOTAN_DLL SHAKE_256 : public HashFunction void clear() override; private: - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; static const size_t SHAKE_256_BITRATE = 1600 - 512; size_t m_output_bits; - secure_vector<u64bit> m_S; + secure_vector<uint64_t> m_S; size_t m_S_pos; }; diff --git a/src/lib/hash/skein/skein_512.cpp b/src/lib/hash/skein/skein_512.cpp index 21eeb1f27..ae059f085 100644 --- a/src/lib/hash/skein/skein_512.cpp +++ b/src/lib/hash/skein/skein_512.cpp @@ -50,20 +50,20 @@ void Skein_512::reset_tweak(type_code type, bool is_final) { m_T[0] = 0; - m_T[1] = (static_cast<u64bit>(type) << 56) | - (static_cast<u64bit>(1) << 62) | - (static_cast<u64bit>(is_final) << 63); + m_T[1] = (static_cast<uint64_t>(type) << 56) | + (static_cast<uint64_t>(1) << 62) | + (static_cast<uint64_t>(is_final) << 63); } void Skein_512::initial_block() { - const byte zeros[64] = { 0 }; + const uint8_t zeros[64] = { 0 }; m_threefish->set_key(zeros, sizeof(zeros)); // ASCII("SHA3") followed by version (0x0001) code - byte config_str[32] = { 0x53, 0x48, 0x41, 0x33, 0x01, 0x00, 0 }; - store_le(u32bit(m_output_bits), config_str + 8); + uint8_t config_str[32] = { 0x53, 0x48, 0x41, 0x33, 0x01, 0x00, 0 }; + store_le(uint32_t(m_output_bits), config_str + 8); reset_tweak(SKEIN_CONFIG, true); ubi_512(config_str, sizeof(config_str)); @@ -78,7 +78,7 @@ void Skein_512::initial_block() if(m_personalization.length() > 64) throw Invalid_Argument("Skein personalization must be less than 64 bytes"); - const byte* bits = reinterpret_cast<const byte*>(m_personalization.data()); + const uint8_t* bits = reinterpret_cast<const uint8_t*>(m_personalization.data()); reset_tweak(SKEIN_PERSONALIZATION, true); ubi_512(bits, m_personalization.length()); } @@ -86,9 +86,9 @@ void Skein_512::initial_block() reset_tweak(SKEIN_MSG, false); } -void Skein_512::ubi_512(const byte msg[], size_t msg_len) +void Skein_512::ubi_512(const uint8_t msg[], size_t msg_len) { - secure_vector<u64bit> M(8); + secure_vector<uint64_t> M(8); do { @@ -100,20 +100,20 @@ void Skein_512::ubi_512(const byte msg[], size_t msg_len) if(to_proc % 8) { for(size_t j = 0; j != to_proc % 8; ++j) - M[to_proc/8] |= static_cast<u64bit>(msg[8*(to_proc/8)+j]) << (8*j); + M[to_proc/8] |= static_cast<uint64_t>(msg[8*(to_proc/8)+j]) << (8*j); } m_threefish->skein_feedfwd(M, m_T); // clear first flag if set - m_T[1] &= ~(static_cast<u64bit>(1) << 62); + m_T[1] &= ~(static_cast<uint64_t>(1) << 62); msg_len -= to_proc; msg += to_proc; } while(msg_len); } -void Skein_512::add_data(const byte input[], size_t length) +void Skein_512::add_data(const uint8_t input[], size_t length) { if(length == 0) return; @@ -142,16 +142,16 @@ void Skein_512::add_data(const byte input[], size_t length) m_buf_pos += length; } -void Skein_512::final_result(byte out[]) +void Skein_512::final_result(uint8_t out[]) { - m_T[1] |= (static_cast<u64bit>(1) << 63); // final block flag + m_T[1] |= (static_cast<uint64_t>(1) << 63); // final block flag for(size_t i = m_buf_pos; i != m_buffer.size(); ++i) m_buffer[i] = 0; ubi_512(m_buffer.data(), m_buf_pos); - const byte counter[8] = { 0 }; + const uint8_t counter[8] = { 0 }; reset_tweak(SKEIN_OUTPUT, true); ubi_512(counter, sizeof(counter)); diff --git a/src/lib/hash/skein/skein_512.h b/src/lib/hash/skein/skein_512.h index 1f34f1583..32323807e 100644 --- a/src/lib/hash/skein/skein_512.h +++ b/src/lib/hash/skein/skein_512.h @@ -47,10 +47,10 @@ class BOTAN_DLL Skein_512 final : public HashFunction SKEIN_OUTPUT = 63 }; - void add_data(const byte input[], size_t length) override; - void final_result(byte out[]) override; + void add_data(const uint8_t input[], size_t length) override; + void final_result(uint8_t out[]) override; - void ubi_512(const byte msg[], size_t msg_len); + void ubi_512(const uint8_t msg[], size_t msg_len); void initial_block(); void reset_tweak(type_code type, bool is_final); @@ -59,8 +59,8 @@ class BOTAN_DLL Skein_512 final : public HashFunction size_t m_output_bits; std::unique_ptr<Threefish_512> m_threefish; - secure_vector<u64bit> m_T; - secure_vector<byte> m_buffer; + secure_vector<uint64_t> m_T; + secure_vector<uint8_t> m_buffer; size_t m_buf_pos; }; diff --git a/src/lib/hash/tiger/tig_tab.cpp b/src/lib/hash/tiger/tig_tab.cpp index 4d0bea5ee..3d1dc1eeb 100644 --- a/src/lib/hash/tiger/tig_tab.cpp +++ b/src/lib/hash/tiger/tig_tab.cpp @@ -9,7 +9,7 @@ namespace Botan { -const u64bit Tiger::SBOX1[256] = { +const uint64_t Tiger::SBOX1[256] = { 0x02AAB17CF7E90C5E, 0xAC424B03E243A8EC, 0x72CD5BE30DD5FCD3, 0x6D019B93F6F97F3A, 0xCD9978FFD21F9193, 0x7573A1C9708029E2, 0xB164326B922A83C3, 0x46883EEE04915870, 0xEAACE3057103ECE6, @@ -97,7 +97,7 @@ const u64bit Tiger::SBOX1[256] = { 0xFFED95D8F1EA02A2, 0xE72B3BD61464D43D, 0xA6300F170BDC4820, 0xEBC18760ED78A77A }; -const u64bit Tiger::SBOX2[256] = { +const uint64_t Tiger::SBOX2[256] = { 0xE6A6BE5A05A12138, 0xB5A122A5B4F87C98, 0x563C6089140B6990, 0x4C46CB2E391F5DD5, 0xD932ADDBC9B79434, 0x08EA70E42015AFF5, 0xD765A6673E478CF1, 0xC4FB757EAB278D99, 0xDF11C6862D6E0692, @@ -185,7 +185,7 @@ const u64bit Tiger::SBOX2[256] = { 0x9010A91E84711AE9, 0x4DF7F0B7B1498371, 0xD62A2EABC0977179, 0x22FAC097AA8D5C0E }; -const u64bit Tiger::SBOX3[256] = { +const uint64_t Tiger::SBOX3[256] = { 0xF49FCC2FF1DAF39B, 0x487FD5C66FF29281, 0xE8A30667FCDCA83F, 0x2C9B4BE3D2FCCE63, 0xDA3FF74B93FBBBC2, 0x2FA165D2FE70BA66, 0xA103E279970E93D4, 0xBECDEC77B0E45E71, 0xCFB41E723985E497, @@ -273,7 +273,7 @@ const u64bit Tiger::SBOX3[256] = { 0x454C6FE9F2C0C1CD, 0x419CF6496412691C, 0xD3DC3BEF265B0F70, 0x6D0E60F5C3578A9E }; -const u64bit Tiger::SBOX4[256] = { +const uint64_t Tiger::SBOX4[256] = { 0x5B0E608526323C55, 0x1A46C1A9FA1B59F5, 0xA9E245A17C4C8FFA, 0x65CA5159DB2955D7, 0x05DB0A76CE35AFC2, 0x81EAC77EA9113D45, 0x528EF88AB6AC0A0D, 0xA09EA253597BE3FF, 0x430DDFB3AC48CD56, diff --git a/src/lib/hash/tiger/tiger.cpp b/src/lib/hash/tiger/tiger.cpp index 1da38291c..b09e03d2e 100644 --- a/src/lib/hash/tiger/tiger.cpp +++ b/src/lib/hash/tiger/tiger.cpp @@ -16,7 +16,7 @@ namespace { /* * Tiger Mixing Function */ -inline void mix(secure_vector<u64bit>& X) +inline void mix(secure_vector<uint64_t>& X) { X[0] -= X[7] ^ 0xA5A5A5A5A5A5A5A5; X[1] ^= X[0]; @@ -42,9 +42,9 @@ inline void mix(secure_vector<u64bit>& X) /* * Tiger Compression Function */ -void Tiger::compress_n(const byte input[], size_t blocks) +void Tiger::compress_n(const uint8_t input[], size_t blocks) { - u64bit A = m_digest[0], B = m_digest[1], C = m_digest[2]; + uint64_t A = m_digest[0], B = m_digest[1], C = m_digest[2]; for(size_t i = 0; i != blocks; ++i) { @@ -58,7 +58,7 @@ void Tiger::compress_n(const byte input[], size_t blocks) { mix(m_X); pass(A, B, C, m_X, 9); - u64bit T = A; A = C; C = B; B = T; + uint64_t T = A; A = C; C = B; B = T; } A = (m_digest[0] ^= A); @@ -72,7 +72,7 @@ void Tiger::compress_n(const byte input[], size_t blocks) /* * Copy out the digest */ -void Tiger::copy_out(byte output[]) +void Tiger::copy_out(uint8_t output[]) { copy_out_vec_le(output, output_length(), m_digest); } @@ -80,9 +80,9 @@ void Tiger::copy_out(byte output[]) /* * Tiger Pass */ -void Tiger::pass(u64bit& A, u64bit& B, u64bit& C, - const secure_vector<u64bit>& X, - byte mul) +void Tiger::pass(uint64_t& A, uint64_t& B, uint64_t& C, + const secure_vector<uint64_t>& X, + uint8_t mul) { C ^= X[0]; A -= SBOX1[get_byte(7, C)] ^ SBOX2[get_byte(5, C)] ^ diff --git a/src/lib/hash/tiger/tiger.h b/src/lib/hash/tiger/tiger.h index fb0524d44..32ae26258 100644 --- a/src/lib/hash/tiger/tiger.h +++ b/src/lib/hash/tiger/tiger.h @@ -34,19 +34,19 @@ class BOTAN_DLL Tiger final : public MDx_HashFunction */ Tiger(size_t out_size = 24, size_t passes = 3); private: - void compress_n(const byte[], size_t block) override; - void copy_out(byte[]) override; + void compress_n(const uint8_t[], size_t block) override; + void copy_out(uint8_t[]) override; - static void pass(u64bit& A, u64bit& B, u64bit& C, - const secure_vector<u64bit>& M, - byte mul); + static void pass(uint64_t& A, uint64_t& B, uint64_t& C, + const secure_vector<uint64_t>& M, + uint8_t mul); - static const u64bit SBOX1[256]; - static const u64bit SBOX2[256]; - static const u64bit SBOX3[256]; - static const u64bit SBOX4[256]; + static const uint64_t SBOX1[256]; + static const uint64_t SBOX2[256]; + static const uint64_t SBOX3[256]; + static const uint64_t SBOX4[256]; - secure_vector<u64bit> m_X, m_digest; + secure_vector<uint64_t> m_X, m_digest; const size_t m_hash_len, m_passes; }; diff --git a/src/lib/hash/whirlpool/whirlpool.cpp b/src/lib/hash/whirlpool/whirlpool.cpp index 5bf4c5246..64350fd24 100644 --- a/src/lib/hash/whirlpool/whirlpool.cpp +++ b/src/lib/hash/whirlpool/whirlpool.cpp @@ -12,9 +12,9 @@ namespace Botan { /* * Whirlpool Compression Function */ -void Whirlpool::compress_n(const byte in[], size_t blocks) +void Whirlpool::compress_n(const uint8_t in[], size_t blocks) { - static const u64bit RC[10] = { + static const uint64_t RC[10] = { 0x1823C6E887B8014F, 0x36A6D2F5796F9152, 0x60BC9B8EA30C7B35, 0x1DE0D7C22E4BFE57, 0x157737E59FF04ADA, 0x58C9290AB1A06B85, @@ -26,17 +26,17 @@ void Whirlpool::compress_n(const byte in[], size_t blocks) { load_be(m_M.data(), in, m_M.size()); - u64bit K0, K1, K2, K3, K4, K5, K6, K7; + uint64_t K0, K1, K2, K3, K4, K5, K6, K7; K0 = m_digest[0]; K1 = m_digest[1]; K2 = m_digest[2]; K3 = m_digest[3]; K4 = m_digest[4]; K5 = m_digest[5]; K6 = m_digest[6]; K7 = m_digest[7]; - u64bit B0, B1, B2, B3, B4, B5, B6, B7; + uint64_t B0, B1, B2, B3, B4, B5, B6, B7; B0 = K0 ^ m_M[0]; B1 = K1 ^ m_M[1]; B2 = K2 ^ m_M[2]; B3 = K3 ^ m_M[3]; B4 = K4 ^ m_M[4]; B5 = K5 ^ m_M[5]; B6 = K6 ^ m_M[6]; B7 = K7 ^ m_M[7]; for(size_t j = 0; j != 10; ++j) { - u64bit T0, T1, T2, T3, T4, T5, T6, T7; + uint64_t T0, T1, T2, T3, T4, T5, T6, T7; T0 = C0[get_byte(0, K0)] ^ C1[get_byte(1, K7)] ^ C2[get_byte(2, K6)] ^ C3[get_byte(3, K5)] ^ C4[get_byte(4, K4)] ^ C5[get_byte(5, K3)] ^ @@ -126,7 +126,7 @@ void Whirlpool::compress_n(const byte in[], size_t blocks) /* * Copy out the digest */ -void Whirlpool::copy_out(byte output[]) +void Whirlpool::copy_out(uint8_t output[]) { copy_out_vec_be(output, output_length(), m_digest); } diff --git a/src/lib/hash/whirlpool/whrl_tab.cpp b/src/lib/hash/whirlpool/whrl_tab.cpp index 7289a0560..460425cee 100644 --- a/src/lib/hash/whirlpool/whrl_tab.cpp +++ b/src/lib/hash/whirlpool/whrl_tab.cpp @@ -9,7 +9,7 @@ namespace Botan { -const u64bit Whirlpool::C0[256] = { +const uint64_t Whirlpool::C0[256] = { 0x18186018C07830D8, 0x23238C2305AF4626, 0xC6C63FC67EF991B8, 0xE8E887E8136FCDFB, 0x878726874CA113CB, 0xB8B8DAB8A9626D11, 0x0101040108050209, 0x4F4F214F426E9E0D, 0x3636D836ADEE6C9B, 0xA6A6A2A6590451FF, 0xD2D26FD2DEBDB90C, 0xF5F5F3F5FB06F70E, @@ -75,7 +75,7 @@ const u64bit Whirlpool::C0[256] = { 0xCCCC17CC2EDB85E2, 0x424215422A578468, 0x98985A98B4C22D2C, 0xA4A4AAA4490E55ED, 0x2828A0285D885075, 0x5C5C6D5CDA31B886, 0xF8F8C7F8933FED6B, 0x8686228644A411C2 }; -const u64bit Whirlpool::C1[256] = { +const uint64_t Whirlpool::C1[256] = { 0xD818186018C07830, 0x2623238C2305AF46, 0xB8C6C63FC67EF991, 0xFBE8E887E8136FCD, 0xCB878726874CA113, 0x11B8B8DAB8A9626D, 0x0901010401080502, 0x0D4F4F214F426E9E, 0x9B3636D836ADEE6C, 0xFFA6A6A2A6590451, 0x0CD2D26FD2DEBDB9, 0x0EF5F5F3F5FB06F7, @@ -141,7 +141,7 @@ const u64bit Whirlpool::C1[256] = { 0xE2CCCC17CC2EDB85, 0x68424215422A5784, 0x2C98985A98B4C22D, 0xEDA4A4AAA4490E55, 0x752828A0285D8850, 0x865C5C6D5CDA31B8, 0x6BF8F8C7F8933FED, 0xC28686228644A411 }; -const u64bit Whirlpool::C2[256] = { +const uint64_t Whirlpool::C2[256] = { 0x30D818186018C078, 0x462623238C2305AF, 0x91B8C6C63FC67EF9, 0xCDFBE8E887E8136F, 0x13CB878726874CA1, 0x6D11B8B8DAB8A962, 0x0209010104010805, 0x9E0D4F4F214F426E, 0x6C9B3636D836ADEE, 0x51FFA6A6A2A65904, 0xB90CD2D26FD2DEBD, 0xF70EF5F5F3F5FB06, @@ -207,7 +207,7 @@ const u64bit Whirlpool::C2[256] = { 0x85E2CCCC17CC2EDB, 0x8468424215422A57, 0x2D2C98985A98B4C2, 0x55EDA4A4AAA4490E, 0x50752828A0285D88, 0xB8865C5C6D5CDA31, 0xED6BF8F8C7F8933F, 0x11C28686228644A4 }; -const u64bit Whirlpool::C3[256] = { +const uint64_t Whirlpool::C3[256] = { 0x7830D818186018C0, 0xAF462623238C2305, 0xF991B8C6C63FC67E, 0x6FCDFBE8E887E813, 0xA113CB878726874C, 0x626D11B8B8DAB8A9, 0x0502090101040108, 0x6E9E0D4F4F214F42, 0xEE6C9B3636D836AD, 0x0451FFA6A6A2A659, 0xBDB90CD2D26FD2DE, 0x06F70EF5F5F3F5FB, @@ -273,7 +273,7 @@ const u64bit Whirlpool::C3[256] = { 0xDB85E2CCCC17CC2E, 0x578468424215422A, 0xC22D2C98985A98B4, 0x0E55EDA4A4AAA449, 0x8850752828A0285D, 0x31B8865C5C6D5CDA, 0x3FED6BF8F8C7F893, 0xA411C28686228644 }; -const u64bit Whirlpool::C4[256] = { +const uint64_t Whirlpool::C4[256] = { 0xC07830D818186018, 0x05AF462623238C23, 0x7EF991B8C6C63FC6, 0x136FCDFBE8E887E8, 0x4CA113CB87872687, 0xA9626D11B8B8DAB8, 0x0805020901010401, 0x426E9E0D4F4F214F, 0xADEE6C9B3636D836, 0x590451FFA6A6A2A6, 0xDEBDB90CD2D26FD2, 0xFB06F70EF5F5F3F5, @@ -339,7 +339,7 @@ const u64bit Whirlpool::C4[256] = { 0x2EDB85E2CCCC17CC, 0x2A57846842421542, 0xB4C22D2C98985A98, 0x490E55EDA4A4AAA4, 0x5D8850752828A028, 0xDA31B8865C5C6D5C, 0x933FED6BF8F8C7F8, 0x44A411C286862286 }; -const u64bit Whirlpool::C5[256] = { +const uint64_t Whirlpool::C5[256] = { 0x18C07830D8181860, 0x2305AF462623238C, 0xC67EF991B8C6C63F, 0xE8136FCDFBE8E887, 0x874CA113CB878726, 0xB8A9626D11B8B8DA, 0x0108050209010104, 0x4F426E9E0D4F4F21, 0x36ADEE6C9B3636D8, 0xA6590451FFA6A6A2, 0xD2DEBDB90CD2D26F, 0xF5FB06F70EF5F5F3, @@ -405,7 +405,7 @@ const u64bit Whirlpool::C5[256] = { 0xCC2EDB85E2CCCC17, 0x422A578468424215, 0x98B4C22D2C98985A, 0xA4490E55EDA4A4AA, 0x285D8850752828A0, 0x5CDA31B8865C5C6D, 0xF8933FED6BF8F8C7, 0x8644A411C2868622 }; -const u64bit Whirlpool::C6[256] = { +const uint64_t Whirlpool::C6[256] = { 0x6018C07830D81818, 0x8C2305AF46262323, 0x3FC67EF991B8C6C6, 0x87E8136FCDFBE8E8, 0x26874CA113CB8787, 0xDAB8A9626D11B8B8, 0x0401080502090101, 0x214F426E9E0D4F4F, 0xD836ADEE6C9B3636, 0xA2A6590451FFA6A6, 0x6FD2DEBDB90CD2D2, 0xF3F5FB06F70EF5F5, @@ -471,7 +471,7 @@ const u64bit Whirlpool::C6[256] = { 0x17CC2EDB85E2CCCC, 0x15422A5784684242, 0x5A98B4C22D2C9898, 0xAAA4490E55EDA4A4, 0xA0285D8850752828, 0x6D5CDA31B8865C5C, 0xC7F8933FED6BF8F8, 0x228644A411C28686 }; -const u64bit Whirlpool::C7[256] = { +const uint64_t Whirlpool::C7[256] = { 0x186018C07830D818, 0x238C2305AF462623, 0xC63FC67EF991B8C6, 0xE887E8136FCDFBE8, 0x8726874CA113CB87, 0xB8DAB8A9626D11B8, 0x0104010805020901, 0x4F214F426E9E0D4F, 0x36D836ADEE6C9B36, 0xA6A2A6590451FFA6, 0xD26FD2DEBDB90CD2, 0xF5F3F5FB06F70EF5, diff --git a/src/lib/hash/whirlpool/whrlpool.h b/src/lib/hash/whirlpool/whrlpool.h index d7db1de28..606fc3257 100644 --- a/src/lib/hash/whirlpool/whrlpool.h +++ b/src/lib/hash/whirlpool/whrlpool.h @@ -27,19 +27,19 @@ class BOTAN_DLL Whirlpool final : public MDx_HashFunction Whirlpool() : MDx_HashFunction(64, true, true, 32), m_M(8), m_digest(8) { clear(); } private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; - - static const u64bit C0[256]; - static const u64bit C1[256]; - static const u64bit C2[256]; - static const u64bit C3[256]; - static const u64bit C4[256]; - static const u64bit C5[256]; - static const u64bit C6[256]; - static const u64bit C7[256]; - - secure_vector<u64bit> m_M, m_digest; + void compress_n(const uint8_t[], size_t blocks) override; + void copy_out(uint8_t[]) override; + + static const uint64_t C0[256]; + static const uint64_t C1[256]; + static const uint64_t C2[256]; + static const uint64_t C3[256]; + static const uint64_t C4[256]; + static const uint64_t C5[256]; + static const uint64_t C6[256]; + static const uint64_t C7[256]; + + secure_vector<uint64_t> m_M, m_digest; }; } |