5 #ifndef BITCOIN_CRYPTO_CHACHA20POLY1305_H 6 #define BITCOIN_CRYPTO_CHACHA20POLY1305_H 23 static constexpr
unsigned KEYLEN = 32;
123 Encrypt(plain, {}, aad, cipher);
138 return Decrypt(cipher, aad, plain, {});
148 #endif // BITCOIN_CRYPTO_CHACHA20POLY1305_H The AEAD_CHACHA20_POLY1305 authenticated encryption algorithm from RFC8439 section 2...
uint64_t m_rekey_counter
The number of rekeys performed so far.
void Encrypt(Span< const std::byte > plain, Span< const std::byte > aad, Span< std::byte > cipher) noexcept
Encrypt a message with a specified aad.
Forward-secure wrapper around AEADChaCha20Poly1305.
uint32_t m_packet_counter
The number of encryptions/decryptions since the last rekey.
AEADChaCha20Poly1305(Span< const std::byte > key) noexcept
Initialize an AEAD instance with a specified 32-byte key.
ChaCha20Aligned::Nonce96 Nonce96
96-bit nonce type.
bool Decrypt(Span< const std::byte > cipher, Span< const std::byte > aad, Nonce96 nonce, Span< std::byte > plain) noexcept
Decrypt a message with a specified 96-bit nonce and aad.
void Encrypt(Span< const std::byte > plain, Span< const std::byte > aad, Nonce96 nonce, Span< std::byte > cipher) noexcept
Encrypt a message with a specified 96-bit nonce and aad.
AEADChaCha20Poly1305 m_aead
Internal AEAD.
const uint32_t m_rekey_interval
Every how many iterations this cipher rekeys.
static constexpr unsigned EXPANSION
Expansion when encrypting.
static constexpr unsigned KEYLEN
Expected size of key argument in constructor.
Unrestricted ChaCha20 cipher.
void NextPacket() noexcept
Update counters (and if necessary, key) to transition to the next message.
void SetKey(Span< const std::byte > key) noexcept
Switch to another 32-byte key.
ChaCha20 m_chacha20
Internal stream cipher.
void Keystream(Nonce96 nonce, Span< std::byte > keystream) noexcept
Get a number of keystream bytes from the underlying stream cipher.
ChaCha20::Nonce96 Nonce96
96-bit nonce type.
static constexpr auto EXPANSION
Expansion when encrypting.
static constexpr auto KEYLEN
Length of keys expected by the constructor.
static constexpr unsigned TAGLEN
Length of the output produced by Finalize().
bool Decrypt(Span< const std::byte > cipher, Span< const std::byte > aad, Span< std::byte > plain) noexcept
Decrypt a message with a specified aad.