aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/cbc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/modes/cbc')
-rw-r--r--src/lib/modes/cbc/cbc.cpp20
-rw-r--r--src/lib/modes/cbc/cbc.h6
2 files changed, 10 insertions, 16 deletions
diff --git a/src/lib/modes/cbc/cbc.cpp b/src/lib/modes/cbc/cbc.cpp
index fedeaf20d..8066dae12 100644
--- a/src/lib/modes/cbc/cbc.cpp
+++ b/src/lib/modes/cbc/cbc.cpp
@@ -61,7 +61,7 @@ void CBC_Mode::key_schedule(const byte key[], size_t length)
m_cipher->set_key(key, length);
}
-secure_vector<byte> CBC_Mode::start_raw(const byte nonce[], size_t nonce_len)
+void CBC_Mode::start_msg(const byte nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -73,8 +73,6 @@ secure_vector<byte> CBC_Mode::start_raw(const byte nonce[], size_t nonce_len)
*/
if(nonce_len)
m_state.assign(nonce, nonce + nonce_len);
-
- return secure_vector<byte>();
}
size_t CBC_Encryption::minimum_final_size() const
@@ -90,12 +88,8 @@ size_t CBC_Encryption::output_length(size_t input_length) const
return round_up(input_length, cipher().block_size());
}
-void CBC_Encryption::update(secure_vector<byte>& buffer, size_t offset)
+size_t CBC_Encryption::process(uint8_t buf[], size_t sz)
{
- BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
- const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
-
const size_t BS = cipher().block_size();
BOTAN_ASSERT(sz % BS == 0, "CBC input is full blocks");
@@ -114,6 +108,8 @@ void CBC_Encryption::update(secure_vector<byte>& buffer, size_t offset)
state().assign(&buf[BS*(blocks-1)], &buf[BS*blocks]);
}
+
+ return sz;
}
void CBC_Encryption::finish(secure_vector<byte>& buffer, size_t offset)
@@ -201,12 +197,8 @@ size_t CBC_Decryption::minimum_final_size() const
return cipher().block_size();
}
-void CBC_Decryption::update(secure_vector<byte>& buffer, size_t offset)
+size_t CBC_Decryption::process(uint8_t buf[], size_t sz)
{
- BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane");
- const size_t sz = buffer.size() - offset;
- byte* buf = buffer.data() + offset;
-
const size_t BS = cipher().block_size();
BOTAN_ASSERT(sz % BS == 0, "Input is full blocks");
@@ -227,6 +219,8 @@ void CBC_Decryption::update(secure_vector<byte>& buffer, size_t offset)
buf += to_proc;
blocks -= to_proc / BS;
}
+
+ return sz;
}
void CBC_Decryption::finish(secure_vector<byte>& buffer, size_t offset)
diff --git a/src/lib/modes/cbc/cbc.h b/src/lib/modes/cbc/cbc.h
index 961991d4a..caad102d4 100644
--- a/src/lib/modes/cbc/cbc.h
+++ b/src/lib/modes/cbc/cbc.h
@@ -47,7 +47,7 @@ class BOTAN_DLL CBC_Mode : public Cipher_Mode
byte* state_ptr() { return m_state.data(); }
private:
- secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override;
+ void start_msg(const byte nonce[], size_t nonce_len) override;
void key_schedule(const byte key[], size_t length) override;
@@ -65,7 +65,7 @@ class BOTAN_DLL CBC_Encryption : public CBC_Mode
CBC_Encryption(BlockCipher* cipher, BlockCipherModePaddingMethod* padding) :
CBC_Mode(cipher, padding) {}
- void update(secure_vector<byte>& blocks, size_t offset = 0) override;
+ size_t process(uint8_t buf[], size_t size) override;
void finish(secure_vector<byte>& final_block, size_t offset = 0) override;
@@ -100,7 +100,7 @@ class BOTAN_DLL CBC_Decryption : public CBC_Mode
CBC_Decryption(BlockCipher* cipher, BlockCipherModePaddingMethod* padding) :
CBC_Mode(cipher, padding), m_tempbuf(update_granularity()) {}
- void update(secure_vector<byte>& blocks, size_t offset = 0) override;
+ size_t process(uint8_t buf[], size_t size) override;
void finish(secure_vector<byte>& final_block, size_t offset = 0) override;