diff --git a/authenc.h b/authenc.h index 5f9f2b1a..8e460c77 100644 --- a/authenc.h +++ b/authenc.h @@ -1,8 +1,20 @@ // authenc.h - originally written and placed in the public domain by Wei Dai //! \file -//! \headerfile authenc.h -//! \brief Base classes for working with authenticated encryption modes of encryption +//! \brief Classes for authenticated encryption modes of operation +//! \details Authenticated encryption (AE) schemes combine confidentiality and authenticity +//! into a single mode of operation They gained traction in the early 2000's because manually +//! combining them was error prone for the typical developer. Around that time, the desire to +//! authenticate but not ecrypt additional data (AAD) was also identified. When both features +//! are available from a scheme, the system is referred to as an AEAD scheme. +//! \details Crypto++ provides four authenticated encryption modes of operation - CCM, EAX, GCM +//! and OCB mode. All modes derive from AuthenticatedSymmetricCipherBase() and the +//! motivation for the API, like calling AAD a "header", can be found in Bellare, +//! Rogaway and Wagner's The EAX +//! Mode of Operation. The EAX paper suggested a basic API to help standardize AEAD +//! schemes in software and promote adoption of the modes. +//! \sa Authenticated +//! Encryption on the Crypto++ wiki. //! \since Crypto++ 5.6.0 #ifndef CRYPTOPP_AUTHENC_H @@ -14,7 +26,17 @@ NAMESPACE_BEGIN(CryptoPP) //! \class AuthenticatedSymmetricCipherBase -//! \brief Base implementation for one direction (encryption or decryption) of a stream cipher or block cipher mode with authentication +//! \brief Base class for authenticated encryption modes of operation +//! \details AuthenticatedSymmetricCipherBase() serves as a base implementation for one direction +//! (encryption or decryption) of a stream cipher or block cipher mode with authentication. +//! \details Crypto++ provides four authenticated encryption modes of operation - CCM, EAX, GCM +//! and OCB mode. All modes derive from AuthenticatedSymmetricCipherBase() and the +//! motivation for the API, like calling AAD a "header", can be found in Bellare, +//! Rogaway and Wagner's The EAX +//! Mode of Operation. The EAX paper suggested a basic API to help standardize AEAD +//! schemes in software and promote adoption of the modes. +//! \sa Authenticated +//! Encryption on the Crypto++ wiki. //! \since Crypto++ 5.6.0 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipherBase : public AuthenticatedSymmetricCipher { @@ -22,6 +44,7 @@ public: AuthenticatedSymmetricCipherBase() : m_state(State_Start), m_bufferedDataLength(0), m_totalHeaderLength(0), m_totalMessageLength(0), m_totalFooterLength(0) {} + // StreamTransformation interface bool IsRandomAccess() const {return false;} bool IsSelfInverting() const {return true;} @@ -42,7 +65,8 @@ public: protected: void AuthenticateData(const byte *data, size_t len); - const SymmetricCipher & GetSymmetricCipher() const {return const_cast(this)->AccessSymmetricCipher();}; + const SymmetricCipher & GetSymmetricCipher() const + {return const_cast(this)->AccessSymmetricCipher();}; virtual SymmetricCipher & AccessSymmetricCipher() =0; virtual bool AuthenticationIsOnPlaintext() const =0; diff --git a/misc.h b/misc.h index 28f2e972..36bae7cf 100644 --- a/misc.h +++ b/misc.h @@ -111,7 +111,7 @@ # define SIZE_MAX SIZE_T_MAX # elif defined(__SIZE_TYPE__) # define SIZE_MAX (~(__SIZE_TYPE__)0) -#else +# else # define SIZE_MAX ((std::numeric_limits::max)()) # endif #endif diff --git a/secblock.h b/secblock.h index 89f6694f..f152e730 100644 --- a/secblock.h +++ b/secblock.h @@ -615,6 +615,20 @@ public: m_mark = ELEMS_MAX; } + //! \brief Set contents from a value + //! \param count the number of values to copy + //! \param value the value, repeated count times + //! \details If the memory block is reduced in size, then the reclaimed memory is set to 0. + //! Assign() resets the element count after the previous block is zeroized. + void Assign(size_type count, T value) + { + New(count); + for (size_t i=0; i