Bitcoin Core 28.99.0
P2P Digital Currency
|
The AEAD_CHACHA20_POLY1305 authenticated encryption algorithm from RFC8439 section 2.8. More...
#include <chacha20poly1305.h>
Public Types | |
using | Nonce96 = ChaCha20::Nonce96 |
96-bit nonce type. More... | |
Public Member Functions | |
AEADChaCha20Poly1305 (Span< const std::byte > key) noexcept | |
Initialize an AEAD instance with a specified 32-byte key. More... | |
void | SetKey (Span< const std::byte > key) noexcept |
Switch to another 32-byte key. More... | |
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. More... | |
void | Encrypt (Span< const std::byte > plain1, Span< const std::byte > plain2, Span< const std::byte > aad, Nonce96 nonce, Span< std::byte > cipher) noexcept |
Encrypt a message (given split into plain1 + plain2) with a specified 96-bit nonce and aad. More... | |
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. More... | |
bool | Decrypt (Span< const std::byte > cipher, Span< const std::byte > aad, Nonce96 nonce, Span< std::byte > plain1, Span< std::byte > plain2) noexcept |
Decrypt a message with a specified 96-bit nonce and aad and split the result. More... | |
void | Keystream (Nonce96 nonce, Span< std::byte > keystream) noexcept |
Get a number of keystream bytes from the underlying stream cipher. More... | |
Static Public Attributes | |
static constexpr unsigned | KEYLEN = 32 |
Expected size of key argument in constructor. More... | |
static constexpr unsigned | EXPANSION = Poly1305::TAGLEN |
Expansion when encrypting. More... | |
Private Attributes | |
ChaCha20 | m_chacha20 |
Internal stream cipher. More... | |
The AEAD_CHACHA20_POLY1305 authenticated encryption algorithm from RFC8439 section 2.8.
Definition at line 16 of file chacha20poly1305.h.
96-bit nonce type.
Definition at line 35 of file chacha20poly1305.h.
|
noexcept |
Initialize an AEAD instance with a specified 32-byte key.
Definition at line 16 of file chacha20poly1305.cpp.
|
inlinenoexcept |
Decrypt a message with a specified 96-bit nonce and aad.
Returns true if valid.
Requires cipher.size() = plain.size() + EXPANSION.
Definition at line 56 of file chacha20poly1305.h.
|
noexcept |
Decrypt a message with a specified 96-bit nonce and aad and split the result.
Returns true if valid.
Requires cipher.size() = plain1.size() + plain2.size() + EXPANSION.
Definition at line 83 of file chacha20poly1305.cpp.
|
inlinenoexcept |
Encrypt a message with a specified 96-bit nonce and aad.
Requires cipher.size() = plain.size() + EXPANSION.
Definition at line 41 of file chacha20poly1305.h.
|
noexcept |
Encrypt a message (given split into plain1 + plain2) with a specified 96-bit nonce and aad.
Requires cipher.size() = plain1.size() + plain2.size() + EXPANSION.
Definition at line 69 of file chacha20poly1305.cpp.
Get a number of keystream bytes from the underlying stream cipher.
This is equivalent to Encrypt() with plain set to that many zero bytes, and dropping the last EXPANSION bytes off the result.
Definition at line 99 of file chacha20poly1305.cpp.
|
noexcept |
Switch to another 32-byte key.
Definition at line 21 of file chacha20poly1305.cpp.
|
staticconstexpr |
Expansion when encrypting.
Definition at line 26 of file chacha20poly1305.h.
|
staticconstexpr |
Expected size of key argument in constructor.
Definition at line 23 of file chacha20poly1305.h.
|
private |
Internal stream cipher.
Definition at line 19 of file chacha20poly1305.h.