![]()  | 
  
    Bitcoin Core 30.99.0
    
   P2P Digital Currency 
   | 
 
ChaCha20 cipher that only operates on multiples of 64 bytes. More...
#include <chacha20.h>
Public Types | |
| using | Nonce96 = std::pair< uint32_t, uint64_t > | 
| Type for 96-bit nonces used by the Set function below.  More... | |
Public Member Functions | |
| ChaCha20Aligned () noexcept=delete | |
| For safety, disallow initialization without key.  More... | |
| ChaCha20Aligned (std::span< const std::byte > key) noexcept | |
| Initialize a cipher with specified 32-byte key.  More... | |
| ~ChaCha20Aligned () | |
| Destructor to clean up private memory.  More... | |
| void | SetKey (std::span< const std::byte > key) noexcept | 
| Set 32-byte key, and seek to nonce 0 and block position 0.  More... | |
| void | Seek (Nonce96 nonce, uint32_t block_counter) noexcept | 
| Set the 96-bit nonce and 32-bit block counter.  More... | |
| void | Keystream (std::span< std::byte > out) noexcept | 
| outputs the keystream into out, whose length must be a multiple of BLOCKLEN.  More... | |
| void | Crypt (std::span< const std::byte > input, std::span< std::byte > output) noexcept | 
| en/deciphers the message <input> and write the result into <output>  More... | |
Static Public Attributes | |
| static constexpr unsigned | KEYLEN {32} | 
| Expected key length in constructor and SetKey.  More... | |
| static constexpr unsigned | BLOCKLEN {64} | 
| Block size (inputs/outputs to Keystream / Crypt should be multiples of this).  More... | |
Private Attributes | |
| uint32_t | input [12] | 
ChaCha20 cipher that only operates on multiples of 64 bytes.
Definition at line 24 of file chacha20.h.
| using ChaCha20Aligned::Nonce96 = std::pair<uint32_t, uint64_t> | 
Type for 96-bit nonces used by the Set function below.
The first field corresponds to the LE32-encoded first 4 bytes of the nonce, also referred to as the '32-bit fixed-common part' in Example 2.8.2 of RFC8439.
The second field corresponds to the LE64-encoded last 8 bytes of the nonce.
Definition at line 56 of file chacha20.h.
      
  | 
  deletenoexcept | 
For safety, disallow initialization without key.
      
  | 
  noexcept | 
Initialize a cipher with specified 32-byte key.
Definition at line 46 of file chacha20.cpp.
| ChaCha20Aligned::~ChaCha20Aligned | ( | ) | 
Destructor to clean up private memory.
Definition at line 41 of file chacha20.cpp.
      
  | 
  inlinenoexcept | 
en/deciphers the message <input> and write the result into <output>
The size of input and output must be equal, and be a multiple of BLOCKLEN.
Definition at line 160 of file chacha20.cpp.
      
  | 
  inlinenoexcept | 
outputs the keystream into out, whose length must be a multiple of BLOCKLEN.
Definition at line 59 of file chacha20.cpp.
      
  | 
  noexcept | 
Set the 96-bit nonce and 32-bit block counter.
Block_counter selects a position to seek to (to byte BLOCKLEN*block_counter). After 256 GiB, the block counter overflows, and nonce.first is incremented.
Definition at line 51 of file chacha20.cpp.
      
  | 
  noexcept | 
Set 32-byte key, and seek to nonce 0 and block position 0.
Definition at line 24 of file chacha20.cpp.
      
  | 
  staticconstexpr | 
Block size (inputs/outputs to Keystream / Crypt should be multiples of this).
Definition at line 34 of file chacha20.h.
      
  | 
  private | 
Definition at line 27 of file chacha20.h.
      
  | 
  staticconstexpr | 
Expected key length in constructor and SetKey.
Definition at line 31 of file chacha20.h.