Disk ARchive 2.7.16
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 More... | |
tronconneuse (tronconneuse &&ref) noexcept | |
move constructor More... | |
tronconneuse & | operator= (const tronconneuse &ref) |
assignment operator More... | |
tronconneuse & | operator= (tronconneuse &&ref) noexcept |
move operator More... | |
virtual | ~tronconneuse () noexcept override |
destructor More... | |
virtual bool | skippable (skippability direction, const infinint &amount) override |
inherited from generic_file More... | |
virtual bool | skip (const infinint &pos) override |
inherited from generic_file More... | |
virtual bool | skip_to_eof () override |
inherited from generic_file More... | |
virtual bool | skip_relative (S_I x) override |
inherited from generic_file More... | |
virtual bool | truncatable (const infinint &pos) const override |
inherited from generic_file More... | |
virtual infinint | get_position () const override |
inherited from generic_file More... | |
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 More... | |
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 More... | |
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 More... | |
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 More... | |
virtual void | inherited_sync_write () override |
this protected inherited method is now private for inherited classes of tronconneuse More... | |
virtual void | inherited_flush_read () override |
this protected inherited method is now private for inherited classes of tronconneuse More... | |
virtual void | inherited_terminate () override |
this protected inherited method is now private for inherited classes of tronconneuse More... | |
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 More... | |
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 More... | |
infinint | buf_offset |
offset of the first byte in buf More... | |
U_32 | buf_byte_data |
number of byte of information in buf (buf_byte_data <= buf_size) More... | |
U_32 | buf_size |
size of allocated memory for clear data in buf More... | |
char * | buf |
decrypted data (or data to encrypt) More... | |
U_32 | clear_block_size |
max amount of data that will be encrypted at once (must stay less than buf_size) More... | |
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 More... | |
infinint | block_num |
block number we next read or write More... | |
generic_file * | encrypted |
generic_file where is put / get the encrypted data More... | |
U_32 | encrypted_buf_size |
allocated size of encrypted_buf More... | |
U_32 | encrypted_buf_data |
amount of byte of information in encrypted_buf More... | |
char * | encrypted_buf |
buffer of encrypted data (read or to write) More... | |
infinint | extra_buf_offset |
offset of the first byte of extra_buf More... | |
U_32 | extra_buf_size |
allocated size of extra_buf More... | |
U_32 | extra_buf_data |
amount of byte of information in extra_buf More... | |
char * | extra_buf |
additional read encrypted that follow what is in encrypted_buf used to check for clear data after encrypted data More... | |
bool | weof |
whether write_end_of_file() has been called More... | |
bool | reof |
whether we reached eof while reading More... | |
archive_version | reading_ver |
archive format we currently read More... | |
std::unique_ptr< crypto_module > | crypto |
wraps the per block encryption/decryption routines More... | |
trailing_clear_data_callback | trailing_clear_data |
callback function that gives the amount of clear data found at the end of the given file More... | |
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 |
|
inline |
copy constructor
Definition at line 70 of file tronconneuse.hpp.
|
inlinenoexcept |
move constructor
Definition at line 73 of file tronconneuse.hpp.
|
inlineoverridevirtualnoexcept |
destructor
Definition at line 82 of file tronconneuse.hpp.
|
inlineprivate |
return true if a there is a byte of information at the given offset
Definition at line 206 of file tronconneuse.hpp.
References buf_byte_data, and fill_buf().
|
inlineoverridevirtual |
returns the block size give to constructor
Definition at line 116 of file tronconneuse.hpp.
References clear_block_size.
|
inlineoverridevirtual |
inherited from generic_file
Implements libdar::generic_file.
Definition at line 95 of file tronconneuse.hpp.
References libdar::generic_file::is_terminated().
|
inlineprotected |
Definition at line 147 of file tronconneuse.hpp.
|
inlineoverrideprivatevirtual |
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
Definition at line 141 of file tronconneuse.hpp.
References buf_byte_data.
|
overrideprivatevirtual |
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.
|
inlineoverrideprivatevirtual |
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
Definition at line 137 of file tronconneuse.hpp.
References flush().
|
inlineoverrideprivatevirtual |
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
Definition at line 144 of file tronconneuse.hpp.
References flush().
|
inlineoverrideprivatevirtual |
this prorected inherited method is now private for inherited classed of tronconneuse
Implements libdar::generic_file.
Definition at line 134 of file tronconneuse.hpp.
|
overrideprivatevirtual |
inherited from generic_file
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
|
inline |
assignment operator
Definition at line 76 of file tronconneuse.hpp.
|
inlinenoexcept |
move operator
Definition at line 79 of file tronconneuse.hpp.
|
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 |
this method to modify the initial shift. This overrides the constructor "no_initial_shift" of the constructor
Definition at line 108 of file tronconneuse.hpp.
References initial_shift.
|
overridevirtual |
inherited from generic_file
Implements libdar::generic_file.
|
overridevirtual |
inherited from generic_file
Implements libdar::generic_file.
|
overridevirtual |
inherited from generic_file
Implements libdar::generic_file.
|
overridevirtual |
inherited from generic_file
Implements libdar::generic_file.
|
inlineoverridevirtual |
inherited from generic_file
Implements libdar::generic_file.
Definition at line 93 of file tronconneuse.hpp.
|
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().
|
private |
block number we next read or write
Definition at line 160 of file tronconneuse.hpp.
|
private |
decrypted data (or data to encrypt)
Definition at line 156 of file tronconneuse.hpp.
|
private |
number of byte of information in buf (buf_byte_data <= buf_size)
Definition at line 154 of file tronconneuse.hpp.
Referenced by check_current_position(), and inherited_flush_read().
|
private |
offset of the first byte in buf
Definition at line 153 of file tronconneuse.hpp.
|
private |
size of allocated memory for clear data in buf
Definition at line 155 of file tronconneuse.hpp.
|
private |
max amount of data that will be encrypted at once (must stay less than buf_size)
Definition at line 158 of file tronconneuse.hpp.
Referenced by get_clear_block_size().
|
private |
wraps the per block encryption/decryption routines
Definition at line 175 of file tronconneuse.hpp.
|
private |
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
Definition at line 159 of file tronconneuse.hpp.
|
private |
generic_file where is put / get the encrypted data
Definition at line 161 of file tronconneuse.hpp.
|
private |
buffer of encrypted data (read or to write)
Definition at line 165 of file tronconneuse.hpp.
|
private |
amount of byte of information in encrypted_buf
Definition at line 164 of file tronconneuse.hpp.
|
private |
allocated size of encrypted_buf
Definition at line 163 of file tronconneuse.hpp.
|
private |
additional read encrypted that follow what is in encrypted_buf used to check for clear data after encrypted data
Definition at line 170 of file tronconneuse.hpp.
|
private |
amount of byte of information in extra_buf
Definition at line 169 of file tronconneuse.hpp.
|
private |
offset of the first byte of extra_buf
Definition at line 167 of file tronconneuse.hpp.
|
private |
allocated size of extra_buf
Definition at line 168 of file tronconneuse.hpp.
|
private |
the initial_shift first bytes of the underlying file are not encrypted
Definition at line 151 of file tronconneuse.hpp.
Referenced by set_initial_shift().
|
private |
archive format we currently read
Definition at line 174 of file tronconneuse.hpp.
|
private |
whether we reached eof while reading
Definition at line 173 of file tronconneuse.hpp.
|
private |
callback function that gives the amount of clear data found at the end of the given file
Definition at line 176 of file tronconneuse.hpp.
Referenced by set_callback_trailing_clear_data().
|
private |
whether write_end_of_file() has been called
Definition at line 172 of file tronconneuse.hpp.