Bitcoin Core 28.99.0
P2P Digital Currency
|
Forward-secure wrapper around AEADChaCha20Poly1305. More...
#include <chacha20poly1305.h>
Public Member Functions | |
FSChaCha20Poly1305 (const FSChaCha20Poly1305 &)=delete | |
FSChaCha20Poly1305 (FSChaCha20Poly1305 &&)=delete | |
FSChaCha20Poly1305 & | operator= (const FSChaCha20Poly1305 &)=delete |
FSChaCha20Poly1305 & | operator= (FSChaCha20Poly1305 &&)=delete |
FSChaCha20Poly1305 (Span< const std::byte > key, uint32_t rekey_interval) noexcept | |
Construct an FSChaCha20Poly1305 cipher that rekeys every rekey_interval operations. More... | |
void | Encrypt (Span< const std::byte > plain, Span< const std::byte > aad, Span< std::byte > cipher) noexcept |
Encrypt a message with a specified aad. More... | |
void | Encrypt (Span< const std::byte > plain1, Span< const std::byte > plain2, Span< const std::byte > aad, Span< std::byte > cipher) noexcept |
Encrypt a message (given split into plain1 + plain2) with a specified aad. More... | |
bool | Decrypt (Span< const std::byte > cipher, Span< const std::byte > aad, Span< std::byte > plain) noexcept |
Decrypt a message with a specified aad. More... | |
bool | Decrypt (Span< const std::byte > cipher, Span< const std::byte > aad, Span< std::byte > plain1, Span< std::byte > plain2) noexcept |
Decrypt a message with a specified aad and split the result. More... | |
Static Public Attributes | |
static constexpr auto | KEYLEN = AEADChaCha20Poly1305::KEYLEN |
Length of keys expected by the constructor. More... | |
static constexpr auto | EXPANSION = AEADChaCha20Poly1305::EXPANSION |
Expansion when encrypting. More... | |
Private Member Functions | |
void | NextPacket () noexcept |
Update counters (and if necessary, key) to transition to the next message. More... | |
Private Attributes | |
AEADChaCha20Poly1305 | m_aead |
Internal AEAD. More... | |
const uint32_t | m_rekey_interval |
Every how many iterations this cipher rekeys. More... | |
uint32_t | m_packet_counter {0} |
The number of encryptions/decryptions since the last rekey. More... | |
uint64_t | m_rekey_counter {0} |
The number of rekeys performed so far. More... | |
Forward-secure wrapper around AEADChaCha20Poly1305.
This implements an AEAD which automatically increments the nonce on every encryption or decryption, and cycles keys after a predetermined number of encryptions or decryptions.
See BIP324 for details.
Definition at line 82 of file chacha20poly1305.h.
|
delete |
|
delete |
|
inlinenoexcept |
Construct an FSChaCha20Poly1305 cipher that rekeys every rekey_interval operations.
Definition at line 114 of file chacha20poly1305.h.
|
inlinenoexcept |
Decrypt a message with a specified aad.
Returns true if valid.
Requires cipher.size() = plain.size() + EXPANSION.
Definition at line 136 of file chacha20poly1305.h.
|
noexcept |
Decrypt a message with a specified aad and split the result.
Returns true if valid.
Requires cipher.size() = plain1.size() + plain2.size() + EXPANSION.
Definition at line 130 of file chacha20poly1305.cpp.
|
inlinenoexcept |
Encrypt a message with a specified aad.
Requires cipher.size() = plain.size() + EXPANSION.
Definition at line 121 of file chacha20poly1305.h.
|
noexcept |
Encrypt a message (given split into plain1 + plain2) with a specified aad.
Requires cipher.size() = plain.size() + EXPANSION.
Definition at line 124 of file chacha20poly1305.cpp.
|
privatenoexcept |
Update counters (and if necessary, key) to transition to the next message.
Definition at line 106 of file chacha20poly1305.cpp.
|
delete |
|
delete |
|
staticconstexpr |
Expansion when encrypting.
Definition at line 105 of file chacha20poly1305.h.
|
staticconstexpr |
Length of keys expected by the constructor.
Definition at line 102 of file chacha20poly1305.h.
|
private |
Internal AEAD.
Definition at line 86 of file chacha20poly1305.h.
|
private |
The number of encryptions/decryptions since the last rekey.
Definition at line 92 of file chacha20poly1305.h.
|
private |
The number of rekeys performed so far.
Definition at line 95 of file chacha20poly1305.h.
|
private |
Every how many iterations this cipher rekeys.
Definition at line 89 of file chacha20poly1305.h.