19 void ChaCha20Poly1305_Base::RekeyCipherAndMac(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms)
27 AccessSymmetricCipher().ProcessString(derived, derived.size());
30 AccessMAC().
SetKey(derived, derived.size(), params);
37 void ChaCha20Poly1305_Base::SetKeyWithoutResync(
const byte *userKey,
size_t userKeyLength,
const NameValuePairs ¶ms)
40 m_userKey.
Assign(userKey, userKeyLength);
51 CRYPTOPP_UNUSED(params);
54 void ChaCha20Poly1305_Base::Resync(
const byte *iv,
size_t len)
57 RekeyCipherAndMac(m_userKey, m_userKey.
SizeInBytes(),
61 size_t ChaCha20Poly1305_Base::AuthenticateBlocks(
const byte *data,
size_t len)
63 AccessMAC().
Update(data, len);
67 void ChaCha20Poly1305_Base::AuthenticateLastHeaderBlock()
70 const byte zero[16] = {0};
71 size_t pad = (16 - (m_totalHeaderLength % 16)) % 16;
72 AccessMAC().
Update(zero, pad);
75 void ChaCha20Poly1305_Base::AuthenticateLastConfidentialBlock()
78 const byte zero[16] = {0};
79 size_t pad = (16 - (m_totalMessageLength % 16)) % 16;
80 AccessMAC().
Update(zero, pad);
83 void ChaCha20Poly1305_Base::AuthenticateLastFooterBlock(byte *mac,
size_t macSize)
85 CRYPTOPP_ALIGN_DATA(8) byte length[2*sizeof(word64)];
88 AccessMAC().
Update(length, sizeof(length));
90 m_state = State_KeySet;
101 bool ChaCha20Poly1305_Base::DecryptAndVerify(byte *message,
const byte *mac,
size_t macLength,
const byte *iv,
int ivLength,
const byte *aad,
size_t aadLength,
const byte *ciphertext,
size_t ciphertextLength)
117 void XChaCha20Poly1305_Base::RekeyCipherAndMac(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms)
125 AccessSymmetricCipher().ProcessString(derived, derived.size());
128 AccessMAC().
SetKey(derived, derived.size(), params);
135 void XChaCha20Poly1305_Base::SetKeyWithoutResync(
const byte *userKey,
size_t userKeyLength,
const NameValuePairs ¶ms)
138 m_userKey.
Assign(userKey, userKeyLength);
149 CRYPTOPP_UNUSED(params);
152 void XChaCha20Poly1305_Base::Resync(
const byte *iv,
size_t len)
155 RekeyCipherAndMac(m_userKey, m_userKey.
SizeInBytes(),
159 size_t XChaCha20Poly1305_Base::AuthenticateBlocks(
const byte *data,
size_t len)
161 AccessMAC().
Update(data, len);
165 void XChaCha20Poly1305_Base::AuthenticateLastHeaderBlock()
168 const byte zero[16] = {0};
169 size_t pad = (16 - (m_totalHeaderLength % 16)) % 16;
170 AccessMAC().
Update(zero, pad);
173 void XChaCha20Poly1305_Base::AuthenticateLastConfidentialBlock()
176 const byte zero[16] = {0};
177 size_t pad = (16 - (m_totalMessageLength % 16)) % 16;
178 AccessMAC().
Update(zero, pad);
181 void XChaCha20Poly1305_Base::AuthenticateLastFooterBlock(byte *mac,
size_t macSize)
183 CRYPTOPP_ALIGN_DATA(8) byte length[2*sizeof(word64)];
186 AccessMAC().
Update(length, sizeof(length));
188 m_state = State_KeySet;
Used to pass byte array input as part of a NameValuePairs object.
Classes for working with NameValuePairs.
ChaCha20/Poly1305-TLS AEAD scheme.
Utility functions for the Crypto++ library.
virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs)
Sets or reset the key of this object.
size_type SizeInBytes() const
Provides the number of bytes in the SecBlock.
void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock=NULL)
Access a block of memory.
void Resynchronize(const byte *iv, int length=-1)
Resynchronize with an IV.
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.
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.
Combines two sets of NameValuePairs.
byte order is little-endian
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
XChaCha20Poly1305 cipher base implementation.
void Assign(const T *ptr, size_type len)
Set contents and size from an array.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
const char * IV()
ConstByteArrayParameter, also accepts const byte * for backwards compatibility.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
An object that implements NameValuePairs.
ChaCha20Poly1305 cipher base implementation.
Crypto++ library namespace.
void TruncatedFinal(byte *mac, size_t macSize)
Computes the hash of the current message.
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.
Interface for retrieving values given their names.