This class is a helper for encrypted stream output. More...
#include <DwmCredenceXChaCha20Poly1305OutBuffer.hh>
Inherits std::streambuf.
Public Member Functions | |
| OutBuffer (std::ostream &os, const std::string &key) | |
Construct with the given ostream os and encryption key key. | |
Protected Member Functions | |
| int_type | overflow (int_type c) override |
| int | sync () override |
| std::streamsize | xsputn (const char *p, std::streamsize n) override |
This class is a helper for encrypted stream output.
It is used as a streambuf for an ostream. It will buffer internally until flush() is called on the ostream that owns the buffer (which will end up calling our sync() member). When our sync() member is called, we will write a random nonce (initialization vector), the encrypted data and the MAC to the associated ostream that was passed as the first argument of the constructor. In other words, message packaging and transmission occurs whenever our sync() member is called.
This class is typically not used directly, but is instead instantiated by Dwm::Credence::XChaCha20Poly1305::Ostream.