Disk ARchive
2.7.15
Full featured and portable backup and archiving tool
|
this is a partial implementation of the generic_file interface to cypher/decypher data block by block. More...
#include <tronconneuse.hpp>
Inherits libdar::proto_tronco.
Public Member Functions | |
tronconneuse (U_32 block_size, generic_file &encrypted_side, const archive_version &reading_ver, std::unique_ptr< crypto_module > &ptr) | |
This is the constructor. More... | |
tronconneuse (const tronconneuse &ref) | |
copy constructor | |
tronconneuse (tronconneuse &&ref) noexcept | |
move constructor | |
tronconneuse & | operator= (const tronconneuse &ref) |
assignment operator | |
tronconneuse & | operator= (tronconneuse &&ref) noexcept |
move operator | |
virtual | ~tronconneuse () noexcept override |
destructor | |
virtual bool | skippable (skippability direction, const infinint &amount) override |
inherited from generic_file | |
virtual bool | skip (const infinint &pos) override |
inherited from generic_file | |
virtual bool | skip_to_eof () override |
inherited from generic_file | |
virtual bool | skip_relative (S_I x) override |
inherited from generic_file | |
virtual bool | truncatable (const infinint &pos) const override |
inherited from generic_file | |
virtual infinint | get_position () const override |
inherited from generic_file | |
virtual void | write_end_of_file () override |
in write_only mode indicate that end of file is reached More... | |
virtual void | set_initial_shift (const infinint &x) override |
this method to modify the initial shift. This overrides the constructor "no_initial_shift" of the constructor | |
virtual void | set_callback_trailing_clear_data (trailing_clear_data_callback callback) override |
virtual U_32 | get_clear_block_size () const override |
returns the block size give to constructor | |
Protected Member Functions | |
const archive_version & | get_reading_version () const |
Private Member Functions | |
virtual void | inherited_read_ahead (const infinint &amount) override |
inherited from generic_file More... | |
virtual U_I | inherited_read (char *a, U_I size) override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual void | inherited_write (const char *a, U_I size) override |
inherited from generic_file More... | |
virtual void | inherited_truncate (const infinint &pos) override |
this prorected inherited method is now private for inherited classed of tronconneuse | |
virtual void | inherited_sync_write () override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual void | inherited_flush_read () override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual void | inherited_terminate () override |
this protected inherited method is now private for inherited classes of tronconneuse | |
void | nullifyptr () noexcept |
void | detruit () noexcept |
void | copy_from (const tronconneuse &ref) |
void | move_from (tronconneuse &&ref) noexcept |
U_32 | fill_buf () |
returns the position (of the next read op) inside the buffer and fill the buffer with clear data | |
void | flush () |
flush any pending data (write mode only) to encrypted device | |
void | init_buf () |
initialize if necessary the various buffers that relies on inherited method values | |
void | position_clear2crypt (const infinint &pos, infinint &file_buf_start, infinint &clear_buf_start, infinint &pos_in_buf, infinint &block_num) |
convert clear position to corresponding position in the encrypted data More... | |
void | position_crypt2clear (const infinint &pos, infinint &clear_pos) |
bool | check_current_position () |
return true if a there is a byte of information at the given offset | |
void | remove_trailing_clear_data_from_encrypted_buf (const infinint &crypt_offset) |
Private Attributes | |
infinint | initial_shift |
the initial_shift first bytes of the underlying file are not encrypted | |
infinint | buf_offset |
offset of the first byte in buf | |
U_32 | buf_byte_data |
number of byte of information in buf (buf_byte_data <= buf_size) | |
U_32 | buf_size |
size of allocated memory for clear data in buf | |
char * | buf |
decrypted data (or data to encrypt) | |
U_32 | clear_block_size |
max amount of data that will be encrypted at once (must stay less than buf_size) | |
infinint | current_position |
position of the next character to read or write from the upper layer perspective, offset zero is the first encrypted byte, thus the first byte after initial_shift | |
infinint | block_num |
block number we next read or write | |
generic_file * | encrypted |
generic_file where is put / get the encrypted data | |
U_32 | encrypted_buf_size |
allocated size of encrypted_buf | |
U_32 | encrypted_buf_data |
amount of byte of information in encrypted_buf | |
char * | encrypted_buf |
buffer of encrypted data (read or to write) | |
infinint | extra_buf_offset |
offset of the first byte of extra_buf | |
U_32 | extra_buf_size |
allocated size of extra_buf | |
U_32 | extra_buf_data |
amount of byte of information in extra_buf | |
char * | extra_buf |
additional read encrypted that follow what is in encrypted_buf used to check for clear data after encrypted data | |
bool | weof |
whether write_end_of_file() has been called | |
bool | reof |
whether we reached eof while reading | |
archive_version | reading_ver |
archive format we currently read | |
std::unique_ptr< crypto_module > | crypto |
wraps the per block encryption/decryption routines | |
trailing_clear_data_callback | trailing_clear_data |
callback function that gives the amount of clear data found at the end of the given file | |
this is a partial implementation of the generic_file interface to cypher/decypher data block by block.
tronconneuse is either read_only or write_only, read_write is not allowed. The openning mode is defined by encrypted_side's mode. In write_only no skip() is allowed, writing is sequential from the beginning of the file to the end (like writing to a pipe). In read_only all skip() functions are available.
Definition at line 53 of file tronconneuse.hpp.
libdar::tronconneuse::tronconneuse | ( | U_32 | block_size, |
generic_file & | encrypted_side, | ||
const archive_version & | reading_ver, | ||
std::unique_ptr< crypto_module > & | ptr | ||
) |
This is the constructor.
[in] | block_size | is the size of block encryption (the size of clear data encrypted together). |
[in] | encrypted_side | where encrypted data are read from or written to. |
[in] | reading_ver | version of the archive format |
[in] | ptr | pointer to a crypto_module object that will be passed to the tronconneuse object |
|
overrideprivatevirtual |
inherited from generic_file
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
|
overrideprivatevirtual |
inherited from generic_file
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
|
private |
convert clear position to corresponding position in the encrypted data
[in] | pos | is the position in the clear data |
[out] | file_buf_start | is the position of the beginning of the crypted block where can be found the data |
[out] | clear_buf_start | is the position of the beginning of the corresponding clear block |
[out] | pos_in_buf | is the position in the clear block of the 'pos' offset |
[out] | block_num | is the block number we have our requested position inside |
|
private |
gives the position of the next character of clear data that corresponds to the encrypted data which index is pos
|
private |
remove clear data at the end of the encrypted_buf
[in] | crypt_offset | is the offset of the first byte of encrypted_buf not considering initial_shift bytes before the begining of the encrypted data |
|
inlineoverridevirtual |
let the caller give a callback function that given a generic_file with cyphered data, is able to return the offset of the first clear byte located after all the cyphered data, this callback function is used (if defined by the following method), when reaching End of File.
Definition at line 113 of file tronconneuse.hpp.
References trailing_clear_data.
|
inlineoverridevirtual |
in write_only mode indicate that end of file is reached
this call must be called in write mode to purge the internal cache before deleting the object (else some data may be lost) no further write call is allowed
Definition at line 103 of file tronconneuse.hpp.
References libdar::generic_file::is_terminated().