aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/cbc
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/modes/cbc
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/modes/cbc')
-rw-r--r--src/lib/modes/cbc/cbc.cpp22
-rw-r--r--src/lib/modes/cbc/cbc.h20
2 files changed, 21 insertions, 21 deletions
diff --git a/src/lib/modes/cbc/cbc.cpp b/src/lib/modes/cbc/cbc.cpp
index 9fbb7023f..188b4a0aa 100644
--- a/src/lib/modes/cbc/cbc.cpp
+++ b/src/lib/modes/cbc/cbc.cpp
@@ -62,12 +62,12 @@ bool CBC_Mode::valid_nonce_length(size_t n) const
return (n == 0 || n == cipher().block_size());
}
-void CBC_Mode::key_schedule(const byte key[], size_t length)
+void CBC_Mode::key_schedule(const uint8_t key[], size_t length)
{
m_cipher->set_key(key, length);
}
-void CBC_Mode::start_msg(const byte nonce[], size_t nonce_len)
+void CBC_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -101,7 +101,7 @@ size_t CBC_Encryption::process(uint8_t buf[], size_t sz)
BOTAN_ASSERT(sz % BS == 0, "CBC input is full blocks");
const size_t blocks = sz / BS;
- const byte* prev_block = state_ptr();
+ const uint8_t* prev_block = state_ptr();
if(blocks)
{
@@ -118,7 +118,7 @@ size_t CBC_Encryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void CBC_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CBC_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
@@ -149,10 +149,10 @@ size_t CTS_Encryption::output_length(size_t input_length) const
return input_length; // no ciphertext expansion in CTS
}
-void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CTS_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset)
{
BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
- byte* buf = buffer.data() + offset;
+ uint8_t* buf = buffer.data() + offset;
const size_t sz = buffer.size() - offset;
const size_t BS = cipher().block_size();
@@ -174,7 +174,7 @@ void CTS_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_bytes = sz - full_blocks;
BOTAN_ASSERT(final_bytes > BS && final_bytes < 2*BS, "Left over size in expected range");
- secure_vector<byte> last(buf + full_blocks, buf + full_blocks + final_bytes);
+ secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
buffer.resize(full_blocks + offset);
update(buffer, offset);
@@ -229,7 +229,7 @@ size_t CBC_Decryption::process(uint8_t buf[], size_t sz)
return sz;
}
-void CBC_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CBC_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;
@@ -265,11 +265,11 @@ size_t CTS_Decryption::minimum_final_size() const
return cipher().block_size() + 1;
}
-void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
+void CTS_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;
const size_t BS = cipher().block_size();
@@ -291,7 +291,7 @@ void CTS_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
const size_t final_bytes = sz - full_blocks;
BOTAN_ASSERT(final_bytes > BS && final_bytes < 2*BS, "Left over size in expected range");
- secure_vector<byte> last(buf + full_blocks, buf + full_blocks + final_bytes);
+ secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
buffer.resize(full_blocks + offset);
update(buffer, offset);
diff --git a/src/lib/modes/cbc/cbc.h b/src/lib/modes/cbc/cbc.h
index 1b7cbd323..a44a9b5d9 100644
--- a/src/lib/modes/cbc/cbc.h
+++ b/src/lib/modes/cbc/cbc.h
@@ -46,18 +46,18 @@ class BOTAN_DLL CBC_Mode : public Cipher_Mode
return *m_padding;
}
- secure_vector<byte>& state() { return m_state; }
+ secure_vector<uint8_t>& state() { return m_state; }
- byte* state_ptr() { return m_state.data(); }
+ uint8_t* state_ptr() { return m_state.data(); }
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;
std::unique_ptr<BlockCipher> m_cipher;
std::unique_ptr<BlockCipherModePaddingMethod> m_padding;
- secure_vector<byte> m_state;
+ secure_vector<uint8_t> m_state;
};
/**
@@ -75,7 +75,7 @@ class BOTAN_DLL CBC_Encryption : public CBC_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;
size_t output_length(size_t input_length) const override;
@@ -95,7 +95,7 @@ class BOTAN_DLL CTS_Encryption final : public CBC_Encryption
size_t output_length(size_t input_length) const 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;
size_t minimum_final_size() const override;
@@ -117,7 +117,7 @@ class BOTAN_DLL CBC_Decryption : public CBC_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;
size_t output_length(size_t input_length) const override;
@@ -126,7 +126,7 @@ class BOTAN_DLL CBC_Decryption : public CBC_Mode
void reset() override;
private:
- secure_vector<byte> m_tempbuf;
+ secure_vector<uint8_t> m_tempbuf;
};
/**
@@ -140,7 +140,7 @@ class BOTAN_DLL CTS_Decryption final : public CBC_Decryption
*/
explicit CTS_Decryption(BlockCipher* cipher) : CBC_Decryption(cipher, nullptr) {}
- 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 minimum_final_size() const override;