Update comments

pull/795/head
Jeffrey Walton 2019-01-25 08:14:23 -05:00
parent 97df2b960b
commit 6a68abea0a
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 19 additions and 18 deletions

View File

@ -83,9 +83,9 @@ enum {BYTES_PER_ITERATION=64};
// during addition in an intermediate result. Conditions to trigger // during addition in an intermediate result. Conditions to trigger
// issue include a user seeks to around 2^32 blocks (256 GB of data). // issue include a user seeks to around 2^32 blocks (256 GB of data).
// https://github.com/weidai11/cryptopp/issues/732 // https://github.com/weidai11/cryptopp/issues/732
inline bool MultiBlockSafe(unsigned int state12, unsigned int blocks) inline bool MultiBlockSafe(unsigned int ctrLow, unsigned int blocks)
{ {
return 0xffffffff - state12 > blocks; return 0xffffffff - ctrLow > blocks;
} }
// OperateKeystream always produces a key stream. The key stream is written // OperateKeystream always produces a key stream. The key stream is written
@ -217,6 +217,9 @@ void ChaCha_OperateKeystream(KeystreamOperation operation,
// We may re-enter a SIMD keystream operation from here. // We may re-enter a SIMD keystream operation from here.
} while (iterationCount--); } while (iterationCount--);
#undef CHACHA_QUARTER_ROUND
#undef CHACHA_OUTPUT
} }
std::string ChaCha_AlgorithmProvider() std::string ChaCha_AlgorithmProvider()

View File

@ -3,12 +3,12 @@
// and Bernstein's reference ChaCha family implementation at // and Bernstein's reference ChaCha family implementation at
// http://cr.yp.to/chacha.html. // http://cr.yp.to/chacha.html.
// Crypto++ added Bernstein's ChaCha classses at version 5.6.4 of the library. // The library added Bernstein's ChaCha classses at Crypto++ 5.6.4. The IETF
// The IETF uses a slightly different implementation, and the classes were // uses a slightly different implementation than Bernstein, and the IETF
// added at Crypto++ version 8.1. We wanted to maintain ABI compatibility at // classes were added at Crypto++ 8.1. We wanted to maintain ABI compatibility
// the 8.1 release so the original ChaCha classes were not disturbed. Instead // at the 8.1 release so the original ChaCha classes were not disturbed.
// new classes were added for IETF ChaCha. The back-end implementation shares // Instead new classes were added for IETF ChaCha. The back-end implementation
// code as expected, however. // shares code as expected, however.
/// \file chacha.h /// \file chacha.h
/// \brief Classes for ChaCha8, ChaCha12 and ChaCha20 stream ciphers /// \brief Classes for ChaCha8, ChaCha12 and ChaCha20 stream ciphers
@ -73,12 +73,10 @@ protected:
}; };
/// \brief ChaCha stream cipher /// \brief ChaCha stream cipher
/// \details Bernstein and ECRYPT's ChaCha is _slightly_ different from the TLS working /// \details This is Bernstein and ECRYPT's ChaCha. It is _slightly_ different
/// group's implementation for cipher suites /// from the IETF's version of ChaCha called ChaChaTLS.
/// <tt>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>, /// \sa <a href="http://cr.yp.to/chacha/chacha-20080208.pdf">ChaCha, a variant
/// <tt>TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256</tt>, and /// of Salsa20</a> (2008.01.28).
/// <tt>TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>.
/// \sa <a href="http://cr.yp.to/chacha/chacha-20080208.pdf">ChaCha, a variant of Salsa20</a> (2008.01.28).
/// \since Crypto++ 5.6.4 /// \since Crypto++ 5.6.4
struct ChaCha : public ChaCha_Info, public SymmetricCipherDocumentation struct ChaCha : public ChaCha_Info, public SymmetricCipherDocumentation
{ {
@ -96,9 +94,9 @@ struct ChaChaTLS_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_
/// \returns the algorithm name /// \returns the algorithm name
/// \details StaticAlgorithmName returns the algorithm's name as a static /// \details StaticAlgorithmName returns the algorithm's name as a static
/// member function. /// member function.
/// \details This is the IETF's variant of Bernstein's ChaCha from RFC 7539. /// \details This is the IETF's variant of Bernstein's ChaCha from RFC
/// IETF ChaCha is called ChaChaTLS in the Crypto++ library. It is /// 7539. IETF ChaCha is called ChaChaTLS in the Crypto++ library. It
/// _slightly_ different from Bernstein's implementation. /// is _slightly_ different from Bernstein's implementation.
static const char* StaticAlgorithmName() { static const char* StaticAlgorithmName() {
return "ChaChaTLS"; return "ChaChaTLS";
} }
@ -131,7 +129,7 @@ protected:
/// \brief ChaCha-TLS stream cipher /// \brief ChaCha-TLS stream cipher
/// \details This is the IETF's variant of Bernstein's ChaCha from RFC 7539. /// \details This is the IETF's variant of Bernstein's ChaCha from RFC 7539.
/// IETF ChaCha is called ChaChaTLS in the Crypto++ library. It is /// IETF ChaCha is called ChaChaTLS in the Crypto++ library. It is
/// _slightly_ different from the Bernstein's implementation. ChaCha-TLS /// _slightly_ different from the Bernstein implementation. ChaCha-TLS
/// can be used for cipher suites /// can be used for cipher suites
/// <tt>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>, /// <tt>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>,
/// <tt>TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256</tt>, and /// <tt>TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256</tt>, and