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

Salsa20 stream cipher implementation. More...

#include <cipher.hh>

Public Member Functions

 Salsa20Cipher (const uint8_t *key)
 Constructs a Salsa20 cipher with a zero nonce.
 
 Salsa20Cipher (const uint8_t *key, const std::array< uint8_t, 8 > &init_vec)
 Constructs a Salsa20 cipher with a given 64-bit nonce.
 
 ~Salsa20Cipher ()
 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

Salsa20 stream cipher implementation.

Constructor & Destructor Documentation

◆ Salsa20Cipher() [1/2]

keepass::Salsa20Cipher::Salsa20Cipher ( const uint8_t *  key)
inlineexplicit

Constructs a Salsa20 cipher with a zero nonce.

Parameters
keyThe 256-bit (32-byte) encryption key.

◆ Salsa20Cipher() [2/2]

keepass::Salsa20Cipher::Salsa20Cipher ( const uint8_t *  key,
const std::array< uint8_t, 8 > &  init_vec 
)

Constructs a Salsa20 cipher with a given 64-bit nonce.

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

Member Function Documentation

◆ Process()

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

Encrypts or decrypts a single 64-byte block.

Because Salsa20 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: