aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-03-16 18:22:16 +0000
committerlloyd <[email protected]>2013-03-16 18:22:16 +0000
commit38a53b81d443349d64ed15ba58f4addcdc1cc627 (patch)
tree4970bc52b0bc6718758ae53c9c629c965029c029 /src
parent6982cf184cf4a51a54d781aba8f8a4e05d25a49c (diff)
OCB encryption can encrypt blocks in parallel now
Diffstat (limited to 'src')
-rw-r--r--src/filters/modes/ocb/ocb.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/filters/modes/ocb/ocb.cpp b/src/filters/modes/ocb/ocb.cpp
index a8481ab8a..970475a9f 100644
--- a/src/filters/modes/ocb/ocb.cpp
+++ b/src/filters/modes/ocb/ocb.cpp
@@ -214,11 +214,7 @@ void OCB_Encryption::buffered_block(const byte input[], size_t input_length)
const size_t blocks = input_length / BS;
-#if 1
const size_t par_bytes = m_cipher->parallel_bytes();
-#else
- const size_t par_bytes = 2*m_cipher->block_size();
-#endif
BOTAN_ASSERT(par_bytes % BS == 0, "Cipher is parallel in full blocks");
@@ -226,8 +222,9 @@ void OCB_Encryption::buffered_block(const byte input[], size_t input_length)
const L_computer& L = *m_L; // convenient name
- secure_vector<byte> ctext_buf(BS);
+ secure_vector<byte> ctext_buf(par_bytes);
secure_vector<byte> csum_accum(par_bytes);
+ secure_vector<byte> offsets(par_bytes);
size_t blocks_left = blocks;
@@ -238,17 +235,20 @@ void OCB_Encryption::buffered_block(const byte input[], size_t input_length)
xor_buf(&csum_accum[0], &input[0], proc_bytes);
+ offsets.clear();
for(size_t i = 0; i != to_proc; ++i)
{
m_offset ^= L(ctz(++m_block_index));
+ offsets += m_offset;
+ }
- ctext_buf = m_offset;
- xor_buf(&ctext_buf[0], &input[BS*i], BS);
- m_cipher->encrypt(ctext_buf);
- ctext_buf ^= m_offset;
+ copy_mem(&ctext_buf[0], &input[0], proc_bytes);
- send(ctext_buf);
- }
+ ctext_buf ^= offsets;
+ m_cipher->encrypt(ctext_buf);
+ ctext_buf ^= offsets;
+
+ send(ctext_buf, proc_bytes);
input += proc_bytes;
blocks_left -= to_proc;