From 38a53b81d443349d64ed15ba58f4addcdc1cc627 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 16 Mar 2013 18:22:16 +0000 Subject: OCB encryption can encrypt blocks in parallel now --- src/filters/modes/ocb/ocb.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') 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 ctext_buf(BS); + secure_vector ctext_buf(par_bytes); secure_vector csum_accum(par_bytes); + secure_vector 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; -- cgit v1.2.3