libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
keepass::ChaCha20Cipher Class Referencefinal

ChaCha20 stream cipher implementation (RFC 8439, 32-bit counter). More...

#include <cipher.hh>

Public Member Functions

 ChaCha20Cipher (const uint8_t *key, const std::array< uint8_t, 12 > &init_vec)
 Constructs a ChaCha20 cipher with the given key and nonce.
 
 ~ChaCha20Cipher ()
 Zeroizes the cipher state holding the key.
 
void Process (const std::array< uint8_t, 64 > &src, std::array< uint8_t, 64 > &dst)
 Encrypts or decrypts a single 64-byte block.
 

Detailed Description

ChaCha20 stream cipher implementation (RFC 8439, 32-bit counter).

Constructor & Destructor Documentation

◆ ChaCha20Cipher()

keepass::ChaCha20Cipher::ChaCha20Cipher ( const uint8_t *  key,
const std::array< uint8_t, 12 > &  init_vec 
)

Constructs a ChaCha20 cipher with the given key and nonce.

Parameters
keyThe 256-bit (32-byte) encryption key.
init_vecThe 12-byte nonce (initialization vector).

Member Function Documentation

◆ Process()

void keepass::ChaCha20Cipher::Process ( const std::array< uint8_t, 64 > &  src,
std::array< uint8_t, 64 > &  dst 
)

Encrypts or decrypts a single 64-byte block.

Because ChaCha20 is a stream cipher, encryption and decryption are the same XOR operation. The internal counter is advanced after each call.

Parameters
srcThe 64-byte input block (plaintext or ciphertext).
dstThe 64-byte output block (ciphertext or plaintext).

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