diff options
author | Jack Lloyd <[email protected]> | 2018-08-08 17:08:22 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-08 17:08:22 -0400 |
commit | 25326f304dc5783940c92996e0e4853c38576ce9 (patch) | |
tree | d4b5b10804aa4851b36fbfc0fc27e139d90c47d1 /src/lib/modes | |
parent | a048766b33e88f3ffe5ca71a65105c9f58d55ecf (diff) |
Add StreamCipher::write_keystream
Avoids the XOR operation. Only implemented for ChaCha20 currently,
everything else defaults to memset-to-zero + xor-cipher
Diffstat (limited to 'src/lib/modes')
-rw-r--r-- | src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp index 786e21def..007e2fbe4 100644 --- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp +++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp @@ -66,11 +66,11 @@ void ChaCha20Poly1305_Mode::start_msg(const uint8_t nonce[], size_t nonce_len) m_chacha->set_iv(nonce, nonce_len); - secure_vector<uint8_t> init(64); // zeros - m_chacha->encrypt(init); + secure_vector<uint8_t> first_block(64); + m_chacha->write_keystream(first_block.data(), first_block.size()); - m_poly1305->set_key(init.data(), 32); - // Remainder of output is discard + m_poly1305->set_key(first_block.data(), 32); + // Remainder of first block is discarded m_poly1305->update(m_ad); |