diff options
Diffstat (limited to 'src/lib/stream')
-rw-r--r-- | src/lib/stream/chacha/chacha.cpp | 56 | ||||
-rw-r--r-- | src/lib/stream/chacha/chacha.h | 16 | ||||
-rw-r--r-- | src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp | 2 | ||||
-rw-r--r-- | src/lib/stream/ctr/ctr.cpp | 10 | ||||
-rw-r--r-- | src/lib/stream/ctr/ctr.h | 10 | ||||
-rw-r--r-- | src/lib/stream/ofb/ofb.cpp | 8 | ||||
-rw-r--r-- | src/lib/stream/ofb/ofb.h | 10 | ||||
-rw-r--r-- | src/lib/stream/rc4/rc4.cpp | 12 | ||||
-rw-r--r-- | src/lib/stream/rc4/rc4.h | 16 | ||||
-rw-r--r-- | src/lib/stream/salsa20/salsa20.cpp | 56 | ||||
-rw-r--r-- | src/lib/stream/salsa20/salsa20.h | 12 | ||||
-rw-r--r-- | src/lib/stream/shake_cipher/shake_cipher.cpp | 8 | ||||
-rw-r--r-- | src/lib/stream/shake_cipher/shake_cipher.h | 10 | ||||
-rw-r--r-- | src/lib/stream/stream_cipher.h | 14 |
14 files changed, 120 insertions, 120 deletions
diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp index c74f60f2d..4befe1981 100644 --- a/src/lib/stream/chacha/chacha.cpp +++ b/src/lib/stream/chacha/chacha.cpp @@ -30,7 +30,7 @@ std::string ChaCha::provider() const } //static -void ChaCha::chacha_x4(byte output[64*4], u32bit input[16], size_t rounds) +void ChaCha::chacha_x4(uint8_t output[64*4], uint32_t input[16], size_t rounds) { BOTAN_ASSERT(rounds % 2 == 0, "Valid rounds"); @@ -44,7 +44,7 @@ void ChaCha::chacha_x4(byte output[64*4], u32bit input[16], size_t rounds) // TODO interleave rounds for(size_t i = 0; i != 4; ++i) { - u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], + uint32_t x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7], x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11], x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15]; @@ -114,7 +114,7 @@ void ChaCha::chacha_x4(byte output[64*4], u32bit input[16], size_t rounds) /* * Combine cipher stream with message */ -void ChaCha::cipher(const byte in[], byte out[], size_t length) +void ChaCha::cipher(const uint8_t in[], uint8_t out[], size_t length) { while(length >= m_buffer.size() - m_position) { @@ -134,18 +134,18 @@ void ChaCha::cipher(const byte in[], byte out[], size_t length) /* * ChaCha Key Schedule */ -void ChaCha::key_schedule(const byte key[], size_t length) +void ChaCha::key_schedule(const uint8_t key[], size_t length) { - static const u32bit TAU[] = + static const uint32_t TAU[] = { 0x61707865, 0x3120646e, 0x79622d36, 0x6b206574 }; - static const u32bit SIGMA[] = + static const uint32_t SIGMA[] = { 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 }; - const u32bit* CONSTANTS = (length == 16) ? TAU : SIGMA; + const uint32_t* CONSTANTS = (length == 16) ? TAU : SIGMA; // Repeat the key if 128 bits - const byte* key2 = (length == 32) ? key + 16 : key; + const uint8_t* key2 = (length == 32) ? key + 16 : key; m_position = 0; m_state.resize(16); @@ -156,22 +156,22 @@ void ChaCha::key_schedule(const byte key[], size_t length) m_state[2] = CONSTANTS[2]; m_state[3] = CONSTANTS[3]; - m_state[4] = load_le<u32bit>(key, 0); - m_state[5] = load_le<u32bit>(key, 1); - m_state[6] = load_le<u32bit>(key, 2); - m_state[7] = load_le<u32bit>(key, 3); + m_state[4] = load_le<uint32_t>(key, 0); + m_state[5] = load_le<uint32_t>(key, 1); + m_state[6] = load_le<uint32_t>(key, 2); + m_state[7] = load_le<uint32_t>(key, 3); - m_state[8] = load_le<u32bit>(key2, 0); - m_state[9] = load_le<u32bit>(key2, 1); - m_state[10] = load_le<u32bit>(key2, 2); - m_state[11] = load_le<u32bit>(key2, 3); + m_state[8] = load_le<uint32_t>(key2, 0); + m_state[9] = load_le<uint32_t>(key2, 1); + m_state[10] = load_le<uint32_t>(key2, 2); + m_state[11] = load_le<uint32_t>(key2, 3); // Default all-zero IV - const byte ZERO[8] = { 0 }; + const uint8_t ZERO[8] = { 0 }; set_iv(ZERO, sizeof(ZERO)); } -void ChaCha::set_iv(const byte iv[], size_t length) +void ChaCha::set_iv(const uint8_t iv[], size_t length) { if(!valid_iv_length(length)) throw Invalid_IV_Length(name(), length); @@ -181,14 +181,14 @@ void ChaCha::set_iv(const byte iv[], size_t length) if(length == 8) { - m_state[14] = load_le<u32bit>(iv, 0); - m_state[15] = load_le<u32bit>(iv, 1); + m_state[14] = load_le<uint32_t>(iv, 0); + m_state[15] = load_le<uint32_t>(iv, 1); } else if(length == 12) { - m_state[13] = load_le<u32bit>(iv, 0); - m_state[14] = load_le<u32bit>(iv, 1); - m_state[15] = load_le<u32bit>(iv, 2); + m_state[13] = load_le<uint32_t>(iv, 0); + m_state[14] = load_le<uint32_t>(iv, 1); + m_state[15] = load_le<uint32_t>(iv, 2); } chacha_x4(m_buffer.data(), m_state.data(), m_rounds); @@ -207,7 +207,7 @@ std::string ChaCha::name() const return "ChaCha(" + std::to_string(m_rounds) + ")"; } -void ChaCha::seek(u64bit offset) +void ChaCha::seek(uint64_t offset) { if (m_state.size() == 0 && m_buffer.size() == 0) { @@ -215,14 +215,14 @@ void ChaCha::seek(u64bit offset) } // Find the block offset - u64bit counter = offset / 64; + uint64_t counter = offset / 64; - byte out[8]; + uint8_t out[8]; store_le(counter, out); - m_state[12] = load_le<u32bit>(out, 0); - m_state[13] += load_le<u32bit>(out, 1); + m_state[12] = load_le<uint32_t>(out, 0); + m_state[13] += load_le<uint32_t>(out, 1); chacha_x4(m_buffer.data(), m_state.data(), m_rounds); m_position = offset % 64; diff --git a/src/lib/stream/chacha/chacha.h b/src/lib/stream/chacha/chacha.h index 6b1c989e2..876b9ca33 100644 --- a/src/lib/stream/chacha/chacha.h +++ b/src/lib/stream/chacha/chacha.h @@ -29,9 +29,9 @@ class BOTAN_DLL ChaCha final : public StreamCipher std::string provider() const override; - void cipher(const byte in[], byte out[], size_t length) override; + void cipher(const uint8_t in[], uint8_t out[], size_t length) override; - void set_iv(const byte iv[], size_t iv_len) override; + void set_iv(const uint8_t iv[], size_t iv_len) override; bool valid_iv_length(size_t iv_len) const override { return (iv_len == 8 || iv_len == 12); } @@ -45,20 +45,20 @@ class BOTAN_DLL ChaCha final : public StreamCipher std::string name() const override; - void seek(u64bit offset) override; + void seek(uint64_t offset) override; private: - void key_schedule(const byte key[], size_t key_len) override; + void key_schedule(const uint8_t key[], size_t key_len) override; - void chacha_x4(byte output[64*4], u32bit state[16], size_t rounds); + void chacha_x4(uint8_t output[64*4], uint32_t state[16], size_t rounds); #if defined(BOTAN_HAS_CHACHA_SSE2) - void chacha_sse2_x4(byte output[64*4], u32bit state[16], size_t rounds); + void chacha_sse2_x4(uint8_t output[64*4], uint32_t state[16], size_t rounds); #endif size_t m_rounds; - secure_vector<u32bit> m_state; - secure_vector<byte> m_buffer; + secure_vector<uint32_t> m_state; + secure_vector<uint8_t> m_buffer; size_t m_position = 0; }; diff --git a/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp b/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp index f28257fb8..9641be67b 100644 --- a/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp +++ b/src/lib/stream/chacha/chacha_sse2/chacha_sse2.cpp @@ -12,7 +12,7 @@ namespace Botan { //static BOTAN_FUNC_ISA("sse2") -void ChaCha::chacha_sse2_x4(byte output[64*4], u32bit input[16], size_t rounds) +void ChaCha::chacha_sse2_x4(uint8_t output[64*4], uint32_t input[16], size_t rounds) { BOTAN_ASSERT(rounds % 2 == 0, "Valid rounds"); diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp index c4552d459..728da3567 100644 --- a/src/lib/stream/ctr/ctr.cpp +++ b/src/lib/stream/ctr/ctr.cpp @@ -38,7 +38,7 @@ void CTR_BE::clear() m_pad_pos = 0; } -void CTR_BE::key_schedule(const byte key[], size_t key_len) +void CTR_BE::key_schedule(const uint8_t key[], size_t key_len) { m_cipher->set_key(key, key_len); @@ -51,7 +51,7 @@ std::string CTR_BE::name() const return ("CTR-BE(" + m_cipher->name() + ")"); } -void CTR_BE::cipher(const byte in[], byte out[], size_t length) +void CTR_BE::cipher(const uint8_t in[], uint8_t out[], size_t length) { while(length >= m_pad.size() - m_pad_pos) { @@ -65,7 +65,7 @@ void CTR_BE::cipher(const byte in[], byte out[], size_t length) m_pad_pos += length; } -void CTR_BE::set_iv(const byte iv[], size_t iv_len) +void CTR_BE::set_iv(const uint8_t iv[], size_t iv_len) { if(!valid_iv_length(iv_len)) throw Invalid_IV_Length(name(), iv_len); @@ -106,7 +106,7 @@ void CTR_BE::increment_counter() { const size_t off = i*bs + (bs-1-j); const uint16_t cnt = static_cast<uint16_t>(m_counter[off]) + carry; - m_counter[off] = static_cast<byte>(cnt); + m_counter[off] = static_cast<uint8_t>(cnt); carry = (cnt >> 8); } } @@ -115,7 +115,7 @@ void CTR_BE::increment_counter() m_pad_pos = 0; } -void CTR_BE::seek(u64bit) +void CTR_BE::seek(uint64_t) { throw Not_Implemented("CTR_BE::seek"); } diff --git a/src/lib/stream/ctr/ctr.h b/src/lib/stream/ctr/ctr.h index c4a28bd2b..345c4f6e8 100644 --- a/src/lib/stream/ctr/ctr.h +++ b/src/lib/stream/ctr/ctr.h @@ -19,9 +19,9 @@ namespace Botan { class BOTAN_DLL CTR_BE final : public StreamCipher { public: - void cipher(const byte in[], byte out[], size_t length) override; + void cipher(const uint8_t in[], uint8_t out[], size_t length) override; - void set_iv(const byte iv[], size_t iv_len) override; + void set_iv(const uint8_t iv[], size_t iv_len) override; bool valid_iv_length(size_t iv_len) const override { return (iv_len <= m_cipher->block_size()); } @@ -45,13 +45,13 @@ class BOTAN_DLL CTR_BE final : public StreamCipher CTR_BE(BlockCipher* cipher, size_t ctr_size); - void seek(u64bit offset) override; + void seek(uint64_t offset) override; private: - void key_schedule(const byte key[], size_t key_len) override; + void key_schedule(const uint8_t key[], size_t key_len) override; void increment_counter(); std::unique_ptr<BlockCipher> m_cipher; - secure_vector<byte> m_counter, m_pad; + secure_vector<uint8_t> m_counter, m_pad; size_t m_ctr_size; size_t m_pad_pos; }; diff --git a/src/lib/stream/ofb/ofb.cpp b/src/lib/stream/ofb/ofb.cpp index 0c23188d5..5a2d63dd4 100644 --- a/src/lib/stream/ofb/ofb.cpp +++ b/src/lib/stream/ofb/ofb.cpp @@ -23,7 +23,7 @@ void OFB::clear() m_buf_pos = 0; } -void OFB::key_schedule(const byte key[], size_t key_len) +void OFB::key_schedule(const uint8_t key[], size_t key_len) { m_cipher->set_key(key, key_len); @@ -36,7 +36,7 @@ std::string OFB::name() const return "OFB(" + m_cipher->name() + ")"; } -void OFB::cipher(const byte in[], byte out[], size_t length) +void OFB::cipher(const uint8_t in[], uint8_t out[], size_t length) { while(length >= m_buffer.size() - m_buf_pos) { @@ -51,7 +51,7 @@ void OFB::cipher(const byte in[], byte out[], size_t length) m_buf_pos += length; } -void OFB::set_iv(const byte iv[], size_t iv_len) +void OFB::set_iv(const uint8_t iv[], size_t iv_len) { if(!valid_iv_length(iv_len)) throw Invalid_IV_Length(name(), iv_len); @@ -64,7 +64,7 @@ void OFB::set_iv(const byte iv[], size_t iv_len) } -void OFB::seek(u64bit) +void OFB::seek(uint64_t) { throw Exception("OFB does not support seeking"); } diff --git a/src/lib/stream/ofb/ofb.h b/src/lib/stream/ofb/ofb.h index f8beb4956..29e015227 100644 --- a/src/lib/stream/ofb/ofb.h +++ b/src/lib/stream/ofb/ofb.h @@ -19,9 +19,9 @@ namespace Botan { class BOTAN_DLL OFB final : public StreamCipher { public: - void cipher(const byte in[], byte out[], size_t length) override; + void cipher(const uint8_t in[], uint8_t out[], size_t length) override; - void set_iv(const byte iv[], size_t iv_len) override; + void set_iv(const uint8_t iv[], size_t iv_len) override; bool valid_iv_length(size_t iv_len) const override { return (iv_len <= m_cipher->block_size()); } @@ -43,12 +43,12 @@ class BOTAN_DLL OFB final : public StreamCipher */ explicit OFB(BlockCipher* cipher); - void seek(u64bit offset) override; + void seek(uint64_t offset) override; private: - void key_schedule(const byte key[], size_t key_len) override; + void key_schedule(const uint8_t key[], size_t key_len) override; std::unique_ptr<BlockCipher> m_cipher; - secure_vector<byte> m_buffer; + secure_vector<uint8_t> m_buffer; size_t m_buf_pos; }; diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp index 47dc1ce29..208b2f560 100644 --- a/src/lib/stream/rc4/rc4.cpp +++ b/src/lib/stream/rc4/rc4.cpp @@ -13,7 +13,7 @@ namespace Botan { /* * Combine cipher stream with message */ -void RC4::cipher(const byte in[], byte out[], size_t length) +void RC4::cipher(const uint8_t in[], uint8_t out[], size_t length) { while(length >= m_buffer.size() - m_position) { @@ -27,7 +27,7 @@ void RC4::cipher(const byte in[], byte out[], size_t length) m_position += length; } -void RC4::set_iv(const byte*, size_t length) +void RC4::set_iv(const uint8_t*, size_t length) { if(length > 0) throw Exception("RC4 does not support an IV"); @@ -38,7 +38,7 @@ void RC4::set_iv(const byte*, size_t length) */ void RC4::generate() { - byte SX, SY; + uint8_t SX, SY; for(size_t i = 0; i != m_buffer.size(); i += 4) { SX = m_state[m_X+1]; m_Y = (m_Y + SX) % 256; SY = m_state[m_Y]; @@ -64,7 +64,7 @@ void RC4::generate() /* * RC4 Key Schedule */ -void RC4::key_schedule(const byte key[], size_t length) +void RC4::key_schedule(const uint8_t key[], size_t length) { m_state.resize(256); m_buffer.resize(256); @@ -72,7 +72,7 @@ void RC4::key_schedule(const byte key[], size_t length) m_position = m_X = m_Y = 0; for(size_t i = 0; i != 256; ++i) - m_state[i] = static_cast<byte>(i); + m_state[i] = static_cast<uint8_t>(i); for(size_t i = 0, state_index = 0; i != 256; ++i) { @@ -111,7 +111,7 @@ void RC4::clear() */ RC4::RC4(size_t s) : m_SKIP(s) {} -void RC4::seek(u64bit) +void RC4::seek(uint64_t) { throw Exception("RC4 does not support seeking"); } diff --git a/src/lib/stream/rc4/rc4.h b/src/lib/stream/rc4/rc4.h index 46715f7d2..938ab59cc 100644 --- a/src/lib/stream/rc4/rc4.h +++ b/src/lib/stream/rc4/rc4.h @@ -19,9 +19,9 @@ namespace Botan { class BOTAN_DLL RC4 final : public StreamCipher { public: - void cipher(const byte in[], byte out[], size_t length) override; + void cipher(const uint8_t in[], uint8_t out[], size_t length) override; - void set_iv(const byte iv[], size_t iv_len) override; + void set_iv(const uint8_t iv[], size_t iv_len) override; void clear() override; std::string name() const override; @@ -40,16 +40,16 @@ class BOTAN_DLL RC4 final : public StreamCipher ~RC4() { clear(); } - void seek(u64bit offset) override; + void seek(uint64_t offset) override; private: - void key_schedule(const byte[], size_t) override; + void key_schedule(const uint8_t[], size_t) override; void generate(); const size_t m_SKIP; - byte m_X = 0; - byte m_Y = 0; - secure_vector<byte> m_state; - secure_vector<byte> m_buffer; + uint8_t m_X = 0; + uint8_t m_Y = 0; + secure_vector<uint8_t> m_state; + secure_vector<uint8_t> m_buffer; size_t m_position = 0; }; diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp index 60bf19285..1c8846183 100644 --- a/src/lib/stream/salsa20/salsa20.cpp +++ b/src/lib/stream/salsa20/salsa20.cpp @@ -23,9 +23,9 @@ namespace { /* * Generate HSalsa20 cipher stream (for XSalsa20 IV setup) */ -void hsalsa20(u32bit output[8], const u32bit input[16]) +void hsalsa20(uint32_t output[8], const uint32_t input[16]) { - u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], + uint32_t x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7], x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11], x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15]; @@ -56,9 +56,9 @@ void hsalsa20(u32bit output[8], const u32bit input[16]) /* * Generate Salsa20 cipher stream */ -void salsa20(byte output[64], const u32bit input[16]) +void salsa20(uint8_t output[64], const uint32_t input[16]) { - u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], + uint32_t x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], x04 = input[ 4], x05 = input[ 5], x06 = input[ 6], x07 = input[ 7], x08 = input[ 8], x09 = input[ 9], x10 = input[10], x11 = input[11], x12 = input[12], x13 = input[13], x14 = input[14], x15 = input[15]; @@ -101,7 +101,7 @@ void salsa20(byte output[64], const u32bit input[16]) /* * Combine cipher stream with message */ -void Salsa20::cipher(const byte in[], byte out[], size_t length) +void Salsa20::cipher(const uint8_t in[], uint8_t out[], size_t length) { while(length >= m_buffer.size() - m_position) { @@ -125,15 +125,15 @@ void Salsa20::cipher(const byte in[], byte out[], size_t length) /* * Salsa20 Key Schedule */ -void Salsa20::key_schedule(const byte key[], size_t length) +void Salsa20::key_schedule(const uint8_t key[], size_t length) { - static const u32bit TAU[] = + static const uint32_t TAU[] = { 0x61707865, 0x3120646e, 0x79622d36, 0x6b206574 }; - static const u32bit SIGMA[] = + static const uint32_t SIGMA[] = { 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 }; - const u32bit* CONSTANTS = (length == 16) ? TAU : SIGMA; + const uint32_t* CONSTANTS = (length == 16) ? TAU : SIGMA; m_state.resize(16); m_buffer.resize(64); @@ -143,18 +143,18 @@ void Salsa20::key_schedule(const byte key[], size_t length) m_state[10] = CONSTANTS[2]; m_state[15] = CONSTANTS[3]; - m_state[1] = load_le<u32bit>(key, 0); - m_state[2] = load_le<u32bit>(key, 1); - m_state[3] = load_le<u32bit>(key, 2); - m_state[4] = load_le<u32bit>(key, 3); + m_state[1] = load_le<uint32_t>(key, 0); + m_state[2] = load_le<uint32_t>(key, 1); + m_state[3] = load_le<uint32_t>(key, 2); + m_state[4] = load_le<uint32_t>(key, 3); if(length == 32) key += 16; - m_state[11] = load_le<u32bit>(key, 0); - m_state[12] = load_le<u32bit>(key, 1); - m_state[13] = load_le<u32bit>(key, 2); - m_state[14] = load_le<u32bit>(key, 3); + m_state[11] = load_le<uint32_t>(key, 0); + m_state[12] = load_le<uint32_t>(key, 1); + m_state[13] = load_le<uint32_t>(key, 2); + m_state[14] = load_le<uint32_t>(key, 3); m_position = 0; @@ -164,7 +164,7 @@ void Salsa20::key_schedule(const byte key[], size_t length) /* * Set the Salsa IV */ -void Salsa20::set_iv(const byte iv[], size_t length) +void Salsa20::set_iv(const uint8_t iv[], size_t length) { if(!valid_iv_length(length)) throw Invalid_IV_Length(name(), length); @@ -178,26 +178,26 @@ void Salsa20::set_iv(const byte iv[], size_t length) else if(length == 8) { // Salsa20 - m_state[6] = load_le<u32bit>(iv, 0); - m_state[7] = load_le<u32bit>(iv, 1); + m_state[6] = load_le<uint32_t>(iv, 0); + m_state[7] = load_le<uint32_t>(iv, 1); } else { // XSalsa20 - m_state[6] = load_le<u32bit>(iv, 0); - m_state[7] = load_le<u32bit>(iv, 1); - m_state[8] = load_le<u32bit>(iv, 2); - m_state[9] = load_le<u32bit>(iv, 3); + m_state[6] = load_le<uint32_t>(iv, 0); + m_state[7] = load_le<uint32_t>(iv, 1); + m_state[8] = load_le<uint32_t>(iv, 2); + m_state[9] = load_le<uint32_t>(iv, 3); - secure_vector<u32bit> hsalsa(8); + secure_vector<uint32_t> hsalsa(8); hsalsa20(hsalsa.data(), m_state.data()); m_state[ 1] = hsalsa[0]; m_state[ 2] = hsalsa[1]; m_state[ 3] = hsalsa[2]; m_state[ 4] = hsalsa[3]; - m_state[ 6] = load_le<u32bit>(iv, 4); - m_state[ 7] = load_le<u32bit>(iv, 5); + m_state[ 6] = load_le<uint32_t>(iv, 4); + m_state[ 7] = load_le<uint32_t>(iv, 5); m_state[11] = hsalsa[4]; m_state[12] = hsalsa[5]; m_state[13] = hsalsa[6]; @@ -232,7 +232,7 @@ void Salsa20::clear() m_position = 0; } -void Salsa20::seek(u64bit) +void Salsa20::seek(uint64_t) { throw Not_Implemented("Salsa20::seek"); } diff --git a/src/lib/stream/salsa20/salsa20.h b/src/lib/stream/salsa20/salsa20.h index a128c5a98..935f5cf85 100644 --- a/src/lib/stream/salsa20/salsa20.h +++ b/src/lib/stream/salsa20/salsa20.h @@ -18,9 +18,9 @@ namespace Botan { class BOTAN_DLL Salsa20 final : public StreamCipher { public: - void cipher(const byte in[], byte out[], size_t length) override; + void cipher(const uint8_t in[], uint8_t out[], size_t length) override; - void set_iv(const byte iv[], size_t iv_len) override; + void set_iv(const uint8_t iv[], size_t iv_len) override; bool valid_iv_length(size_t iv_len) const override { return (iv_len == 0 || iv_len == 8 || iv_len == 24); } @@ -34,12 +34,12 @@ class BOTAN_DLL Salsa20 final : public StreamCipher std::string name() const override; StreamCipher* clone() const override { return new Salsa20; } - void seek(u64bit offset) override; + void seek(uint64_t offset) override; private: - void key_schedule(const byte key[], size_t key_len) override; + void key_schedule(const uint8_t key[], size_t key_len) override; - secure_vector<u32bit> m_state; - secure_vector<byte> m_buffer; + secure_vector<uint32_t> m_state; + secure_vector<uint8_t> m_buffer; size_t m_position = 0; }; diff --git a/src/lib/stream/shake_cipher/shake_cipher.cpp b/src/lib/stream/shake_cipher/shake_cipher.cpp index dc3c73299..4f79777f4 100644 --- a/src/lib/stream/shake_cipher/shake_cipher.cpp +++ b/src/lib/stream/shake_cipher/shake_cipher.cpp @@ -17,7 +17,7 @@ SHAKE_128_Cipher::SHAKE_128_Cipher() : m_buf_pos(0) {} -void SHAKE_128_Cipher::cipher(const byte in[], byte out[], size_t length) +void SHAKE_128_Cipher::cipher(const uint8_t in[], uint8_t out[], size_t length) { while(length >= m_buffer.size() - m_buf_pos) { @@ -35,7 +35,7 @@ void SHAKE_128_Cipher::cipher(const byte in[], byte out[], size_t length) m_buf_pos += length; } -void SHAKE_128_Cipher::key_schedule(const byte key[], size_t length) +void SHAKE_128_Cipher::key_schedule(const uint8_t key[], size_t length) { zeroise(m_state); @@ -58,7 +58,7 @@ void SHAKE_128_Cipher::clear() m_buf_pos = 0; } -void SHAKE_128_Cipher::set_iv(const byte[], size_t length) +void SHAKE_128_Cipher::set_iv(const uint8_t[], size_t length) { /* * This could be supported in some way (say, by treating iv as @@ -68,7 +68,7 @@ void SHAKE_128_Cipher::set_iv(const byte[], size_t length) throw Invalid_IV_Length(name(), length); } -void SHAKE_128_Cipher::seek(u64bit) +void SHAKE_128_Cipher::seek(uint64_t) { throw Not_Implemented("SHAKE_128_Cipher::seek"); } diff --git a/src/lib/stream/shake_cipher/shake_cipher.h b/src/lib/stream/shake_cipher/shake_cipher.h index 40915ecea..e15669f24 100644 --- a/src/lib/stream/shake_cipher/shake_cipher.h +++ b/src/lib/stream/shake_cipher/shake_cipher.h @@ -24,17 +24,17 @@ class BOTAN_DLL SHAKE_128_Cipher final : public StreamCipher /** * Produce more XOF output */ - void cipher(const byte in[], byte out[], size_t length) override; + void cipher(const uint8_t in[], uint8_t out[], size_t length) override; /** * Seeking is not supported, this function will throw */ - void seek(u64bit offset) override; + void seek(uint64_t offset) override; /** * IV not supported, this function will throw unless iv_len == 0 */ - void set_iv(const byte iv[], size_t iv_len) override; + void set_iv(const uint8_t iv[], size_t iv_len) override; bool valid_iv_length(size_t iv_len) const override { return (iv_len == 0); } @@ -52,10 +52,10 @@ class BOTAN_DLL SHAKE_128_Cipher final : public StreamCipher StreamCipher* clone() const override { return new SHAKE_128_Cipher; } private: - void key_schedule(const byte key[], size_t key_len) override; + void key_schedule(const uint8_t key[], size_t key_len) override; secure_vector<uint64_t> m_state; // internal state - secure_vector<byte> m_buffer; // ciphertext buffer + secure_vector<uint8_t> m_buffer; // ciphertext buffer size_t m_buf_pos; // position in m_buffer }; diff --git a/src/lib/stream/stream_cipher.h b/src/lib/stream/stream_cipher.h index 7654bf427..3c843cb87 100644 --- a/src/lib/stream/stream_cipher.h +++ b/src/lib/stream/stream_cipher.h @@ -54,7 +54,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * @param out the byte array to hold the output, i.e. the ciphertext * @param len the length of both in and out in bytes */ - virtual void cipher(const byte in[], byte out[], size_t len) = 0; + virtual void cipher(const uint8_t in[], uint8_t out[], size_t len) = 0; /** * Encrypt or decrypt a message @@ -62,7 +62,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * @param buf the plaintext / ciphertext * @param len the length of buf in bytes */ - void cipher1(byte buf[], size_t len) + void cipher1(uint8_t buf[], size_t len) { cipher(buf, buf, len); } /** @@ -71,7 +71,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * @param inout the plaintext / ciphertext */ template<typename Alloc> - void encipher(std::vector<byte, Alloc>& inout) + void encipher(std::vector<uint8_t, Alloc>& inout) { cipher(inout.data(), inout.data(), inout.size()); } /** @@ -80,7 +80,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * @param inout the plaintext / ciphertext */ template<typename Alloc> - void encrypt(std::vector<byte, Alloc>& inout) + void encrypt(std::vector<uint8_t, Alloc>& inout) { cipher(inout.data(), inout.data(), inout.size()); } /** @@ -89,7 +89,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * @param inout the plaintext / ciphertext */ template<typename Alloc> - void decrypt(std::vector<byte, Alloc>& inout) + void decrypt(std::vector<uint8_t, Alloc>& inout) { cipher(inout.data(), inout.data(), inout.size()); } /** @@ -97,7 +97,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * @param iv the initialization vector * @param iv_len the length of the IV in bytes */ - virtual void set_iv(const byte iv[], size_t iv_len) = 0; + virtual void set_iv(const uint8_t iv[], size_t iv_len) = 0; /** * @param iv_len the length of the IV in bytes @@ -114,7 +114,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm * Set the offset and the state used later to generate the keystream * @param offset the offset where we begin to generate the keystream */ - virtual void seek(u64bit offset) = 0; + virtual void seek(uint64_t offset) = 0; /** * @return provider information about this implementation. Default is "base", |