aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-08-15 19:35:38 +0000
committerlloyd <[email protected]>2013-08-15 19:35:38 +0000
commit10bab015381aceecdf37bc7c7c325e014f2da676 (patch)
tree41dfffbef7a115a3200d9870a53eb8d039239b91 /src
parent84cd26db4770ccf09a80a99b7ccfd899d8eeb1a8 (diff)
Keeping this buffer persistently greatly helps performance
Diffstat (limited to 'src')
-rw-r--r--src/modes/cbc/cbc.cpp12
-rw-r--r--src/modes/cbc/cbc.h4
2 files changed, 8 insertions, 8 deletions
diff --git a/src/modes/cbc/cbc.cpp b/src/modes/cbc/cbc.cpp
index 65b78fbc5..bb7c56858 100644
--- a/src/modes/cbc/cbc.cpp
+++ b/src/modes/cbc/cbc.cpp
@@ -163,19 +163,17 @@ void CBC_Decryption::update(secure_vector<byte>& buffer, size_t offset)
BOTAN_ASSERT(sz % BS == 0, "Input is full blocks");
size_t blocks = sz / BS;
- secure_vector<byte> temp(update_granularity());
-
while(blocks)
{
- const size_t to_proc = std::min(sz, temp.size());
+ const size_t to_proc = std::min(sz, m_tempbuf.size());
- cipher().decrypt_n(buf, &temp[0], to_proc / BS);
+ cipher().decrypt_n(buf, &m_tempbuf[0], to_proc / BS);
- xor_buf(&temp[0], state_ptr(), BS);
- xor_buf(&temp[BS], buf, to_proc - BS);
+ xor_buf(&m_tempbuf[0], state_ptr(), BS);
+ xor_buf(&m_tempbuf[BS], buf, to_proc - BS);
copy_mem(state_ptr(), buf + (to_proc - BS), BS);
- copy_mem(buf, &temp[0], to_proc);
+ copy_mem(buf, &m_tempbuf[0], to_proc);
buf += to_proc;
blocks -= to_proc / BS;
diff --git a/src/modes/cbc/cbc.h b/src/modes/cbc/cbc.h
index 8e3a72fd0..add6a206f 100644
--- a/src/modes/cbc/cbc.h
+++ b/src/modes/cbc/cbc.h
@@ -78,7 +78,7 @@ class BOTAN_DLL CBC_Decryption : public CBC_Mode
{
public:
CBC_Decryption(BlockCipher* cipher, BlockCipherModePaddingMethod* padding) :
- CBC_Mode(cipher, padding) {}
+ CBC_Mode(cipher, padding), m_tempbuf(update_granularity()) {}
void update(secure_vector<byte>& blocks, size_t offset) override;
@@ -87,6 +87,8 @@ class BOTAN_DLL CBC_Decryption : public CBC_Mode
size_t output_length(size_t input_length) const override;
size_t minimum_final_size() const override;
+ private:
+ secure_vector<byte> m_tempbuf;
};
}