Crypto++
8.2
Free C++ class library of cryptographic schemes
|
Go to the documentation of this file.
14 #ifndef CRYPTOPP_CHACHA_POLY1305_H
15 #define CRYPTOPP_CHACHA_POLY1305_H
40 {
return std::string(
"ChaCha20/Poly1305");}
42 {
return GetSymmetricCipher().AlgorithmProvider();}
50 {CRYPTOPP_UNUSED(n);
return 32;}
54 {
return GetSymmetricCipher().OptimalDataAlignment();}
68 {
return W64LIT(274877906880);}
84 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);
101 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);
105 bool AuthenticationIsOnPlaintext()
const {
return false;}
106 unsigned int AuthenticationBlockSize()
const {
return 1;}
107 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
108 void Resync(
const byte *iv,
size_t len);
109 size_t AuthenticateBlocks(
const byte *data,
size_t len);
110 void AuthenticateLastHeaderBlock();
111 void AuthenticateLastConfidentialBlock();
112 void AuthenticateLastFooterBlock(
byte *mac,
size_t macSize);
116 void RekeyCipherAndMac(
const byte *userKey,
size_t userKeyLength,
const NameValuePairs ¶ms);
130 template <
bool T_IsEncryption>
134 static std::string StaticAlgorithmName()
135 {
return std::string(
"ChaCha20/Poly1305");}
142 bool IsForwardTransformation()
const
143 {
return T_IsEncryption;}
187 {
return std::string(
"XChaCha20/Poly1305");}
189 {
return GetSymmetricCipher().AlgorithmProvider();}
197 {CRYPTOPP_UNUSED(n);
return 32;}
201 {
return GetSymmetricCipher().OptimalDataAlignment();}
215 {
return W64LIT(274877906880);}
231 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);
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);
263 void RekeyCipherAndMac(
const byte *userKey,
size_t userKeyLength,
const NameValuePairs ¶ms);
277 template <
bool T_IsEncryption>
281 static std::string StaticAlgorithmName()
282 {
return std::string(
"XChaCha20/Poly1305");}
289 bool IsForwardTransformation()
const
290 {
return T_IsEncryption;}
320 #endif // CRYPTOPP_CHACHA_POLY1305_H
ChaCha20Poly1305_Final< false > Decryption
ChaCha20Poly1305 decryption.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
ChaCha20Poly1305 cipher base implementation.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Poly1305-TLS message authentication code.
ChaCha20Poly1305_Final< true > Encryption
ChaCha20Poly1305 encryption.
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.
ChaCha20/Poly1305-TLS AEAD scheme.
size_t MinKeyLength() const
Returns smallest valid key length.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
lword MaxFooterLength() const
Provides the the maximum length of AAD.
XChaCha20Poly1305_Final< false > Decryption
XChaCha20Poly1305 decryption.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
ChaCha20Poly1305 cipher final implementation.
size_t MaxKeyLength() const
Returns largest valid key length.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
Classes for ChaCha8, ChaCha12 and ChaCha20 stream ciphers.
size_t DefaultKeyLength() const
Returns default key length.
@ UNIQUE_IV
The IV must be unique.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
Classes for Poly1305 message authentication code.
IV_Requirement
Secure IVs requirements as enumerated values.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
unsigned int DigestSize() const
Provides the digest size of the hash.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
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.
std::string AlgorithmName() const
Provides the name of this algorithm.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
unsigned int DigestSize() const
Provides the digest size of the hash.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Classes for authenticated encryption modes of operation.
Base class for authenticated encryption modes of operation.
XChaCha20Poly1305_Final< true > Encryption
XChaCha20Poly1305 encryption.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
lword MaxFooterLength() const
Provides the the maximum length of AAD.
size_t MaxKeyLength() const
Returns largest valid key length.
size_t DefaultKeyLength() const
Returns default key length.
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
std::string AlgorithmName() const
Provides the name of this algorithm.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
Crypto++ library namespace.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
XChaCha20Poly1305 cipher final implementation.
Interface for message authentication codes.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
XChaCha20/Poly1305-TLS AEAD scheme.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
Interface for retrieving values given their names.
Abstract base classes that provide a uniform interface to this library.
size_t MinKeyLength() const
Returns smallest valid key length.
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
XChaCha20Poly1305 cipher base implementation.