libcdoc 0.1.8
|
Provides encryption interface. More...
#include <CDocWriter.h>
Public Member Functions | |
virtual | ~CDocWriter () |
virtual result_t | addRecipient (const Recipient &rcpt)=0 |
Add recipient to container. | |
virtual result_t | beginEncryption ()=0 |
Prepares the stream for encryption. | |
virtual result_t | addFile (const std::string &name, size_t size)=0 |
Add a new file to the container. | |
virtual result_t | writeData (const uint8_t *src, size_t size)=0 |
Write data to the encrypted stream. | |
virtual result_t | finishEncryption ()=0 |
Finalizes the encryption stream. | |
virtual result_t | encrypt (MultiDataSource &src, const std::vector< libcdoc::Recipient > &recipients) |
Encrypt data and send to the output stream. | |
std::string | getLastErrorStr () |
Get the error text of the last failed operation. | |
Static Public Member Functions | |
static CDocWriter * | createWriter (int version, DataConsumer *dst, bool take_ownership, Configuration *conf, CryptoBackend *crypto, NetworkBackend *network) |
Create CDoc document writer. | |
static CDocWriter * | createWriter (int version, std::ostream &ofs, Configuration *conf, CryptoBackend *crypto, NetworkBackend *network) |
Create CDoc document writer. | |
static CDocWriter * | createWriter (int version, const std::string &path, Configuration *conf, CryptoBackend *crypto, NetworkBackend *network) |
Create CDoc document writer. | |
Public Attributes | |
const int | version |
The container version (1 or 2) | |
Protected Member Functions | |
CDocWriter (int _version, DataConsumer *dst, bool take_ownership) | |
void | setLastError (const std::string &message) |
Protected Attributes | |
std::string | last_error |
DataConsumer * | dst |
bool | owned |
Configuration * | conf = nullptr |
CryptoBackend * | crypto = nullptr |
NetworkBackend * | network = nullptr |
Provides encryption interface.
An abstract base class of CDoc1 and CDoc2 writers. Provides an unified interface for file creation and encryption.
|
virtual |
|
explicitprotected |
|
pure virtual |
Add a new file to the container.
Start streaming a new file into the container output stream. The name will be written to stream exactly as is. If size is >= 0 the number of bytes subsequently written has to match exactly. Otherwise the final size is determined by the actual number of bytes written.
name | the name to be used in container |
size | the size of the file |
Add recipient to container.
This adds new recipient to the list of container recipients. FMK (File Master Key) is encrypted separately for each recipient, using corresponding methods. All recipients should be added before the encryption starts.
rcpt | a Recipient object |
|
pure virtual |
Prepares the stream for encryption.
This may involve creating cryptographic ciphers, building headers and writing the initial part of the stream. All recipients should be added before a call to beginEncryption.
|
static |
Create CDoc document writer.
Creates a new CDoc document writer for file. Configuration and NetworkBackend may be null if keyservers are not used.
version | (1 or 2) |
path | output file path |
conf | a configuration object |
crypto | a cryptographic backend implementation |
network | a network backend implementation |
|
static |
Create CDoc document writer.
Creates a new CDoc document writer for DataConsumer. Configuration and NetworkBackend may be null if keyservers are not used.
version | (1 or 2) |
dst | output DataConsumer |
take_ownership | whether to close dst at the end of encryption and delete with CDocWiter |
conf | a configuration object |
crypto | a cryptographic backend implementation |
network | a network backend implementation |
|
static |
Create CDoc document writer.
Creates a new CDoc document writer for outputstream. Configuration and NetworkBackend may be null if keyservers are not used.
version | (1 or 2) |
ofs | output stream |
conf | a configuration object |
crypto | a cryptographic backend implementation |
network | a network backend implementation |
|
inlinevirtual |
Encrypt data and send to the output stream.
Encrypts the data, provided by MultiDataSource, in one go.
src | MultiDataSource providing input files (named chunks) |
recipients | a list of recipients for whom locks will be encoded into file |
References libcdoc::NOT_IMPLEMENTED.
|
pure virtual |
Finalizes the encryption stream.
This may involve flushing file, calculating checksum and closing the stream (if owned by CDocWriter)
|
inline |
Get the error text of the last failed operation.
Get the error message of the last failed operation. It should be called immediately after getting error code as certain methods may reset the error.
|
inlineprotected |
|
pure virtual |
Write data to the encrypted stream.
Writes data to the current file (created with addFile) in container. A single file may safely be written in multiple parts as long as the total size matches the one provided in addFile (or the total size was left indeterminate).
src | the source buffer |
size | the size of data in buffer |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
const int libcdoc::CDocWriter::version |
The container version (1 or 2)