Update documentation

pull/795/head
Jeffrey Walton 2019-01-27 11:54:35 -05:00
parent f78a5b2eb8
commit 3f37cfc3a3
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 26 additions and 16 deletions

View File

@ -12,9 +12,10 @@
/// \file chacha.h /// \file chacha.h
/// \brief Classes for ChaCha8, ChaCha12 and ChaCha20 stream ciphers /// \brief Classes for ChaCha8, ChaCha12 and ChaCha20 stream ciphers
/// \details Crypto++ provides Bernstein and ECRYPT's ChaCha from <a href="http://cr.yp.to/chacha/chacha-20080128.pdf">ChaCha, /// \details Crypto++ provides Bernstein and ECRYPT's ChaCha from <a
/// a variant of Salsa20</a> (2008.01.28). Crypto++ also provides the IETF /// href="http://cr.yp.to/chacha/chacha-20080128.pdf">ChaCha, a
/// implementation of ChaCha using the ChaChaTLS name. Bernstein's /// variant of Salsa20</a> (2008.01.28). Crypto++ also provides the
/// IETF implementation of ChaCha using the ChaChaTLS name. Bernstein's
/// implementation is _slightly_ different from the TLS working group's /// implementation is _slightly_ different from the TLS working group's
/// implementation for cipher suites /// implementation for cipher suites
/// <tt>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>, /// <tt>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>,

View File

