| Disk ARchive 2.8.5 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
libdar::tronconneuse Class Reference
Private

this is a partial implementation of the generic_file interface to cypher/decypher data block by block. More...

`#include <tronconneuse.hpp>`

## 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.
| 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
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
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
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
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

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ tronconneuse() [1/3]

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.

Parameters

  [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

Note
  that encrypted_side is not owned and destroyed by tronconneuse, it must exist during all the life of the tronconneuse object, and is not destroyed by the tronconneuse's destructor

References reading_ver.

Referenced by operator=(), operator=(), tronconneuse(), and tronconneuse().

## ◆ tronconneuse() [2/3]

libdar::tronconneuse::tronconneuse | ( | const tronconneuse & | ref | ) |
| inline

copy constructor

Definition at line 70 of file tronconneuse.hpp.

References tronconneuse().

## ◆ tronconneuse() [3/3]

libdar::tronconneuse::tronconneuse | ( | tronconneuse && | ref | ) |
| inline noexcept

move constructor

Definition at line 73 of file tronconneuse.hpp.

References tronconneuse().

## ◆ ~tronconneuse()

virtual libdar::tronconneuse::~tronconneuse | ( |  | ) |
| inline override virtual noexcept

destructor

Definition at line 82 of file tronconneuse.hpp.

## Member Function Documentation

## ◆ check_current_position()

bool libdar::tronconneuse::check_current_position | ( |  | ) |
| inline private

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, check_current_position(), and fill_buf().

Referenced by check_current_position().

## ◆ get_clear_block_size()

virtual U_32 libdar::tronconneuse::get_clear_block_size | ( |  | ) | const
| inline override virtual

returns the block size give to constructor

Definition at line 116 of file tronconneuse.hpp.

References clear_block_size.

## ◆ get_position()

virtual infinint libdar::tronconneuse::get_position | ( |  | ) | const
| inline override virtual

inherited from generic_file

Implements libdar::generic_file.

Definition at line 95 of file tronconneuse.hpp.

References current_position, and libdar::generic_file::is_terminated().

## ◆ get_reading_version()

const archive_version & libdar::tronconneuse::get_reading_version | ( |  | ) | const
| inline protected

Definition at line 147 of file tronconneuse.hpp.

## ◆ inherited_flush_read()

virtual void libdar::tronconneuse::inherited_flush_read | ( |  | ) |
| inline override private virtual

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.

## ◆ inherited_read()

virtual U_I libdar::tronconneuse::inherited_read | ( | char * | a,
|  | U_I | size )
| override private virtual

this protected inherited method is now private for inherited classes of tronconneuse

Implements libdar::generic_file.

## ◆ inherited_read_ahead()

virtual void libdar::tronconneuse::inherited_read_ahead | ( | const infinint & | amount | ) |
| override private virtual

inherited from generic_file

this protected inherited method is now private for inherited classes of tronconneuse

Implements libdar::generic_file.

## ◆ inherited_sync_write()

virtual void libdar::tronconneuse::inherited_sync_write | ( |  | ) |
| inline override private virtual

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().

## ◆ inherited_terminate()

virtual void libdar::tronconneuse::inherited_terminate | ( |  | ) |
| inline override private virtual

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().

## ◆ inherited_truncate()

virtual void libdar::tronconneuse::inherited_truncate | ( | const infinint & | pos | ) |
| inline override private virtual

this prorected inherited method is now private for inherited classed of tronconneuse

Implements libdar::generic_file.

Definition at line 134 of file tronconneuse.hpp.

## ◆ inherited_write()

virtual void libdar::tronconneuse::inherited_write | ( | const char * | a,
|  | U_I | size )
| override private virtual

inherited from generic_file

this protected inherited method is now private for inherited classes of tronconneuse

Implements libdar::generic_file.

## ◆ operator=() [1/2]

tronconneuse & libdar::tronconneuse::operator= | ( | const tronconneuse & | ref | ) |
| inline

assignment operator

Definition at line 76 of file tronconneuse.hpp.

References libdar::generic_file::operator=(), and tronconneuse().

## ◆ operator=() [2/2]

tronconneuse & libdar::tronconneuse::operator= | ( | tronconneuse && | ref | ) |
| inline noexcept

move operator

Definition at line 79 of file tronconneuse.hpp.

References libdar::generic_file::operator=(), and tronconneuse().

## ◆ position_clear2crypt()

void libdar::tronconneuse::position_clear2crypt | ( | const infinint & | pos,
|  | infinint & | file_buf_start,
|  | infinint & | clear_buf_start,
|  | infinint & | pos_in_buf,
|  | infinint & | block_num )
| private

convert clear position to corresponding position in the encrypted data

Parameters

  [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

References block_num, and position_clear2crypt().

Referenced by position_clear2crypt().

## ◆ position_crypt2clear()

void libdar::tronconneuse::position_crypt2clear | ( | const infinint & | pos,
|  | infinint & | clear_pos )
| private

gives the position of the next character of clear data that corresponds to the encrypted data which index is pos

References position_crypt2clear().

Referenced by position_crypt2clear().

## ◆ remove_trailing_clear_data_from_encrypted_buf()

void libdar::tronconneuse::remove_trailing_clear_data_from_encrypted_buf | ( | const infinint & | crypt_offset | ) |
| private

remove clear data at the end of the encrypted_buf

Parameters

  [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

## ◆ set_callback_trailing_clear_data()

virtual void libdar::tronconneuse::set_callback_trailing_clear_data | ( | trailing_clear_data_callback | callback | ) |
| inline override virtual

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.

## ◆ set_initial_shift()

virtual void libdar::tronconneuse::set_initial_shift | ( | const infinint & | x | ) |
| inline override virtual

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.

## ◆ skip()

virtual bool libdar::tronconneuse::skip | ( | const infinint & | pos | ) |
| override virtual

inherited from generic_file

Implements libdar::generic_file.

## ◆ skip_relative()

virtual bool libdar::tronconneuse::skip_relative | ( | S_I | x | ) |
| override virtual

inherited from generic_file

Implements libdar::generic_file.

## ◆ skip_to_eof()

virtual bool libdar::tronconneuse::skip_to_eof | ( |  | ) |
| override virtual

inherited from generic_file

Implements libdar::generic_file.

## ◆ skippable()

virtual bool libdar::tronconneuse::skippable | ( | skippability | direction,
|  | const infinint & | amount )
| override virtual

inherited from generic_file

Implements libdar::generic_file.

## ◆ truncatable()

virtual bool libdar::tronconneuse::truncatable | ( | const infinint & | pos | ) | const
| inline override virtual

inherited from generic_file

Implements libdar::generic_file.

Definition at line 93 of file tronconneuse.hpp.

## ◆ write_end_of_file()

virtual void libdar::tronconneuse::write_end_of_file | ( |  | ) |
| inline override virtual

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

Note
  this call cannot be used from the destructor, because it relies on pure virtual methods

Definition at line 103 of file tronconneuse.hpp.

References flush(), libdar::generic_file::is_terminated(), and weof.

## Member Data Documentation

## ◆ block_num

infinint libdar::tronconneuse::block_num
| private

block number we next read or write

Definition at line 160 of file tronconneuse.hpp.

Referenced by position_clear2crypt().

## ◆ buf

char* libdar::tronconneuse::buf
| private

decrypted data (or data to encrypt)

Definition at line 156 of file tronconneuse.hpp.

## ◆ buf_byte_data

U_32 libdar::tronconneuse::buf_byte_data
| 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().

## ◆ buf_offset

infinint libdar::tronconneuse::buf_offset
| private

offset of the first byte in buf

Definition at line 153 of file tronconneuse.hpp.

## ◆ buf_size

U_32 libdar::tronconneuse::buf_size
| private

size of allocated memory for clear data in buf

Definition at line 155 of file tronconneuse.hpp.

## ◆ clear_block_size

U_32 libdar::tronconneuse::clear_block_size
| 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().

## ◆ crypto

std::unique_ptr<crypto_module> libdar::tronconneuse::crypto
| private

wraps the per block encryption/decryption routines

Definition at line 175 of file tronconneuse.hpp.

## ◆ current_position

infinint libdar::tronconneuse::current_position
| 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.

Referenced by get_position().

## ◆ encrypted

generic_file* libdar::tronconneuse::encrypted
| private

generic_file where is put / get the encrypted data

Definition at line 161 of file tronconneuse.hpp.

## ◆ encrypted_buf

char* libdar::tronconneuse::encrypted_buf
| private

buffer of encrypted data (read or to write)

Definition at line 165 of file tronconneuse.hpp.

## ◆ encrypted_buf_data

U_32 libdar::tronconneuse::encrypted_buf_data
| private

amount of byte of information in encrypted_buf

Definition at line 164 of file tronconneuse.hpp.

## ◆ encrypted_buf_size

U_32 libdar::tronconneuse::encrypted_buf_size
| private

allocated size of encrypted_buf

Definition at line 163 of file tronconneuse.hpp.

## ◆ extra_buf

char* libdar::tronconneuse::extra_buf
| 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.

## ◆ extra_buf_data

U_32 libdar::tronconneuse::extra_buf_data
| private

amount of byte of information in extra_buf

Definition at line 169 of file tronconneuse.hpp.

## ◆ extra_buf_offset

infinint libdar::tronconneuse::extra_buf_offset
| private

offset of the first byte of extra_buf

Definition at line 167 of file tronconneuse.hpp.

## ◆ extra_buf_size

U_32 libdar::tronconneuse::extra_buf_size
| private

allocated size of extra_buf

Definition at line 168 of file tronconneuse.hpp.

## ◆ initial_shift

infinint libdar::tronconneuse::initial_shift
| 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().

## ◆ reading_ver

archive_version libdar::tronconneuse::reading_ver
| private

archive format we currently read

Definition at line 174 of file tronconneuse.hpp.

Referenced by tronconneuse().

## ◆ reof

bool libdar::tronconneuse::reof
| private

whether we reached eof while reading

Definition at line 173 of file tronconneuse.hpp.

## ◆ trailing_clear_data

trailing_clear_data_callback libdar::tronconneuse::trailing_clear_data
| 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().

## ◆ weof

bool libdar::tronconneuse::weof
| private

whether write_end_of_file() has been called

Definition at line 172 of file tronconneuse.hpp.

Referenced by write_end_of_file().

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

- tronconneuse.hpp