aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/aead
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/modes/aead')
-rw-r--r--src/lib/modes/aead/aead.h6
-rw-r--r--src/lib/modes/aead/ccm/ccm.cpp60
-rw-r--r--src/lib/modes/aead/ccm/ccm.h24
-rw-r--r--src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp30
-rw-r--r--src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h12
-rw-r--r--src/lib/modes/aead/eax/eax.cpp22
-rw-r--r--src/lib/modes/aead/eax/eax.h14
-rw-r--r--src/lib/modes/aead/gcm/clmul/clmul.cpp2
-rw-r--r--src/lib/modes/aead/gcm/clmul/clmul.h2
-rw-r--r--src/lib/modes/aead/gcm/gcm.cpp72
-rw-r--r--src/lib/modes/aead/gcm/gcm.h38
-rw-r--r--src/lib/modes/aead/ocb/ocb.cpp74
-rw-r--r--src/lib/modes/aead/ocb/ocb.h26
-rw-r--r--src/lib/modes/aead/siv/siv.cpp26
-rw-r--r--src/lib/modes/aead/siv/siv.h22
15 files changed, 215 insertions, 215 deletions
diff --git a/src/lib/modes/aead/aead.h b/src/lib/modes/aead/aead.h
index 2cdc6137e..3d3c7287f 100644
--- a/src/lib/modes/aead/aead.h
+++ b/src/lib/modes/aead/aead.h
@@ -36,7 +36,7 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
* @param ad the associated data
* @param ad_len length of add in bytes
*/
- virtual void set_associated_data(const byte ad[], size_t ad_len) = 0;
+ virtual void set_associated_data(const uint8_t ad[], size_t ad_len) = 0;
/**
* Set associated data that is not included in the ciphertext but
@@ -48,7 +48,7 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
* @param ad the associated data
*/
template<typename Alloc>
- void set_associated_data_vec(const std::vector<byte, Alloc>& ad)
+ void set_associated_data_vec(const std::vector<uint8_t, Alloc>& ad)
{
set_associated_data(ad.data(), ad.size());
}
@@ -63,7 +63,7 @@ class BOTAN_DLL AEAD_Mode : public Cipher_Mode
* @param ad the associated data
*/
template<typename Alloc>
- void set_ad(const std::vector<byte, Alloc>& ad)
+ void set_ad(const std::vector<uint8_t, Alloc>& ad)
{
set_associated_data(ad.data(), ad.size());
}
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp
index de639f23a..db0d2d58b 100644
--- a/src/lib/modes/aead/ccm/ccm.cpp
+++ b/src/lib/modes/aead/ccm/ccm.cpp
@@ -65,7 +65,7 @@ size_t CCM_Mode::update_granularity() const
/*
This value does not particularly matter as regardless CCM_Mode::update
buffers all input, so in theory this could be 1. However as for instance
- Transform_Filter creates update_granularity() byte buffers, use a
+ Transform_Filter creates update_granularity() uint8_t buffers, use a
somewhat large size to avoid bouncing on a tiny buffer.
*/
return m_cipher->parallel_bytes();
@@ -76,12 +76,12 @@ Key_Length_Specification CCM_Mode::key_spec() const
return m_cipher->key_spec();
}
-void CCM_Mode::key_schedule(const byte key[], size_t length)
+void CCM_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
}
-void CCM_Mode::set_associated_data(const byte ad[], size_t length)
+void CCM_Mode::set_associated_data(const uint8_t ad[], size_t length)
{
m_ad_buf.clear();
@@ -90,15 +90,15 @@ void CCM_Mode::set_associated_data(const byte ad[], size_t length)
// FIXME: support larger AD using length encoding rules
BOTAN_ASSERT(length < (0xFFFF - 0xFF), "Supported CCM AD length");
- m_ad_buf.push_back(get_byte(0, static_cast<u16bit>(length)));
- m_ad_buf.push_back(get_byte(1, static_cast<u16bit>(length)));
+ m_ad_buf.push_back(get_byte(0, static_cast<uint16_t>(length)));
+ m_ad_buf.push_back(get_byte(1, static_cast<uint16_t>(length)));
m_ad_buf += std::make_pair(ad, length);
while(m_ad_buf.size() % CCM_BS)
m_ad_buf.push_back(0); // pad with zeros to full block size
}
}
-void CCM_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void CCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -113,7 +113,7 @@ size_t CCM_Mode::process(uint8_t buf[], size_t sz)
return 0; // no output until finished
}
-void CCM_Mode::encode_length(size_t len, byte out[])
+void CCM_Mode::encode_length(size_t len, uint8_t out[])
{
const size_t len_bytes = L();
@@ -125,18 +125,18 @@ void CCM_Mode::encode_length(size_t len, byte out[])
BOTAN_ASSERT((len >> (len_bytes*8)) == 0, "Message length fits in field");
}
-void CCM_Mode::inc(secure_vector<byte>& C)
+void CCM_Mode::inc(secure_vector<uint8_t>& C)
{
for(size_t i = 0; i != C.size(); ++i)
if(++C[C.size()-i-1])
break;
}
-secure_vector<byte> CCM_Mode::format_b0(size_t sz)
+secure_vector<uint8_t> CCM_Mode::format_b0(size_t sz)
{
- secure_vector<byte> B0(CCM_BS);
+ secure_vector<uint8_t> B0(CCM_BS);
- const byte b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);
+ const uint8_t b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);
B0[0] = b_flags;
copy_mem(&B0[1], m_nonce.data(), m_nonce.size());
@@ -145,11 +145,11 @@ secure_vector<byte> CCM_Mode::format_b0(size_t sz)
return B0;
}
-secure_vector<byte> CCM_Mode::format_c0()
+secure_vector<uint8_t> CCM_Mode::format_c0()
{
- secure_vector<byte> C(CCM_BS);
+ secure_vector<uint8_t> C(CCM_BS);
- const byte a_flags = L()-1;
+ const uint8_t a_flags = L()-1;
C[0] = a_flags;
copy_mem(&C[1], m_nonce.data(), m_nonce.size());
@@ -157,21 +157,21 @@ secure_vector<byte> CCM_Mode::format_c0()
return C;
}
-void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CCM_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
- const secure_vector<byte>& ad = ad_buf();
+ const secure_vector<uint8_t>& ad = ad_buf();
BOTAN_ASSERT(ad.size() % CCM_BS == 0, "AD is block size multiple");
const BlockCipher& E = cipher();
- secure_vector<byte> T(CCM_BS);
+ secure_vector<uint8_t> T(CCM_BS);
E.encrypt(format_b0(sz), T);
for(size_t i = 0; i != ad.size(); i += CCM_BS)
@@ -180,14 +180,14 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
E.encrypt(T);
}
- secure_vector<byte> C = format_c0();
- secure_vector<byte> S0(CCM_BS);
+ secure_vector<uint8_t> C = format_c0();
+ secure_vector<uint8_t> S0(CCM_BS);
E.encrypt(C, S0);
inc(C);
- secure_vector<byte> X(CCM_BS);
+ secure_vector<uint8_t> X(CCM_BS);
- const byte* buf_end = &buf[sz];
+ const uint8_t* buf_end = &buf[sz];
while(buf != buf_end)
{
@@ -208,23 +208,23 @@ void CCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer += std::make_pair(T.data(), tag_size());
}
-void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CCM_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
- const secure_vector<byte>& ad = ad_buf();
+ const secure_vector<uint8_t>& ad = ad_buf();
BOTAN_ASSERT(ad.size() % CCM_BS == 0, "AD is block size multiple");
const BlockCipher& E = cipher();
- secure_vector<byte> T(CCM_BS);
+ secure_vector<uint8_t> T(CCM_BS);
E.encrypt(format_b0(sz - tag_size()), T);
for(size_t i = 0; i != ad.size(); i += CCM_BS)
@@ -233,15 +233,15 @@ void CCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
E.encrypt(T);
}
- secure_vector<byte> C = format_c0();
+ secure_vector<uint8_t> C = format_c0();
- secure_vector<byte> S0(CCM_BS);
+ secure_vector<uint8_t> S0(CCM_BS);
E.encrypt(C, S0);
inc(C);
- secure_vector<byte> X(CCM_BS);
+ secure_vector<uint8_t> X(CCM_BS);
- const byte* buf_end = &buf[sz - tag_size()];
+ const uint8_t* buf_end = &buf[sz - tag_size()];
while(buf != buf_end)
{
diff --git a/src/lib/modes/aead/ccm/ccm.h b/src/lib/modes/aead/ccm/ccm.h
index 9795354fc..93dd0d7e1 100644
--- a/src/lib/modes/aead/ccm/ccm.h
+++ b/src/lib/modes/aead/ccm/ccm.h
@@ -25,7 +25,7 @@ class BOTAN_DLL CCM_Mode : public AEAD_Mode
public:
size_t process(uint8_t buf[], size_t sz) override;
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -50,26 +50,26 @@ class BOTAN_DLL CCM_Mode : public AEAD_Mode
const BlockCipher& cipher() const { return *m_cipher; }
- void encode_length(size_t len, byte out[]);
+ void encode_length(size_t len, uint8_t out[]);
- void inc(secure_vector<byte>& C);
+ void inc(secure_vector<uint8_t>& C);
- const secure_vector<byte>& ad_buf() const { return m_ad_buf; }
+ const secure_vector<uint8_t>& ad_buf() const { return m_ad_buf; }
- secure_vector<byte>& msg_buf() { return m_msg_buf; }
+ secure_vector<uint8_t>& msg_buf() { return m_msg_buf; }
- secure_vector<byte> format_b0(size_t msg_size);
- secure_vector<byte> format_c0();
+ secure_vector<uint8_t> format_b0(size_t msg_size);
+ secure_vector<uint8_t> format_c0();
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
const size_t m_tag_size;
const size_t m_L;
std::unique_ptr<BlockCipher> m_cipher;
- secure_vector<byte> m_nonce, m_msg_buf, m_ad_buf;
+ secure_vector<uint8_t> m_nonce, m_msg_buf, m_ad_buf;
};
/**
@@ -88,7 +88,7 @@ class BOTAN_DLL CCM_Encryption final : public CCM_Mode
CCM_Encryption(BlockCipher* cipher, size_t tag_size = 16, size_t L = 3) :
CCM_Mode(cipher, tag_size, L) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{ return input_length + tag_size(); }
@@ -112,7 +112,7 @@ class BOTAN_DLL CCM_Decryption final : public CCM_Mode
CCM_Decryption(BlockCipher* cipher, size_t tag_size = 16, size_t L = 3) :
CCM_Mode(cipher, tag_size, L) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
index 197d6f921..64169a9b8 100644
--- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
+++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp
@@ -37,12 +37,12 @@ void ChaCha20Poly1305_Mode::reset()
m_nonce_len = 0;
}
-void ChaCha20Poly1305_Mode::key_schedule(const byte key[], size_t length)
+void ChaCha20Poly1305_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_chacha->set_key(key, length);
}
-void ChaCha20Poly1305_Mode::set_associated_data(const byte ad[], size_t length)
+void ChaCha20Poly1305_Mode::set_associated_data(const uint8_t ad[], size_t length)
{
if(m_ctext_len)
throw Exception("Too late to set AD for ChaCha20Poly1305");
@@ -51,12 +51,12 @@ void ChaCha20Poly1305_Mode::set_associated_data(const byte ad[], size_t length)
void ChaCha20Poly1305_Mode::update_len(size_t len)
{
- byte len8[8] = { 0 };
- store_le(static_cast<u64bit>(len), len8);
+ uint8_t len8[8] = { 0 };
+ store_le(static_cast<uint64_t>(len), len8);
m_poly1305->update(len8, 8);
}
-void ChaCha20Poly1305_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void ChaCha20Poly1305_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -66,7 +66,7 @@ void ChaCha20Poly1305_Mode::start_msg(const byte nonce[], size_t nonce_len)
m_chacha->set_iv(nonce, nonce_len);
- secure_vector<byte> init(64); // zeros
+ secure_vector<uint8_t> init(64); // zeros
m_chacha->encrypt(init);
m_poly1305->set_key(init.data(), 32);
@@ -78,7 +78,7 @@ void ChaCha20Poly1305_Mode::start_msg(const byte nonce[], size_t nonce_len)
{
if(m_ad.size() % 16)
{
- const byte zeros[16] = { 0 };
+ const uint8_t zeros[16] = { 0 };
m_poly1305->update(zeros, 16 - m_ad.size() % 16);
}
}
@@ -96,21 +96,21 @@ size_t ChaCha20Poly1305_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void ChaCha20Poly1305_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void ChaCha20Poly1305_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
if(cfrg_version())
{
if(m_ctext_len % 16)
{
- const byte zeros[16] = { 0 };
+ const uint8_t zeros[16] = { 0 };
m_poly1305->update(zeros, 16 - m_ctext_len % 16);
}
update_len(m_ad.size());
}
update_len(m_ctext_len);
- const secure_vector<byte> mac = m_poly1305->final();
+ const secure_vector<uint8_t> mac = m_poly1305->final();
buffer += std::make_pair(mac.data(), tag_size());
m_ctext_len = 0;
}
@@ -123,11 +123,11 @@ size_t ChaCha20Poly1305_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void ChaCha20Poly1305_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void ChaCha20Poly1305_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -144,16 +144,16 @@ void ChaCha20Poly1305_Decryption::finish(secure_vector<byte>& buffer, size_t off
{
if(m_ctext_len % 16)
{
- const byte zeros[16] = { 0 };
+ const uint8_t zeros[16] = { 0 };
m_poly1305->update(zeros, 16 - m_ctext_len % 16);
}
update_len(m_ad.size());
}
update_len(m_ctext_len);
- const secure_vector<byte> mac = m_poly1305->final();
+ const secure_vector<uint8_t> mac = m_poly1305->final();
- const byte* included_tag = &buf[remaining];
+ const uint8_t* included_tag = &buf[remaining];
m_ctext_len = 0;
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h
index 58328ac5b..4245e5e01 100644
--- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h
+++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.h
@@ -24,7 +24,7 @@ namespace Botan {
class BOTAN_DLL ChaCha20Poly1305_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override { return "ChaCha20Poly1305"; }
@@ -47,16 +47,16 @@ class BOTAN_DLL ChaCha20Poly1305_Mode : public AEAD_Mode
ChaCha20Poly1305_Mode();
- secure_vector<byte> m_ad;
+ secure_vector<uint8_t> m_ad;
size_t m_nonce_len = 0;
size_t m_ctext_len = 0;
bool cfrg_version() const { return m_nonce_len == 12; }
void update_len(size_t len);
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
};
/**
@@ -72,7 +72,7 @@ class BOTAN_DLL ChaCha20Poly1305_Encryption final : public ChaCha20Poly1305_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -91,7 +91,7 @@ class BOTAN_DLL ChaCha20Poly1305_Decryption final : public ChaCha20Poly1305_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
}
diff --git a/src/lib/modes/aead/eax/eax.cpp b/src/lib/modes/aead/eax/eax.cpp
index ba52efcfd..4889ac21a 100644
--- a/src/lib/modes/aead/eax/eax.cpp
+++ b/src/lib/modes/aead/eax/eax.cpp
@@ -18,9 +18,9 @@ namespace {
/*
* EAX MAC-based PRF
*/
-secure_vector<byte> eax_prf(byte tag, size_t block_size,
+secure_vector<uint8_t> eax_prf(uint8_t tag, size_t block_size,
MessageAuthenticationCode& mac,
- const byte in[], size_t length)
+ const uint8_t in[], size_t length)
{
for(size_t i = 0; i != block_size - 1; ++i)
{
@@ -78,7 +78,7 @@ Key_Length_Specification EAX_Mode::key_spec() const
/*
* Set the EAX key
*/
-void EAX_Mode::key_schedule(const byte key[], size_t length)
+void EAX_Mode::key_schedule(const uint8_t key[], size_t length)
{
/*
* These could share the key schedule, which is one nice part of EAX,
@@ -91,12 +91,12 @@ void EAX_Mode::key_schedule(const byte key[], size_t length)
/*
* Set the EAX associated data
*/
-void EAX_Mode::set_associated_data(const byte ad[], size_t length)
+void EAX_Mode::set_associated_data(const uint8_t ad[], size_t length)
{
m_ad_mac = eax_prf(1, block_size(), *m_cmac, ad, length);
}
-void EAX_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void EAX_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -117,11 +117,11 @@ size_t EAX_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void EAX_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void EAX_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
update(buffer, offset);
- secure_vector<byte> data_mac = m_cmac->final();
+ secure_vector<uint8_t> data_mac = m_cmac->final();
xor_buf(data_mac, m_nonce_mac, data_mac.size());
if(m_ad_mac.empty())
@@ -141,11 +141,11 @@ size_t EAX_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void EAX_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void EAX_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "Have the tag as part of final input");
@@ -157,9 +157,9 @@ void EAX_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
m_ctr->cipher(buf, buf, remaining);
}
- const byte* included_tag = &buf[remaining];
+ const uint8_t* included_tag = &buf[remaining];
- secure_vector<byte> mac = m_cmac->final();
+ secure_vector<uint8_t> mac = m_cmac->final();
mac ^= m_nonce_mac;
if(m_ad_mac.empty())
diff --git a/src/lib/modes/aead/eax/eax.h b/src/lib/modes/aead/eax/eax.h
index c0b6bcf42..fc991ab1f 100644
--- a/src/lib/modes/aead/eax/eax.h
+++ b/src/lib/modes/aead/eax/eax.h
@@ -22,7 +22,7 @@ namespace Botan {
class BOTAN_DLL EAX_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -54,13 +54,13 @@ class BOTAN_DLL EAX_Mode : public AEAD_Mode
std::unique_ptr<StreamCipher> m_ctr;
std::unique_ptr<MessageAuthenticationCode> m_cmac;
- secure_vector<byte> m_ad_mac;
+ secure_vector<uint8_t> m_ad_mac;
- secure_vector<byte> m_nonce_mac;
+ secure_vector<uint8_t> m_nonce_mac;
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
};
/**
@@ -83,7 +83,7 @@ class BOTAN_DLL EAX_Encryption final : public EAX_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -109,7 +109,7 @@ class BOTAN_DLL EAX_Decryption final : public EAX_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
}
diff --git a/src/lib/modes/aead/gcm/clmul/clmul.cpp b/src/lib/modes/aead/gcm/clmul/clmul.cpp
index 725ef3da3..ed3473b4e 100644
--- a/src/lib/modes/aead/gcm/clmul/clmul.cpp
+++ b/src/lib/modes/aead/gcm/clmul/clmul.cpp
@@ -12,7 +12,7 @@
namespace Botan {
BOTAN_FUNC_ISA("pclmul,ssse3")
-void gcm_multiply_clmul(byte x[16], const byte H[16])
+void gcm_multiply_clmul(uint8_t x[16], const uint8_t H[16])
{
/*
* Algorithms 1 and 5 from Intel's CLMUL guide
diff --git a/src/lib/modes/aead/gcm/clmul/clmul.h b/src/lib/modes/aead/gcm/clmul/clmul.h
index a3d8d9851..5e4a0de35 100644
--- a/src/lib/modes/aead/gcm/clmul/clmul.h
+++ b/src/lib/modes/aead/gcm/clmul/clmul.h
@@ -12,7 +12,7 @@
namespace Botan {
-void gcm_multiply_clmul(byte x[16], const byte H[16]);
+void gcm_multiply_clmul(uint8_t x[16], const uint8_t H[16]);
}
diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp
index e0bc59a8d..0d0cbff3c 100644
--- a/src/lib/modes/aead/gcm/gcm.cpp
+++ b/src/lib/modes/aead/gcm/gcm.cpp
@@ -20,21 +20,21 @@ namespace Botan {
static const size_t GCM_BS = 16;
-void GHASH::gcm_multiply(secure_vector<byte>& x) const
+void GHASH::gcm_multiply(secure_vector<uint8_t>& x) const
{
#if defined(BOTAN_HAS_GCM_CLMUL)
if(CPUID::has_clmul())
return gcm_multiply_clmul(x.data(), m_H.data());
#endif
- static const u64bit R = 0xE100000000000000;
+ static const uint64_t R = 0xE100000000000000;
- u64bit H[2] = {
- load_be<u64bit>(m_H.data(), 0),
- load_be<u64bit>(m_H.data(), 1)
+ uint64_t H[2] = {
+ load_be<uint64_t>(m_H.data(), 0),
+ load_be<uint64_t>(m_H.data(), 1)
};
- u64bit Z[2] = { 0, 0 };
+ uint64_t Z[2] = { 0, 0 };
CT::poison(H, 2);
CT::poison(Z, 2);
@@ -44,30 +44,30 @@ void GHASH::gcm_multiply(secure_vector<byte>& x) const
for(size_t i = 0; i != 2; ++i)
{
- const u64bit X = load_be<u64bit>(x.data(), i);
+ const uint64_t X = load_be<uint64_t>(x.data(), i);
- u64bit mask = 0x8000000000000000;
+ uint64_t mask = 0x8000000000000000;
for(size_t j = 0; j != 64; ++j)
{
- const u64bit XMASK = CT::expand_mask<u64bit>(X & mask);
+ const uint64_t XMASK = CT::expand_mask<uint64_t>(X & mask);
mask >>= 1;
Z[0] ^= H[0] & XMASK;
Z[1] ^= H[1] & XMASK;
// GCM's bit ops are reversed so we carry out of the bottom
- const u64bit carry = R & CT::expand_mask<u64bit>(H[1] & 1);
+ const uint64_t carry = R & CT::expand_mask<uint64_t>(H[1] & 1);
H[1] = (H[1] >> 1) | (H[0] << 63);
H[0] = (H[0] >> 1) ^ carry;
}
}
- store_be<u64bit>(x.data(), Z[0], Z[1]);
+ store_be<uint64_t>(x.data(), Z[0], Z[1]);
CT::unpoison(x.data(), x.size());
}
-void GHASH::ghash_update(secure_vector<byte>& ghash,
- const byte input[], size_t length)
+void GHASH::ghash_update(secure_vector<uint8_t>& ghash,
+ const uint8_t input[], size_t length)
{
/*
This assumes if less than block size input then we're just on the
@@ -86,7 +86,7 @@ void GHASH::ghash_update(secure_vector<byte>& ghash,
}
}
-void GHASH::key_schedule(const byte key[], size_t length)
+void GHASH::key_schedule(const uint8_t key[], size_t length)
{
m_H.assign(key, key+length);
m_H_ad.resize(GCM_BS);
@@ -94,13 +94,13 @@ void GHASH::key_schedule(const byte key[], size_t length)
m_text_len = 0;
}
-void GHASH::start(const byte nonce[], size_t len)
+void GHASH::start(const uint8_t nonce[], size_t len)
{
m_nonce.assign(nonce, nonce + len);
m_ghash = m_H_ad;
}
-void GHASH::set_associated_data(const byte input[], size_t length)
+void GHASH::set_associated_data(const uint8_t input[], size_t length)
{
zeroise(m_H_ad);
@@ -108,7 +108,7 @@ void GHASH::set_associated_data(const byte input[], size_t length)
m_ad_len = length;
}
-void GHASH::update(const byte input[], size_t length)
+void GHASH::update(const uint8_t input[], size_t length)
{
BOTAN_ASSERT(m_ghash.size() == GCM_BS, "Key was set");
@@ -117,19 +117,19 @@ void GHASH::update(const byte input[], size_t length)
ghash_update(m_ghash, input, length);
}
-void GHASH::add_final_block(secure_vector<byte>& hash,
+void GHASH::add_final_block(secure_vector<uint8_t>& hash,
size_t ad_len, size_t text_len)
{
- secure_vector<byte> final_block(GCM_BS);
- store_be<u64bit>(final_block.data(), 8*ad_len, 8*text_len);
+ secure_vector<uint8_t> final_block(GCM_BS);
+ store_be<uint64_t>(final_block.data(), 8*ad_len, 8*text_len);
ghash_update(hash, final_block.data(), final_block.size());
}
-secure_vector<byte> GHASH::final()
+secure_vector<uint8_t> GHASH::final()
{
add_final_block(m_ghash, m_ad_len, m_text_len);
- secure_vector<byte> mac;
+ secure_vector<uint8_t> mac;
mac.swap(m_ghash);
mac ^= m_nonce;
@@ -137,10 +137,10 @@ secure_vector<byte> GHASH::final()
return mac;
}
-secure_vector<byte> GHASH::nonce_hash(const byte nonce[], size_t nonce_len)
+secure_vector<uint8_t> GHASH::nonce_hash(const uint8_t nonce[], size_t nonce_len)
{
BOTAN_ASSERT(m_ghash.size() == 0, "nonce_hash called during wrong time");
- secure_vector<byte> y0(GCM_BS);
+ secure_vector<uint8_t> y0(GCM_BS);
ghash_update(y0, nonce, nonce_len);
add_final_block(y0, 0, nonce_len);
@@ -217,29 +217,29 @@ Key_Length_Specification GCM_Mode::key_spec() const
return m_ctr->key_spec();
}
-void GCM_Mode::key_schedule(const byte key[], size_t keylen)
+void GCM_Mode::key_schedule(const uint8_t key[], size_t keylen)
{
m_ctr->set_key(key, keylen);
- const std::vector<byte> zeros(GCM_BS);
+ const std::vector<uint8_t> zeros(GCM_BS);
m_ctr->set_iv(zeros.data(), zeros.size());
- secure_vector<byte> H(GCM_BS);
+ secure_vector<uint8_t> H(GCM_BS);
m_ctr->encipher(H);
m_ghash->set_key(H);
}
-void GCM_Mode::set_associated_data(const byte ad[], size_t ad_len)
+void GCM_Mode::set_associated_data(const uint8_t ad[], size_t ad_len)
{
m_ghash->set_associated_data(ad, ad_len);
}
-void GCM_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void GCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
- secure_vector<byte> y0(GCM_BS);
+ secure_vector<uint8_t> y0(GCM_BS);
if(nonce_len == 12)
{
@@ -253,7 +253,7 @@ void GCM_Mode::start_msg(const byte nonce[], size_t nonce_len)
m_ctr->set_iv(y0.data(), y0.size());
- secure_vector<byte> m_enc_y0(GCM_BS);
+ secure_vector<uint8_t> m_enc_y0(GCM_BS);
m_ctr->encipher(m_enc_y0);
m_ghash->start(m_enc_y0.data(), m_enc_y0.size());
@@ -267,11 +267,11 @@ size_t GCM_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void GCM_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void GCM_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ARG_CHECK(offset <= buffer.size());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
m_ctr->cipher(buf, buf, sz);
m_ghash->update(buf, sz);
@@ -287,11 +287,11 @@ size_t GCM_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void GCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void GCM_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ARG_CHECK(offset <= buffer.size());
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
if(sz < tag_size())
throw Exception("Insufficient input for GCM decryption, tag missing");
@@ -307,7 +307,7 @@ void GCM_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
auto mac = m_ghash->final();
- const byte* included_tag = &buffer[remaining+offset];
+ const uint8_t* included_tag = &buffer[remaining+offset];
if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("GCM tag check failed");
diff --git a/src/lib/modes/aead/gcm/gcm.h b/src/lib/modes/aead/gcm/gcm.h
index 65b6b0474..e2e3a2c9d 100644
--- a/src/lib/modes/aead/gcm/gcm.h
+++ b/src/lib/modes/aead/gcm/gcm.h
@@ -23,7 +23,7 @@ class GHASH;
class BOTAN_DLL GCM_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -52,9 +52,9 @@ class BOTAN_DLL GCM_Mode : public AEAD_Mode
std::unique_ptr<StreamCipher> m_ctr;
std::unique_ptr<GHASH> m_ghash;
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
};
/**
@@ -77,7 +77,7 @@ class BOTAN_DLL GCM_Encryption final : public GCM_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -103,7 +103,7 @@ class BOTAN_DLL GCM_Decryption final : public GCM_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
};
/**
@@ -113,18 +113,18 @@ class BOTAN_DLL GCM_Decryption final : public GCM_Mode
class BOTAN_DLL GHASH : public SymmetricAlgorithm
{
public:
- void set_associated_data(const byte ad[], size_t ad_len);
+ void set_associated_data(const uint8_t ad[], size_t ad_len);
- secure_vector<byte> nonce_hash(const byte nonce[], size_t len);
+ secure_vector<uint8_t> nonce_hash(const uint8_t nonce[], size_t len);
- void start(const byte nonce[], size_t len);
+ void start(const uint8_t nonce[], size_t len);
/*
* Assumes input len is multiple of 16
*/
- void update(const byte in[], size_t len);
+ void update(const uint8_t in[], size_t len);
- secure_vector<byte> final();
+ secure_vector<uint8_t> final();
Key_Length_Specification key_spec() const override
{ return Key_Length_Specification(16); }
@@ -135,23 +135,23 @@ class BOTAN_DLL GHASH : public SymmetricAlgorithm
std::string name() const override { return "GHASH"; }
protected:
- void ghash_update(secure_vector<byte>& x,
- const byte input[], size_t input_len);
+ void ghash_update(secure_vector<uint8_t>& x,
+ const uint8_t input[], size_t input_len);
- void add_final_block(secure_vector<byte>& x,
+ void add_final_block(secure_vector<uint8_t>& x,
size_t ad_len, size_t pt_len);
- secure_vector<byte> m_H;
- secure_vector<byte> m_H_ad;
- secure_vector<byte> m_ghash;
+ secure_vector<uint8_t> m_H;
+ secure_vector<uint8_t> m_H_ad;
+ secure_vector<uint8_t> m_ghash;
size_t m_ad_len = 0;
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 gcm_multiply(secure_vector<byte>& x) const;
+ void gcm_multiply(secure_vector<uint8_t>& x) const;
- secure_vector<byte> m_nonce;
+ secure_vector<uint8_t> m_nonce;
size_t m_text_len = 0;
};
diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp
index c530dda5d..84787ad38 100644
--- a/src/lib/modes/aead/ocb/ocb.cpp
+++ b/src/lib/modes/aead/ocb/ocb.cpp
@@ -24,13 +24,13 @@ class L_computer
m_L.push_back(poly_double(dollar()));
}
- const secure_vector<byte>& star() const { return m_L_star; }
+ const secure_vector<uint8_t>& star() const { return m_L_star; }
- const secure_vector<byte>& dollar() const { return m_L_dollar; }
+ const secure_vector<uint8_t>& dollar() const { return m_L_dollar; }
- const secure_vector<byte>& operator()(size_t i) const { return get(i); }
+ const secure_vector<uint8_t>& operator()(size_t i) const { return get(i); }
- const secure_vector<byte>& compute_offsets(secure_vector<byte>& offset,
+ const secure_vector<uint8_t>& compute_offsets(secure_vector<uint8_t>& offset,
size_t block_index,
size_t blocks) const
{
@@ -46,7 +46,7 @@ class L_computer
}
private:
- const secure_vector<byte>& get(size_t i) const
+ const secure_vector<uint8_t>& get(size_t i) const
{
while(m_L.size() <= i)
m_L.push_back(poly_double(m_L.back()));
@@ -54,14 +54,14 @@ class L_computer
return m_L.at(i);
}
- secure_vector<byte> poly_double(const secure_vector<byte>& in) const
+ secure_vector<uint8_t> poly_double(const secure_vector<uint8_t>& in) const
{
return CMAC::poly_double(in);
}
- secure_vector<byte> m_L_dollar, m_L_star;
- mutable std::vector<secure_vector<byte>> m_L;
- mutable secure_vector<byte> m_offset_buf;
+ secure_vector<uint8_t> m_L_dollar, m_L_star;
+ mutable std::vector<secure_vector<uint8_t>> m_L;
+ mutable secure_vector<uint8_t> m_offset_buf;
};
namespace {
@@ -69,14 +69,14 @@ namespace {
/*
* OCB's HASH
*/
-secure_vector<byte> ocb_hash(const L_computer& L,
+secure_vector<uint8_t> ocb_hash(const L_computer& L,
const BlockCipher& cipher,
- const byte ad[], size_t ad_len)
+ const uint8_t ad[], size_t ad_len)
{
- secure_vector<byte> sum(16);
- secure_vector<byte> offset(16);
+ secure_vector<uint8_t> sum(16);
+ secure_vector<uint8_t> offset(16);
- secure_vector<byte> buf(16);
+ secure_vector<uint8_t> buf(16);
const size_t ad_blocks = (ad_len / 16);
const size_t ad_remainder = (ad_len % 16);
@@ -165,30 +165,30 @@ Key_Length_Specification OCB_Mode::key_spec() const
return m_cipher->key_spec();
}
-void OCB_Mode::key_schedule(const byte key[], size_t length)
+void OCB_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
m_L.reset(new L_computer(*m_cipher));
}
-void OCB_Mode::set_associated_data(const byte ad[], size_t ad_len)
+void OCB_Mode::set_associated_data(const uint8_t ad[], size_t ad_len)
{
BOTAN_ASSERT(m_L, "A key was set");
m_ad_hash = ocb_hash(*m_L, *m_cipher, ad, ad_len);
}
-secure_vector<byte>
-OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len)
+secure_vector<uint8_t>
+OCB_Mode::update_nonce(const uint8_t nonce[], size_t nonce_len)
{
BOTAN_ASSERT(nonce_len < 16, "OCB nonce is less than cipher block size");
- secure_vector<byte> nonce_buf(16);
+ secure_vector<uint8_t> nonce_buf(16);
copy_mem(&nonce_buf[16 - nonce_len], nonce, nonce_len);
nonce_buf[0] = ((tag_size() * 8) % 128) << 1;
nonce_buf[16 - nonce_len - 1] = 1;
- const byte bottom = nonce_buf[16-1] & 0x3F;
+ const uint8_t bottom = nonce_buf[16-1] & 0x3F;
nonce_buf[16-1] &= 0xC0;
const bool need_new_stretch = (m_last_nonce != nonce_buf);
@@ -210,7 +210,7 @@ OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len)
const size_t shift_bytes = bottom / 8;
const size_t shift_bits = bottom % 8;
- secure_vector<byte> offset(16);
+ secure_vector<uint8_t> offset(16);
for(size_t i = 0; i != 16; ++i)
{
offset[i] = (m_stretch[i+shift_bytes] << shift_bits);
@@ -220,7 +220,7 @@ OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len)
return offset;
}
-void OCB_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void OCB_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -232,7 +232,7 @@ void OCB_Mode::start_msg(const byte nonce[], size_t nonce_len)
m_block_index = 0;
}
-void OCB_Encryption::encrypt(byte buffer[], size_t blocks)
+void OCB_Encryption::encrypt(uint8_t buffer[], size_t blocks)
{
const size_t par_blocks = m_checksum.size() / 16;
@@ -262,11 +262,11 @@ size_t OCB_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void OCB_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
if(sz)
{
@@ -278,27 +278,27 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
if(remainder_bytes)
{
BOTAN_ASSERT(remainder_bytes < 16, "Only a partial block left");
- byte* remainder = &buf[sz - remainder_bytes];
+ uint8_t* remainder = &buf[sz - remainder_bytes];
xor_buf(m_checksum.data(), remainder, remainder_bytes);
m_checksum[remainder_bytes] ^= 0x80;
m_offset ^= m_L->star(); // Offset_*
- secure_vector<byte> zeros(16);
+ secure_vector<uint8_t> zeros(16);
m_cipher->encrypt(m_offset, zeros);
xor_buf(remainder, zeros.data(), remainder_bytes);
}
}
- secure_vector<byte> checksum(16);
+ secure_vector<uint8_t> checksum(16);
// fold checksum
for(size_t i = 0; i != m_checksum.size(); ++i)
checksum[i % checksum.size()] ^= m_checksum[i];
// now compute the tag
- secure_vector<byte> mac = m_offset;
+ secure_vector<uint8_t> mac = m_offset;
mac ^= checksum;
mac ^= m_L->dollar();
@@ -313,7 +313,7 @@ void OCB_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
m_block_index = 0;
}
-void OCB_Decryption::decrypt(byte buffer[], size_t blocks)
+void OCB_Decryption::decrypt(uint8_t buffer[], size_t blocks)
{
const size_t par_bytes = m_cipher->parallel_bytes();
@@ -347,11 +347,11 @@ size_t OCB_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void OCB_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
@@ -368,11 +368,11 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
{
BOTAN_ASSERT(final_bytes < 16, "Only a partial block left");
- byte* remainder = &buf[remaining - final_bytes];
+ uint8_t* remainder = &buf[remaining - final_bytes];
m_offset ^= m_L->star(); // Offset_*
- secure_vector<byte> pad(16);
+ secure_vector<uint8_t> pad(16);
m_cipher->encrypt(m_offset, pad); // P_*
xor_buf(remainder, pad.data(), final_bytes);
@@ -382,14 +382,14 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
}
}
- secure_vector<byte> checksum(16);
+ secure_vector<uint8_t> checksum(16);
// fold checksum
for(size_t i = 0; i != m_checksum.size(); ++i)
checksum[i % checksum.size()] ^= m_checksum[i];
// compute the mac
- secure_vector<byte> mac = m_offset;
+ secure_vector<uint8_t> mac = m_offset;
mac ^= checksum;
mac ^= m_L->dollar();
@@ -403,7 +403,7 @@ void OCB_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
m_block_index = 0;
// compare mac
- const byte* included_tag = &buf[remaining];
+ const uint8_t* included_tag = &buf[remaining];
if(!same_mem(mac.data(), included_tag, tag_size()))
throw Integrity_Failure("OCB tag check failed");
diff --git a/src/lib/modes/aead/ocb/ocb.h b/src/lib/modes/aead/ocb/ocb.h
index dfdb8c18c..cac87ddb6 100644
--- a/src/lib/modes/aead/ocb/ocb.h
+++ b/src/lib/modes/aead/ocb/ocb.h
@@ -28,7 +28,7 @@ class L_computer;
class BOTAN_DLL OCB_Mode : public AEAD_Mode
{
public:
- void set_associated_data(const byte ad[], size_t ad_len) override;
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override;
std::string name() const override;
@@ -58,19 +58,19 @@ class BOTAN_DLL OCB_Mode : public AEAD_Mode
size_t m_block_index = 0;
- secure_vector<byte> m_checksum;
- secure_vector<byte> m_offset;
- secure_vector<byte> m_ad_hash;
+ secure_vector<uint8_t> m_checksum;
+ secure_vector<uint8_t> m_offset;
+ secure_vector<uint8_t> m_ad_hash;
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<byte> update_nonce(const byte nonce[], size_t nonce_len);
+ secure_vector<uint8_t> update_nonce(const uint8_t nonce[], size_t nonce_len);
size_t m_tag_size = 0;
- secure_vector<byte> m_last_nonce;
- secure_vector<byte> m_stretch;
+ secure_vector<uint8_t> m_last_nonce;
+ secure_vector<uint8_t> m_stretch;
};
class BOTAN_DLL OCB_Encryption final : public OCB_Mode
@@ -90,9 +90,9 @@ class BOTAN_DLL OCB_Encryption final : public OCB_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
private:
- void encrypt(byte input[], size_t blocks);
+ void encrypt(uint8_t input[], size_t blocks);
};
class BOTAN_DLL OCB_Decryption final : public OCB_Mode
@@ -115,9 +115,9 @@ class BOTAN_DLL OCB_Decryption final : public OCB_Mode
size_t process(uint8_t buf[], size_t size) override;
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
private:
- void decrypt(byte input[], size_t blocks);
+ void decrypt(uint8_t input[], size_t blocks);
};
}
diff --git a/src/lib/modes/aead/siv/siv.cpp b/src/lib/modes/aead/siv/siv.cpp
index 373a2627c..c4db3d785 100644
--- a/src/lib/modes/aead/siv/siv.cpp
+++ b/src/lib/modes/aead/siv/siv.cpp
@@ -51,7 +51,7 @@ size_t SIV_Mode::update_granularity() const
/*
This value does not particularly matter as regardless SIV_Mode::update
buffers all input, so in theory this could be 1. However as for instance
- Transform_Filter creates update_granularity() byte buffers, use a
+ Transform_Filter creates update_granularity() uint8_t buffers, use a
somewhat large size to avoid bouncing on a tiny buffer.
*/
return 128;
@@ -62,7 +62,7 @@ Key_Length_Specification SIV_Mode::key_spec() const
return m_cmac->key_spec().multiple(2);
}
-void SIV_Mode::key_schedule(const byte key[], size_t length)
+void SIV_Mode::key_schedule(const uint8_t key[], size_t length)
{
const size_t keylen = length / 2;
m_cmac->set_key(key, keylen);
@@ -70,7 +70,7 @@ void SIV_Mode::key_schedule(const byte key[], size_t length)
m_ad_macs.clear();
}
-void SIV_Mode::set_associated_data_n(size_t n, const byte ad[], size_t length)
+void SIV_Mode::set_associated_data_n(size_t n, const uint8_t ad[], size_t length)
{
if(n >= m_ad_macs.size())
m_ad_macs.resize(n+1);
@@ -78,7 +78,7 @@ void SIV_Mode::set_associated_data_n(size_t n, const byte ad[], size_t length)
m_ad_macs[n] = m_cmac->process(ad, length);
}
-void SIV_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void SIV_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -98,11 +98,11 @@ size_t SIV_Mode::process(uint8_t buf[], size_t sz)
return 0;
}
-secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len)
+secure_vector<uint8_t> SIV_Mode::S2V(const uint8_t* text, size_t text_len)
{
- const byte zero[16] = { 0 };
+ const uint8_t zero[16] = { 0 };
- secure_vector<byte> V = m_cmac->process(zero, 16);
+ secure_vector<uint8_t> V = m_cmac->process(zero, 16);
for(size_t i = 0; i != m_ad_macs.size(); ++i)
{
@@ -131,7 +131,7 @@ secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len)
return m_cmac->final();
}
-void SIV_Mode::set_ctr_iv(secure_vector<byte> V)
+void SIV_Mode::set_ctr_iv(secure_vector<uint8_t> V)
{
V[8] &= 0x7F;
V[12] &= 0x7F;
@@ -139,13 +139,13 @@ void SIV_Mode::set_ctr_iv(secure_vector<byte> V)
ctr().set_iv(V.data(), V.size());
}
-void SIV_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void SIV_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
buffer.insert(buffer.begin() + offset, msg_buf().begin(), msg_buf().end());
- secure_vector<byte> V = S2V(buffer.data() + offset, buffer.size() - offset);
+ secure_vector<uint8_t> V = S2V(buffer.data() + offset, buffer.size() - offset);
buffer.insert(buffer.begin() + offset, V.begin(), V.end());
@@ -153,7 +153,7 @@ void SIV_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
ctr().cipher1(&buffer[offset + V.size()], buffer.size() - offset - V.size());
}
-void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void SIV_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
@@ -163,7 +163,7 @@ void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
BOTAN_ASSERT(sz >= tag_size(), "We have the tag");
- secure_vector<byte> V(buffer.data() + offset, buffer.data() + offset + 16);
+ secure_vector<uint8_t> V(buffer.data() + offset, buffer.data() + offset + 16);
set_ctr_iv(V);
@@ -171,7 +171,7 @@ void SIV_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
buffer.data() + offset,
buffer.size() - offset - V.size());
- secure_vector<byte> T = S2V(buffer.data() + offset, buffer.size() - offset - V.size());
+ secure_vector<uint8_t> T = S2V(buffer.data() + offset, buffer.size() - offset - V.size());
if(T != V)
throw Integrity_Failure("SIV tag check failed");
diff --git a/src/lib/modes/aead/siv/siv.h b/src/lib/modes/aead/siv/siv.h
index 711d9e30c..ea6ad8234 100644
--- a/src/lib/modes/aead/siv/siv.h
+++ b/src/lib/modes/aead/siv/siv.h
@@ -30,9 +30,9 @@ class BOTAN_DLL SIV_Mode : public AEAD_Mode
* @param ad associated data
* @param ad_len length of associated data in bytes
*/
- void set_associated_data_n(size_t n, const byte ad[], size_t ad_len);
+ void set_associated_data_n(size_t n, const uint8_t ad[], size_t ad_len);
- void set_associated_data(const byte ad[], size_t ad_len) override
+ void set_associated_data(const uint8_t ad[], size_t ad_len) override
{
set_associated_data_n(0, ad, ad_len);
}
@@ -56,21 +56,21 @@ class BOTAN_DLL SIV_Mode : public AEAD_Mode
StreamCipher& ctr() { return *m_ctr; }
- void set_ctr_iv(secure_vector<byte> V);
+ void set_ctr_iv(secure_vector<uint8_t> V);
- secure_vector<byte>& msg_buf() { return m_msg_buf; }
+ secure_vector<uint8_t>& msg_buf() { return m_msg_buf; }
- secure_vector<byte> S2V(const byte text[], size_t text_len);
+ secure_vector<uint8_t> S2V(const uint8_t text[], size_t text_len);
private:
- void start_msg(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const uint8_t nonce[], size_t nonce_len) override;
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
const std::string m_name;
std::unique_ptr<StreamCipher> m_ctr;
std::unique_ptr<MessageAuthenticationCode> m_cmac;
- secure_vector<byte> m_nonce, m_msg_buf;
- std::vector<secure_vector<byte>> m_ad_macs;
+ secure_vector<uint8_t> m_nonce, m_msg_buf;
+ std::vector<secure_vector<uint8_t>> m_ad_macs;
};
/**
@@ -84,7 +84,7 @@ class BOTAN_DLL SIV_Encryption final : public SIV_Mode
*/
explicit SIV_Encryption(BlockCipher* cipher) : SIV_Mode(cipher) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{ return input_length + tag_size(); }
@@ -103,7 +103,7 @@ class BOTAN_DLL SIV_Decryption final : public SIV_Mode
*/
explicit SIV_Decryption(BlockCipher* cipher) : SIV_Mode(cipher) {}
- void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
+ void finish(secure_vector<uint8_t>& final_block, size_t offset = 0) override;
size_t output_length(size_t input_length) const override
{