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

Input streambuf that encrypts on the fly (streaming counterpart of the whole-buffer encrypt_cbc / ChaCha20 path). More...

#include <stream.hh>

Inheritance diagram for keepass::encrypt_ostreambuf:

Public Member Functions

 encrypt_ostreambuf (std::ostream &dst, Cipher< 16 > &cipher)
 Constructs a CBC-mode encrypting streambuf.
 
 encrypt_ostreambuf (std::ostream &dst, ChaCha20Cipher &cipher)
 Constructs a ChaCha20 encrypting streambuf.
 
 ~encrypt_ostreambuf () override
 Zeroizes the transient plaintext and chaining state.
 
int overflow (int c) override
 Buffers a character, encrypting one block when it reaches capacity.
 
std::streamsize xsputn (const char *s, std::streamsize count) override
 Writes several characters, applying cipher respectively.
 
int sync () override
 Finalizes the stream (PKCS #7 padding for CBC, partial block for ChaCha20).
 

Detailed Description

Input streambuf that encrypts on the fly (streaming counterpart of the whole-buffer encrypt_cbc / ChaCha20 path).

Wraps the plaintext in the same ciphertext produced by the existing blocking code: CBC mode with PKCS #7 padding for block ciphers and pure XOR with a 64-byte keystream for ChaCha20. This lets the exporters pipe the XML (and KDBX 4 inner header) directly into the cipher without ever materializing the plaintext or ciphertext in memory.

Constructor & Destructor Documentation

◆ encrypt_ostreambuf() [1/2]

keepass::encrypt_ostreambuf::encrypt_ostreambuf ( std::ostream &  dst,
Cipher< 16 > &  cipher 
)

Constructs a CBC-mode encrypting streambuf.

Parameters
dstThe output stream receiving the ciphertext.
cipherThe 16-byte block cipher used for CBC encryption.

◆ encrypt_ostreambuf() [2/2]

keepass::encrypt_ostreambuf::encrypt_ostreambuf ( std::ostream &  dst,
ChaCha20Cipher &  cipher 
)

Constructs a ChaCha20 encrypting streambuf.

Parameters
dstThe output stream receiving the ciphertext.
cipherThe ChaCha20 cipher used for keystream generation.

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