14 #ifndef CRYPTOPP_CHACHA_POLY1305_H 15 #define CRYPTOPP_CHACHA_POLY1305_H 32 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName()
33 {
return "ChaCha20/Poly1305";}
39 {
return std::string(
"ChaCha20/Poly1305");}
41 {
return GetSymmetricCipher().AlgorithmProvider();}
49 {CRYPTOPP_UNUSED(n);
return 32;}
53 {
return GetSymmetricCipher().OptimalDataAlignment();}
67 {
return W64LIT(274877906880);}
83 virtual void EncryptAndAuthenticate(
byte *ciphertext,
byte *mac,
size_t macSize,
const byte *iv,
int ivLength,
const byte *aad,
size_t aadLength,
const byte *message,
size_t messageLength);
100 virtual bool DecryptAndVerify(
byte *message,
const byte *mac,
size_t macSize,
const byte *iv,
int ivLength,
const byte *aad,
size_t aadLength,
const byte *ciphertext,
size_t ciphertextLength);
104 bool AuthenticationIsOnPlaintext()
const {
return false;}
105 unsigned int AuthenticationBlockSize()
const {
return 1;}
106 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
107 void Resync(
const byte *iv,
size_t len);
108 size_t AuthenticateBlocks(
const byte *data,
size_t len);
109 void AuthenticateLastHeaderBlock();
110 void AuthenticateLastConfidentialBlock();
111 void AuthenticateLastFooterBlock(
byte *mac,
size_t macSize);
114 void RekeyCipherAndMac(
const byte *userKey,
size_t userKeyLength,
const NameValuePairs ¶ms);
132 template <
bool T_IsEncryption>
143 bool IsForwardTransformation()
const 144 {
return T_IsEncryption;}
180 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName()
181 {
return "XChaCha20/Poly1305";}
187 {
return std::string(
"XChaCha20/Poly1305");}
189 {
return GetSymmetricCipher().AlgorithmProvider();}
197 {CRYPTOPP_UNUSED(n);
return 32;}
201 {
return GetSymmetricCipher().OptimalDataAlignment();}
215 {
return W64LIT(274877906880);}
248 virtual bool DecryptAndVerify(
byte *message,
const byte *mac,
size_t macSize,
const byte *iv,
int ivLength,
const byte *aad,
size_t aadLength,
const byte *ciphertext,
size_t ciphertextLength);
252 bool AuthenticationIsOnPlaintext()
const {
return false;}
253 unsigned int AuthenticationBlockSize()
const {
return 1;}
254 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
255 void Resync(
const byte *iv,
size_t len);
256 size_t AuthenticateBlocks(
const byte *data,
size_t len);
257 void AuthenticateLastHeaderBlock();
258 void AuthenticateLastConfidentialBlock();
259 void AuthenticateLastFooterBlock(
byte *mac,
size_t macSize);
262 void RekeyCipherAndMac(
const byte *userKey,
size_t userKeyLength,
const NameValuePairs ¶ms);
280 template <
bool T_IsEncryption>
291 bool IsForwardTransformation()
const 292 {
return T_IsEncryption;}
322 #endif // CRYPTOPP_CHACHA_POLY1305_H size_t DefaultKeyLength() const
Returns default key length.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
lword MaxFooterLength() const
Provides the maximum length of AAD.
Interface for message authentication codes.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
#define W64LIT(x)
Declare an unsigned word64.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Poly1305-TLS message authentication code.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
XChaCha20Poly1305_Final< true > Encryption
XChaCha20Poly1305 encryption.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
virtual void EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *aad, size_t aadLength, const byte *message, size_t messageLength)
Encrypts and calculates a MAC in one call.
lword MaxFooterLength() const
Provides the maximum length of AAD.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
IETF ChaCha20/Poly1305 AEAD scheme.
XChaCha20Poly1305_Final< false > Decryption
XChaCha20Poly1305 decryption.
std::string AlgorithmName() const
Provides the name of this algorithm.
Abstract base classes that provide a uniform interface to this library.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
virtual bool DecryptAndVerify(byte *message, const byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *aad, size_t aadLength, const byte *ciphertext, size_t ciphertextLength)
Decrypts and verifies a MAC in one call.
IETF ChaCha20Poly1305 cipher final implementation.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
size_t MinKeyLength() const
Returns smallest valid key length.
size_t DefaultKeyLength() const
Returns default key length.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
IETF XChaCha20Poly1305 cipher base implementation.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
ChaCha20Poly1305_Final< true > Encryption
ChaCha20Poly1305 encryption.
unsigned int DigestSize() const
Provides the digest size of the hash.
size_t MaxKeyLength() const
Returns largest valid key length.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Base class for authenticated encryption modes of operation.
IETF XChaCha20/Poly1305 AEAD scheme.
size_t MinKeyLength() const
Returns smallest valid key length.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
word64 lword
Large word type.
unsigned char byte
8-bit unsigned datatype
ChaCha20Poly1305_Final< false > Decryption
ChaCha20Poly1305 decryption.
IV_Requirement
Secure IVs requirements as enumerated values.
size_t MaxKeyLength() const
Returns largest valid key length.
const lword LWORD_MAX
Large word type max value.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
IETF XChaCha20Poly1305 cipher final implementation.
IETF ChaCha20Poly1305 cipher base implementation.
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
Crypto++ library namespace.
Classes for Poly1305 message authentication code.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
std::string AlgorithmName() const
Provides the name of this algorithm.
Classes for authenticated encryption modes of operation.
Classes for ChaCha8, ChaCha12 and ChaCha20 stream ciphers.
unsigned int DigestSize() const
Provides the digest size of the hash.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
Interface for retrieving values given their names.