@ -346,8 +346,7 @@ void Poly1305TLS_Base::Update(const byte *input, size_t length)
// Process // Process
memcpy_s(m_acc + num, BLOCKSIZE - num, input, rem); memcpy_s(m_acc + num, BLOCKSIZE - num, input, rem);
Poly1305_HashBlocks(m_h, m_r, m_acc, BLOCKSIZE, 1); Poly1305_HashBlocks(m_h, m_r, m_acc, BLOCKSIZE, 1);
input += rem; input += rem; length -= rem;
length -= rem;
} }
else else
{ {

View File

@ -20,7 +20,7 @@
/// Message-Authentication Code (20050329)</A>, <a href="http://tools.ietf.org/html/rfc8439">RFC /// Message-Authentication Code (20050329)</A>, <a href="http://tools.ietf.org/html/rfc8439">RFC
/// 8439, ChaCha20 and Poly1305 for IETF Protocols</a> and Andy Polyakov <A /// 8439, ChaCha20 and Poly1305 for IETF Protocols</a> and Andy Polyakov <A
/// HREF="http://www.openssl.org/blog/blog/2016/02/15/poly1305-revised/">Poly1305 Revised</A> /// HREF="http://www.openssl.org/blog/blog/2016/02/15/poly1305-revised/">Poly1305 Revised</A>
/// \since Crypto++ 6.0 /// \since Poly1305 since Crypto++ 6.0, Poly1305TLS since Crypto++ 8.1
#ifndef CRYPTOPP_POLY1305_H #ifndef CRYPTOPP_POLY1305_H
#define CRYPTOPP_POLY1305_H #define CRYPTOPP_POLY1305_H
@ -36,7 +36,7 @@ NAMESPACE_BEGIN(CryptoPP)
////////////////////////////// Bernstein Poly1305 ////////////////////////////// ////////////////////////////// Bernstein Poly1305 //////////////////////////////
/// \brief Poly1305 message authentication code base class /// \brief Poly1305 message authentication code base class
/// \tparam T class derived from BlockCipherDocumentation with 16-byte key and 16-byte blocksize /// \tparam T BlockCipherDocumentation derived class with 16-byte key and 16-byte blocksize
/// \details Poly1305_Base is the base class of Bernstein's Poly1305 algorithm. /// \details Poly1305_Base is the base class of Bernstein's Poly1305 algorithm.
/// \since Crypto++ 6.0 /// \since Crypto++ 6.0
template <class T> template <class T>
@ -94,9 +94,11 @@ protected:
/// message, using a 16-byte AES key, a 16-byte additional key, and a 16-byte nonce. /// message, using a 16-byte AES key, a 16-byte additional key, and a 16-byte nonce.
/// \details The key is 32 bytes and a concatenation <tt>key = {k,s}</tt>, where /// \details The key is 32 bytes and a concatenation <tt>key = {k,s}</tt>, where
/// <tt>k</tt> is the AES key and <tt>r</tt> is additional key that gets clamped. /// <tt>k</tt> is the AES key and <tt>r</tt> is additional key that gets clamped.
/// The key is clamped internally so there is no need to perform the operation
/// defore setting the key.
/// \details Each message must use a unique security context, which means either the key or nonce /// \details Each message must use a unique security context, which means either the key or nonce
/// must be changed after each message. It can be accomplished in one of two ways. First, you /// must be changed after each message. It can be accomplished in one of two ways. First, you
/// can create a new Poly1305 object with a key and nonce each time its needed. /// can create a new Poly1305 object each time its needed.
/// <pre> SecByteBlock key(32), nonce(16); /// <pre> SecByteBlock key(32), nonce(16);
/// prng.GenerateBlock(key, key.size()); /// prng.GenerateBlock(key, key.size());
/// prng.GenerateBlock(nonce, nonce.size()); /// prng.GenerateBlock(nonce, nonce.size());
@ -106,8 +108,7 @@ protected:
/// poly1305.Final(...);</pre> /// poly1305.Final(...);</pre>
/// ///
/// \details Second, you can create a Poly1305 object, reuse the key, and set a fresh nonce /// \details Second, you can create a Poly1305 object, reuse the key, and set a fresh nonce
/// for each message. The second and subsequent nonces can be generated directly using a /// for each message. The second and subsequent nonces can be generated using GetNextIV().
/// RandomNumberGenerator() derived class; or it can be generated using GetNextIV().
/// <pre> SecByteBlock key(32), nonce(16); /// <pre> SecByteBlock key(32), nonce(16);
/// prng.GenerateBlock(key, key.size()); /// prng.GenerateBlock(key, key.size());
/// prng.GenerateBlock(nonce, nonce.size()); /// prng.GenerateBlock(nonce, nonce.size());
@ -144,10 +145,12 @@ public:
/// \param keyLength the size of the byte array, in bytes /// \param keyLength the size of the byte array, in bytes
/// \param nonce a byte array used to key the cipher /// \param nonce a byte array used to key the cipher
/// \param nonceLength the size of the byte array, in bytes /// \param nonceLength the size of the byte array, in bytes
/// \details key is the 32-byte key composed of the 16-byte AES key and the 16 additional key /// \details The key is 32 bytes and a concatenation <tt>key = {k,s}</tt>, where
/// bytes used for <tt>r</tt>. /// <tt>k</tt> is the AES key and <tt>r</tt> is additional key that gets clamped.
/// \details Each message requires a unique security context. You can use GetNextIV() and /// The key is clamped internally so there is no need to perform the operation
/// Resynchronize() to set a new nonce under a key for a message. /// defore setting the key.
/// \details Each message requires a unique security context. You can use GetNextIV()
/// and Resynchronize() to set a new nonce under a key for a message.
Poly1305(const byte *key, size_t keyLength=DEFAULT_KEYLENGTH, const byte *nonce=NULLPTR, size_t nonceLength=0) Poly1305(const byte *key, size_t keyLength=DEFAULT_KEYLENGTH, const byte *nonce=NULLPTR, size_t nonceLength=0)
{this->SetKey(key, keyLength, MakeParameters(Name::IV(), ConstByteArrayParameter(nonce, nonceLength)));} {this->SetKey(key, keyLength, MakeParameters(Name::IV(), ConstByteArrayParameter(nonce, nonceLength)));}
}; };
@ -187,10 +190,17 @@ protected:
}; };
/// \brief Poly1305-TLS message authentication code /// \brief Poly1305-TLS message authentication code
/// \details Poly1305-TLS is the IETF's version of Poly1305. It is a slightly /// \details This is the IETF's variant of Bernstein's Poly1305 from RFC 8439.
/// different algorithm than Bernstein's version. /// IETF Poly1305 is called Poly1305TLS in the Crypto++ library. It is
/// _slightly_ different from the Bernstein implementation. Poly1305-TLS
/// can be used for cipher suites
/// <tt>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>,
/// <tt>TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256</tt>, and
/// <tt>TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256</tt>.
/// \details The key is 32 bytes and a concatenation <tt>key = {r,s}</tt>, where /// \details The key is 32 bytes and a concatenation <tt>key = {r,s}</tt>, where
/// <tt>r</tt> is additional key that gets clamped and <tt>s</tt> is the nonce. /// <tt>r</tt> is additional key that gets clamped and <tt>s</tt> is the nonce.
/// The key is clamped internally so there is no need to perform the operation
/// defore setting the key.
/// \details Each message must use a unique security context, which means the key /// \details Each message must use a unique security context, which means the key
/// must be changed after each message. It can be accomplished in one of two ways. /// must be changed after each message. It can be accomplished in one of two ways.
/// First, you can create a new Poly1305 object with a new key each time its needed. /// First, you can create a new Poly1305 object with a new key each time its needed.