aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/stream
diff options
context:
space:
mode:
authorRenĂ© Meusel <[email protected]>2017-04-12 21:36:04 +0200
committerRenĂ© Meusel <[email protected]>2017-04-13 09:43:18 +0200
commit85df358b0aa16802970b8a784e9cf1e35e5da08f (patch)
tree5b7c30ef3a3284f1e93510839d9383ae6715283a /src/lib/stream
parent0d38f29ced06f4e8b84694f655a094592f08ddb8 (diff)
Refactor: use ::seek(0) in CTR_BE::set_iv()
Diffstat (limited to 'src/lib/stream')
-rw-r--r--src/lib/stream/ctr/ctr.cpp19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp
index 4bcf46c06..b56923324 100644
--- a/src/lib/stream/ctr/ctr.cpp
+++ b/src/lib/stream/ctr/ctr.cpp
@@ -73,27 +73,10 @@ void CTR_BE::set_iv(const uint8_t iv[], size_t iv_len)
if(!valid_iv_length(iv_len))
throw Invalid_IV_Length(name(), iv_len);
- const size_t bs = m_cipher->block_size();
-
- zeroise(m_counter);
zeroise(m_iv);
buffer_insert(m_iv, 0, iv, iv_len);
- const size_t n_wide = m_counter.size() / m_cipher->block_size();
- buffer_insert(m_counter, 0, iv, iv_len);
-
- // Set m_counter blocks to IV, IV + 1, ... IV + n
- for(size_t i = 1; i != n_wide; ++i)
- {
- buffer_insert(m_counter, i*bs, &m_counter[(i-1)*bs], bs);
-
- for(size_t j = 0; j != m_ctr_size; ++j)
- if(++m_counter[i*bs + (bs - 1 - j)])
- break;
- }
-
- m_cipher->encrypt_n(m_counter.data(), m_pad.data(), n_wide);
- m_pad_pos = 0;
+ seek(0);
}
/*