diff options
Diffstat (limited to 'src/lib/mac')
-rw-r--r-- | src/lib/mac/cbc_mac/cbc_mac.cpp | 6 | ||||
-rw-r--r-- | src/lib/mac/cbc_mac/cbc_mac.h | 8 | ||||
-rw-r--r-- | src/lib/mac/cmac/cmac.cpp | 14 | ||||
-rw-r--r-- | src/lib/mac/cmac/cmac.h | 10 | ||||
-rw-r--r-- | src/lib/mac/gmac/gmac.cpp | 14 | ||||
-rw-r--r-- | src/lib/mac/gmac/gmac.h | 16 | ||||
-rw-r--r-- | src/lib/mac/hmac/hmac.cpp | 8 | ||||
-rw-r--r-- | src/lib/mac/hmac/hmac.h | 8 | ||||
-rw-r--r-- | src/lib/mac/mac.cpp | 4 | ||||
-rw-r--r-- | src/lib/mac/mac.h | 12 | ||||
-rw-r--r-- | src/lib/mac/poly1305/poly1305.cpp | 64 | ||||
-rw-r--r-- | src/lib/mac/poly1305/poly1305.h | 10 | ||||
-rw-r--r-- | src/lib/mac/siphash/siphash.cpp | 24 | ||||
-rw-r--r-- | src/lib/mac/siphash/siphash.h | 12 | ||||
-rw-r--r-- | src/lib/mac/x919_mac/x919_mac.cpp | 6 | ||||
-rw-r--r-- | src/lib/mac/x919_mac/x919_mac.h | 8 |
16 files changed, 112 insertions, 112 deletions
diff --git a/src/lib/mac/cbc_mac/cbc_mac.cpp b/src/lib/mac/cbc_mac/cbc_mac.cpp index 741d550e5..b272fe3bc 100644 --- a/src/lib/mac/cbc_mac/cbc_mac.cpp +++ b/src/lib/mac/cbc_mac/cbc_mac.cpp @@ -12,7 +12,7 @@ namespace Botan { /* * Update an CBC-MAC Calculation */ -void CBC_MAC::add_data(const byte input[], size_t length) +void CBC_MAC::add_data(const uint8_t input[], size_t length) { size_t xored = std::min(output_length() - m_position, length); xor_buf(&m_state[m_position], input, xored); @@ -39,7 +39,7 @@ void CBC_MAC::add_data(const byte input[], size_t length) /* * Finalize an CBC-MAC Calculation */ -void CBC_MAC::final_result(byte mac[]) +void CBC_MAC::final_result(uint8_t mac[]) { if(m_position) m_cipher->encrypt(m_state); @@ -52,7 +52,7 @@ void CBC_MAC::final_result(byte mac[]) /* * CBC-MAC Key Schedule */ -void CBC_MAC::key_schedule(const byte key[], size_t length) +void CBC_MAC::key_schedule(const uint8_t key[], size_t length) { m_cipher->set_key(key, length); } diff --git a/src/lib/mac/cbc_mac/cbc_mac.h b/src/lib/mac/cbc_mac/cbc_mac.h index dd4877d1c..9ac870cb4 100644 --- a/src/lib/mac/cbc_mac/cbc_mac.h +++ b/src/lib/mac/cbc_mac/cbc_mac.h @@ -34,12 +34,12 @@ class BOTAN_DLL CBC_MAC final : public MessageAuthenticationCode */ explicit CBC_MAC(BlockCipher* cipher); 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; std::unique_ptr<BlockCipher> m_cipher; - secure_vector<byte> m_state; + secure_vector<uint8_t> m_state; size_t m_position = 0; }; diff --git a/src/lib/mac/cmac/cmac.cpp b/src/lib/mac/cmac/cmac.cpp index 9afd86cdb..bb862196f 100644 --- a/src/lib/mac/cmac/cmac.cpp +++ b/src/lib/mac/cmac/cmac.cpp @@ -12,16 +12,16 @@ namespace Botan { /* * Perform CMAC's multiplication in GF(2^n) */ -secure_vector<byte> CMAC::poly_double(const secure_vector<byte>& in) +secure_vector<uint8_t> CMAC::poly_double(const secure_vector<uint8_t>& in) { const bool top_carry = static_cast<bool>((in[0] & 0x80) != 0); - secure_vector<byte> out = in; + secure_vector<uint8_t> out = in; - byte carry = 0; + uint8_t carry = 0; for(size_t i = out.size(); i != 0; --i) { - byte temp = out[i-1]; + uint8_t temp = out[i-1]; out[i-1] = (temp << 1) | carry; carry = (temp >> 7); } @@ -55,7 +55,7 @@ secure_vector<byte> CMAC::poly_double(const secure_vector<byte>& in) /* * Update an CMAC Calculation */ -void CMAC::add_data(const byte input[], size_t length) +void CMAC::add_data(const uint8_t input[], size_t length) { buffer_insert(m_buffer, m_position, input, length); if(m_position + length > output_length()) @@ -80,7 +80,7 @@ void CMAC::add_data(const byte input[], size_t length) /* * Finalize an CMAC Calculation */ -void CMAC::final_result(byte mac[]) +void CMAC::final_result(uint8_t mac[]) { xor_buf(m_state, m_buffer, m_position); @@ -107,7 +107,7 @@ void CMAC::final_result(byte mac[]) /* * CMAC Key Schedule */ -void CMAC::key_schedule(const byte key[], size_t length) +void CMAC::key_schedule(const uint8_t key[], size_t length) { clear(); m_cipher->set_key(key, length); diff --git a/src/lib/mac/cmac/cmac.h b/src/lib/mac/cmac/cmac.h index 6897665c0..7127f82f2 100644 --- a/src/lib/mac/cmac/cmac.h +++ b/src/lib/mac/cmac/cmac.h @@ -34,7 +34,7 @@ class BOTAN_DLL CMAC final : public MessageAuthenticationCode * CMAC's polynomial doubling operation * @param in the input */ - static secure_vector<byte> poly_double(const secure_vector<byte>& in); + static secure_vector<uint8_t> poly_double(const secure_vector<uint8_t>& in); /** * @param cipher the block cipher to use @@ -44,12 +44,12 @@ class BOTAN_DLL CMAC final : public MessageAuthenticationCode CMAC(const CMAC&) = delete; CMAC& operator=(const CMAC&) = delete; 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; std::unique_ptr<BlockCipher> m_cipher; - secure_vector<byte> m_buffer, m_state, m_B, m_P; + secure_vector<uint8_t> m_buffer, m_state, m_B, m_P; size_t m_position; }; diff --git a/src/lib/mac/gmac/gmac.cpp b/src/lib/mac/gmac/gmac.cpp index 4461cf370..5e08a8827 100644 --- a/src/lib/mac/gmac/gmac.cpp +++ b/src/lib/mac/gmac/gmac.cpp @@ -37,7 +37,7 @@ size_t GMAC::output_length() const return GCM_BS; } -void GMAC::add_data(const byte input[], size_t size) +void GMAC::add_data(const uint8_t input[], size_t size) { m_ad_len += size; @@ -57,16 +57,16 @@ void GMAC::add_data(const byte input[], size_t size) } } -void GMAC::key_schedule(const byte key[], size_t size) +void GMAC::key_schedule(const uint8_t key[], size_t size) { clear(); m_cipher->set_key(key, size); m_cipher->encrypt(m_H_ad.data(), m_H.data()); } -void GMAC::start_msg(const byte nonce[], size_t nonce_len) +void GMAC::start_msg(const uint8_t nonce[], size_t nonce_len) { - secure_vector<byte> y0(GCM_BS); + secure_vector<uint8_t> y0(GCM_BS); if(nonce_len == 12) { @@ -79,13 +79,13 @@ void GMAC::start_msg(const byte nonce[], size_t nonce_len) add_final_block(y0, 0, nonce_len); } - secure_vector<byte> m_enc_y0(GCM_BS); + secure_vector<uint8_t> m_enc_y0(GCM_BS); m_cipher->encrypt(y0.data(), m_enc_y0.data()); GHASH::start(m_enc_y0.data(), m_enc_y0.size()); m_initialized = true; } -void GMAC::final_result(byte mac[]) +void GMAC::final_result(uint8_t mac[]) { // This ensures the GMAC computation has been initialized with a fresh // nonce. The aim of this check is to prevent developers from re-using @@ -101,7 +101,7 @@ void GMAC::final_result(byte mac[]) m_aad_buf.data(), m_aad_buf.size()); } - secure_vector<byte> result = GHASH::final(); + secure_vector<uint8_t> result = GHASH::final(); std::copy(result.begin(), result.end(), mac); clear(); } diff --git a/src/lib/mac/gmac/gmac.h b/src/lib/mac/gmac/gmac.h index b05c5451f..7735d3d32 100644 --- a/src/lib/mac/gmac/gmac.h +++ b/src/lib/mac/gmac/gmac.h @@ -35,7 +35,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode, * @param nonce Initialization vector. * @param nonce_len size of initialization vector. */ - void start(const byte nonce[], size_t nonce_len); + void start(const uint8_t nonce[], size_t nonce_len); /** * Must be called to set the initialization vector prior to GMAC @@ -43,7 +43,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode, * * @param nonce Initialization vector. */ - void start(const secure_vector<byte>& nonce); + void start(const secure_vector<uint8_t>& nonce); /** * Must be called to set the initialization vector prior to GMAC @@ -51,7 +51,7 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode, * * @param nonce Initialization vector. */ - void start(const std::vector<byte>& nonce); + void start(const std::vector<uint8_t>& nonce); Key_Length_Specification key_spec() const override { @@ -69,13 +69,13 @@ class BOTAN_DLL GMAC : public MessageAuthenticationCode, GMAC& operator=(const GMAC&) = delete; private: - void add_data(const byte[], size_t) override; - void final_result(byte[]) override; - void start_msg(const byte nonce[], size_t nonce_len) override; - void key_schedule(const byte key[], size_t size) override; + void add_data(const uint8_t[], size_t) override; + void final_result(uint8_t[]) override; + void start_msg(const uint8_t nonce[], size_t nonce_len) override; + void key_schedule(const uint8_t key[], size_t size) override; static const size_t GCM_BS = 16; - secure_vector<byte> m_aad_buf; + secure_vector<uint8_t> m_aad_buf; std::unique_ptr<BlockCipher> m_cipher; bool m_initialized; }; diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp index a2021515f..aeadf4520 100644 --- a/src/lib/mac/hmac/hmac.cpp +++ b/src/lib/mac/hmac/hmac.cpp @@ -13,7 +13,7 @@ namespace Botan { /* * Update a HMAC Calculation */ -void HMAC::add_data(const byte input[], size_t length) +void HMAC::add_data(const uint8_t input[], size_t length) { m_hash->update(input, length); } @@ -21,7 +21,7 @@ void HMAC::add_data(const byte input[], size_t length) /* * Finalize a HMAC Calculation */ -void HMAC::final_result(byte mac[]) +void HMAC::final_result(uint8_t mac[]) { m_hash->final(mac); m_hash->update(m_okey); @@ -33,7 +33,7 @@ void HMAC::final_result(byte mac[]) /* * HMAC Key Schedule */ -void HMAC::key_schedule(const byte key[], size_t length) +void HMAC::key_schedule(const uint8_t key[], size_t length) { m_hash->clear(); @@ -45,7 +45,7 @@ void HMAC::key_schedule(const byte key[], size_t length) if(length > m_hash->hash_block_size()) { - secure_vector<byte> hmac_key = m_hash->process(key, length); + secure_vector<uint8_t> hmac_key = m_hash->process(key, length); xor_buf(m_ikey, hmac_key, hmac_key.size()); xor_buf(m_okey, hmac_key, hmac_key.size()); } diff --git a/src/lib/mac/hmac/hmac.h b/src/lib/mac/hmac/hmac.h index bfb425fa8..6627475d1 100644 --- a/src/lib/mac/hmac/hmac.h +++ b/src/lib/mac/hmac/hmac.h @@ -39,12 +39,12 @@ class BOTAN_DLL HMAC final : public MessageAuthenticationCode HMAC(const HMAC&) = delete; HMAC& operator=(const HMAC&) = delete; 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; std::unique_ptr<HashFunction> m_hash; - secure_vector<byte> m_ikey, m_okey; + secure_vector<uint8_t> m_ikey, m_okey; }; } diff --git a/src/lib/mac/mac.cpp b/src/lib/mac/mac.cpp index 2fa321a67..3dfe753b7 100644 --- a/src/lib/mac/mac.cpp +++ b/src/lib/mac/mac.cpp @@ -145,9 +145,9 @@ MessageAuthenticationCode::create_or_throw(const std::string& algo, /* * Default (deterministic) MAC verification operation */ -bool MessageAuthenticationCode::verify_mac(const byte mac[], size_t length) +bool MessageAuthenticationCode::verify_mac(const uint8_t mac[], size_t length) { - secure_vector<byte> our_mac = final(); + secure_vector<uint8_t> our_mac = final(); if(our_mac.size() != length) return false; diff --git a/src/lib/mac/mac.h b/src/lib/mac/mac.h index d7808c1bf..44bdd3da4 100644 --- a/src/lib/mac/mac.h +++ b/src/lib/mac/mac.h @@ -63,7 +63,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, * Default implementation simply rejects all non-empty nonces * since most hash/MAC algorithms do not support randomization */ - virtual void start_msg(const byte nonce[], size_t nonce_len) + virtual void start_msg(const uint8_t nonce[], size_t nonce_len) { BOTAN_UNUSED(nonce); if(nonce_len > 0) @@ -76,7 +76,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, * @param nonce the per message nonce */ template<typename Alloc> - void start(const std::vector<byte, Alloc>& nonce) + void start(const std::vector<uint8_t, Alloc>& nonce) { start_msg(nonce.data(), nonce.size()); } @@ -86,7 +86,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, * @param nonce the per message nonce * @param nonce_len length of nonce */ - void start(const byte nonce[], size_t nonce_len) + void start(const uint8_t nonce[], size_t nonce_len) { start_msg(nonce, nonce_len); } @@ -105,14 +105,14 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, * @param length the length of param in * @return true if the MAC is valid, false otherwise */ - virtual bool verify_mac(const byte in[], size_t length); + virtual bool verify_mac(const uint8_t in[], size_t length); /** * Verify a MAC. * @param in the MAC to verify as a byte array * @return true if the MAC is valid, false otherwise */ - virtual bool verify_mac(const std::vector<byte>& in) + virtual bool verify_mac(const std::vector<uint8_t>& in) { return verify_mac(in.data(), in.size()); } @@ -122,7 +122,7 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, * @param in the MAC to verify as a byte array * @return true if the MAC is valid, false otherwise */ - virtual bool verify_mac(const secure_vector<byte>& in) + virtual bool verify_mac(const secure_vector<uint8_t>& in) { return verify_mac(in.data(), in.size()); } diff --git a/src/lib/mac/poly1305/poly1305.cpp b/src/lib/mac/poly1305/poly1305.cpp index 0a62808f6..9fe0bad0a 100644 --- a/src/lib/mac/poly1305/poly1305.cpp +++ b/src/lib/mac/poly1305/poly1305.cpp @@ -17,11 +17,11 @@ namespace Botan { namespace { -void poly1305_init(secure_vector<u64bit>& X, const byte key[32]) +void poly1305_init(secure_vector<uint64_t>& X, const uint8_t key[32]) { /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */ - const u64bit t0 = load_le<u64bit>(key, 0); - const u64bit t1 = load_le<u64bit>(key, 1); + const uint64_t t0 = load_le<uint64_t>(key, 0); + const uint64_t t1 = load_le<uint64_t>(key, 1); X[0] = ( t0 ) & 0xffc0fffffff; X[1] = ((t0 >> 44) | (t1 << 20)) & 0xfffffc0ffff; @@ -33,34 +33,34 @@ void poly1305_init(secure_vector<u64bit>& X, const byte key[32]) X[5] = 0; /* save pad for later */ - X[6] = load_le<u64bit>(key, 2); - X[7] = load_le<u64bit>(key, 3); + X[6] = load_le<uint64_t>(key, 2); + X[7] = load_le<uint64_t>(key, 3); } -void poly1305_blocks(secure_vector<u64bit>& X, const byte *m, size_t blocks, bool is_final = false) +void poly1305_blocks(secure_vector<uint64_t>& X, const uint8_t *m, size_t blocks, bool is_final = false) { #if !defined(BOTAN_TARGET_HAS_NATIVE_UINT128) typedef donna128 uint128_t; #endif - const u64bit hibit = is_final ? 0 : (static_cast<u64bit>(1) << 40); /* 1 << 128 */ + const uint64_t hibit = is_final ? 0 : (static_cast<uint64_t>(1) << 40); /* 1 << 128 */ - const u64bit r0 = X[0]; - const u64bit r1 = X[1]; - const u64bit r2 = X[2]; + const uint64_t r0 = X[0]; + const uint64_t r1 = X[1]; + const uint64_t r2 = X[2]; - u64bit h0 = X[3+0]; - u64bit h1 = X[3+1]; - u64bit h2 = X[3+2]; + uint64_t h0 = X[3+0]; + uint64_t h1 = X[3+1]; + uint64_t h2 = X[3+2]; - const u64bit s1 = r1 * (5 << 2); - const u64bit s2 = r2 * (5 << 2); + const uint64_t s1 = r1 * (5 << 2); + const uint64_t s2 = r2 * (5 << 2); while(blocks--) { /* h += m[i] */ - const u64bit t0 = load_le<u64bit>(m, 0); - const u64bit t1 = load_le<u64bit>(m, 1); + const uint64_t t0 = load_le<uint64_t>(m, 0); + const uint64_t t1 = load_le<uint64_t>(m, 1); h0 += (( t0 ) & 0xfffffffffff); h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff); @@ -72,7 +72,7 @@ void poly1305_blocks(secure_vector<u64bit>& X, const byte *m, size_t blocks, boo uint128_t d2 = uint128_t(h0) * r2 + uint128_t(h1) * r1 + uint128_t(h2) * r0; /* (partial) h %= p */ - u64bit c = carry_shift(d0, 44); h0 = d0 & 0xfffffffffff; + uint64_t c = carry_shift(d0, 44); h0 = d0 & 0xfffffffffff; d1 += c; c = carry_shift(d1, 44); h1 = d1 & 0xfffffffffff; d2 += c; c = carry_shift(d2, 42); h2 = d2 & 0x3ffffffffff; h0 += c * 5; c = carry_shift(h0, 44); h0 = h0 & 0xfffffffffff; @@ -86,14 +86,14 @@ void poly1305_blocks(secure_vector<u64bit>& X, const byte *m, size_t blocks, boo X[3+2] = h2; } -void poly1305_finish(secure_vector<u64bit>& X, byte mac[16]) +void poly1305_finish(secure_vector<uint64_t>& X, uint8_t mac[16]) { /* fully carry h */ - u64bit h0 = X[3+0]; - u64bit h1 = X[3+1]; - u64bit h2 = X[3+2]; + uint64_t h0 = X[3+0]; + uint64_t h1 = X[3+1]; + uint64_t h2 = X[3+2]; - u64bit c; + uint64_t c; c = (h1 >> 44); h1 &= 0xfffffffffff; h2 += c; c = (h2 >> 42); h2 &= 0x3ffffffffff; h0 += c * 5; c = (h0 >> 44); h0 &= 0xfffffffffff; @@ -103,12 +103,12 @@ void poly1305_finish(secure_vector<u64bit>& X, byte mac[16]) h1 += c; /* compute h + -p */ - u64bit g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff; - u64bit g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff; - u64bit g2 = h2 + c - (static_cast<u64bit>(1) << 42); + uint64_t g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff; + uint64_t g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff; + uint64_t g2 = h2 + c - (static_cast<uint64_t>(1) << 42); /* select h if h < p, or h + -p if h >= p */ - c = (g2 >> ((sizeof(u64bit) * 8) - 1)) - 1; + c = (g2 >> ((sizeof(uint64_t) * 8) - 1)) - 1; g0 &= c; g1 &= c; g2 &= c; @@ -118,8 +118,8 @@ void poly1305_finish(secure_vector<u64bit>& X, byte mac[16]) h2 = (h2 & c) | g2; /* h = (h + pad) */ - const u64bit t0 = X[6]; - const u64bit t1 = X[7]; + const uint64_t t0 = X[6]; + const uint64_t t1 = X[7]; h0 += (( t0 ) & 0xfffffffffff) ; c = (h0 >> 44); h0 &= 0xfffffffffff; h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff) + c; c = (h1 >> 44); h1 &= 0xfffffffffff; @@ -144,7 +144,7 @@ void Poly1305::clear() m_buf_pos = 0; } -void Poly1305::key_schedule(const byte key[], size_t) +void Poly1305::key_schedule(const uint8_t key[], size_t) { m_buf_pos = 0; m_buf.resize(16); @@ -153,7 +153,7 @@ void Poly1305::key_schedule(const byte key[], size_t) poly1305_init(m_poly, key); } -void Poly1305::add_data(const byte input[], size_t length) +void Poly1305::add_data(const uint8_t input[], size_t length) { BOTAN_ASSERT_EQUAL(m_poly.size(), 8, "Initialized"); @@ -180,7 +180,7 @@ void Poly1305::add_data(const byte input[], size_t length) m_buf_pos += remaining; } -void Poly1305::final_result(byte out[]) +void Poly1305::final_result(uint8_t out[]) { BOTAN_ASSERT_EQUAL(m_poly.size(), 8, "Initialized"); diff --git a/src/lib/mac/poly1305/poly1305.h b/src/lib/mac/poly1305/poly1305.h index 740313122..25ee70761 100644 --- a/src/lib/mac/poly1305/poly1305.h +++ b/src/lib/mac/poly1305/poly1305.h @@ -34,12 +34,12 @@ class BOTAN_DLL Poly1305 final : public MessageAuthenticationCode } 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; - secure_vector<u64bit> m_poly; - secure_vector<byte> m_buf; + secure_vector<uint64_t> m_poly; + secure_vector<uint8_t> m_buf; size_t m_buf_pos = 0; }; 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<u64bit>& V, size_t r) +void SipRounds(uint64_t M, secure_vector<uint64_t>& 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<u64bit>& 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<u64bit>(input[0]) << 56); + m_mbuf = (m_mbuf >> 8) | (static_cast<uint64_t>(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<u64bit>(input, 0), m_V, m_C); + SipRounds(load_le<uint64_t>(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<u64bit>(input[i]) << 56); + m_mbuf = (m_mbuf >> 8) | (static_cast<uint64_t>(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<u64bit>(m_words) << 56); + m_mbuf = (m_mbuf >> (64-m_mbuf_pos*8)) | (static_cast<uint64_t>(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<u64bit>(key, 0); - const u64bit K1 = load_le<u64bit>(key, 1); + const uint64_t K0 = load_le<uint64_t>(key, 0); + const uint64_t K1 = load_le<uint64_t>(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<u64bit> m_V; - u64bit m_mbuf = 0; + secure_vector<uint64_t> m_V; + uint64_t m_mbuf = 0; size_t m_mbuf_pos = 0; - byte m_words = 0; + uint8_t m_words = 0; }; } diff --git a/src/lib/mac/x919_mac/x919_mac.cpp b/src/lib/mac/x919_mac/x919_mac.cpp index 205d812c2..189108377 100644 --- a/src/lib/mac/x919_mac/x919_mac.cpp +++ b/src/lib/mac/x919_mac/x919_mac.cpp @@ -12,7 +12,7 @@ namespace Botan { /* * Update an ANSI X9.19 MAC Calculation */ -void ANSI_X919_MAC::add_data(const byte input[], size_t length) +void ANSI_X919_MAC::add_data(const uint8_t input[], size_t length) { size_t xored = std::min(8 - m_position, length); xor_buf(&m_state[m_position], input, xored); @@ -38,7 +38,7 @@ void ANSI_X919_MAC::add_data(const byte input[], size_t length) /* * Finalize an ANSI X9.19 MAC Calculation */ -void ANSI_X919_MAC::final_result(byte mac[]) +void ANSI_X919_MAC::final_result(uint8_t mac[]) { if(m_position) m_des1->encrypt(m_state); @@ -51,7 +51,7 @@ void ANSI_X919_MAC::final_result(byte mac[]) /* * ANSI X9.19 MAC Key Schedule */ -void ANSI_X919_MAC::key_schedule(const byte key[], size_t length) +void ANSI_X919_MAC::key_schedule(const uint8_t key[], size_t length) { m_des1->set_key(key, 8); diff --git a/src/lib/mac/x919_mac/x919_mac.h b/src/lib/mac/x919_mac/x919_mac.h index 904931d20..8e300cb34 100644 --- a/src/lib/mac/x919_mac/x919_mac.h +++ b/src/lib/mac/x919_mac/x919_mac.h @@ -35,12 +35,12 @@ class BOTAN_DLL ANSI_X919_MAC final : public MessageAuthenticationCode ANSI_X919_MAC(const ANSI_X919_MAC&) = delete; ANSI_X919_MAC& operator=(const ANSI_X919_MAC&) = delete; 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; std::unique_ptr<BlockCipher> m_des1, m_des2; - secure_vector<byte> m_state; + secure_vector<uint8_t> m_state; size_t m_position; }; |