Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
FSChaCha20 Class Reference

Forward-secure ChaCha20. More...

#include <chacha20.h>

Collaboration diagram for FSChaCha20:
[legend]

Public Member Functions

 FSChaCha20 (const FSChaCha20 &)=delete
 FSChaCha20 (FSChaCha20 &&)=delete
FSChaCha20operator= (const FSChaCha20 &)=delete
FSChaCha20operator= (FSChaCha20 &&)=delete
 FSChaCha20 (std::span< const std::byte > key, uint32_t rekey_interval) noexcept
 Construct an FSChaCha20 cipher that rekeys every rekey_interval Crypt() calls.
void Crypt (std::span< const std::byte > input, std::span< std::byte > output) noexcept
 Encrypt or decrypt a chunk.

Static Public Attributes

static constexpr unsigned KEYLEN = 32
 Length of keys expected by the constructor.

Private Attributes

ChaCha20 m_chacha20
 Internal stream cipher.
const uint32_t m_rekey_interval
 The number of encryptions/decryptions before a rekey happens.
uint32_t m_chunk_counter {0}
 The number of encryptions/decryptions since the last rekey.
uint64_t m_rekey_counter {0}
 The number of rekey operations that have happened.

Detailed Description

Forward-secure ChaCha20.

This implements a stream cipher that automatically transitions to a new stream with a new key and new nonce after a predefined number of encryptions or decryptions.

See BIP324 for details.

Definition at line 125 of file chacha20.h.

Constructor & Destructor Documentation

◆ FSChaCha20() [1/3]

FSChaCha20::FSChaCha20 ( const FSChaCha20 & )
delete
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FSChaCha20() [2/3]

FSChaCha20::FSChaCha20 ( FSChaCha20 && )
delete
Here is the call graph for this function:

◆ FSChaCha20() [3/3]

FSChaCha20::FSChaCha20 ( std::span< const std::byte > key,
uint32_t rekey_interval )
noexcept

Construct an FSChaCha20 cipher that rekeys every rekey_interval Crypt() calls.

Definition at line 343 of file chacha20.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ Crypt()

void FSChaCha20::Crypt ( std::span< const std::byte > input,
std::span< std::byte > output )
noexcept

Encrypt or decrypt a chunk.

Definition at line 349 of file chacha20.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

FSChaCha20 & FSChaCha20::operator= ( const FSChaCha20 & )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

FSChaCha20 & FSChaCha20::operator= ( FSChaCha20 && )
delete
Here is the call graph for this function:

Member Data Documentation

◆ KEYLEN

unsigned FSChaCha20::KEYLEN = 32
staticconstexpr

Length of keys expected by the constructor.

Definition at line 142 of file chacha20.h.

◆ m_chacha20

ChaCha20 FSChaCha20::m_chacha20
private

Internal stream cipher.

Definition at line 129 of file chacha20.h.

◆ m_chunk_counter

uint32_t FSChaCha20::m_chunk_counter {0}
private

The number of encryptions/decryptions since the last rekey.

Definition at line 135 of file chacha20.h.

◆ m_rekey_counter

uint64_t FSChaCha20::m_rekey_counter {0}
private

The number of rekey operations that have happened.

Definition at line 138 of file chacha20.h.

◆ m_rekey_interval

const uint32_t FSChaCha20::m_rekey_interval
private

The number of encryptions/decryptions before a rekey happens.

Definition at line 132 of file chacha20.h.


The documentation for this class was generated from the following files: