From c1ad534038f044c4428eac21318b0d55927cfabd Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 30 Jan 2019 01:45:09 -0500 Subject: Update comments --- chacha.cpp | 3 ++- chachapoly.cpp | 6 ++++++ chachapoly.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/chacha.cpp b/chacha.cpp index 321ebbaf..fcea81ec 100644 --- a/chacha.cpp +++ b/chacha.cpp @@ -316,6 +316,7 @@ std::string ChaCha_Policy::AlgorithmProvider() const void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) { CRYPTOPP_ASSERT(key); CRYPTOPP_ASSERT(length == 16 || length == 32); + CRYPTOPP_UNUSED(key); CRYPTOPP_UNUSED(length); m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); if (m_rounds != 20 && m_rounds != 12 && m_rounds != 8) @@ -337,7 +338,7 @@ void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, void ChaCha_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length); - CRYPTOPP_ASSERT(length==8); + CRYPTOPP_ASSERT(length==8); CRYPTOPP_UNUSED(length); GetBlock get(IV); m_state[12] = m_state[13] = 0; diff --git a/chachapoly.cpp b/chachapoly.cpp index 6d4d395e..8daff99d 100644 --- a/chachapoly.cpp +++ b/chachapoly.cpp @@ -8,6 +8,12 @@ NAMESPACE_BEGIN(CryptoPP) +// RekeyCipherAndMac is heavier-weight than we like. The Authenc framework was +// predicated on BlcokCiphers, where the key and key schedule could be +// calculated independent of the IV being used. However, the ChaCha and +// ChaCha20Poly1305 construction cannot disgorge key setup and IV. Even a +// simple Resync() forces us to regenerate the initial state for both +// ChaCha20 and Poly1305. void ChaCha20Poly1305_Base::RekeyCipherAndMac(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) { // Derive MAC key diff --git a/chachapoly.h b/chachapoly.h index 5f7e92e6..01637671 100644 --- a/chachapoly.h +++ b/chachapoly.h @@ -120,6 +120,7 @@ protected: }; /// \brief ChaCha20Poly1305 cipher final implementation +/// \tparam T_ForwardTransform flag indicating cipher direction /// \details ChaCha20Poly1305 is an authenticated encryption scheme that combines /// ChaCha20TLS and Poly1305TLS. The scheme is defined in RFC 8439, section 2.8, /// AEAD_CHACHA20_POLY1305 construction, and uses the IETF versions of ChaCha -- cgit v1.2.1