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

scrambler.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef SCRAMBLER_HPP
27 #define SCRAMBLER_HPP
28
29 #include "../my_config.h"
30 #include <string>
31 #include "infinint.hpp"
32 #include "generic_file.hpp"
33 #include "erreurs.hpp"
34 #include "secu_string.hpp"
35
36 namespace libdar
37 {
38
41
42
44
45 class scrambler : public generic_file
46 {
47 public:
48 scrambler(const secu_string & pass, generic_file & hidden_side);
49 scrambler(const scrambler & ref) = delete;
50 scrambler(scrambler && ref) noexcept = delete;
51 scrambler & operator = (const scrambler & ref) = delete;
52 scrambler & operator = (scrambler && ref) noexcept = delete;
53 ~scrambler() { if(buffer != nullptr) delete [] buffer; };
54
55
56 virtual bool skippable(skippability direction, const infinint & amount) override { return ref->skippable(direction, amount); };
57 virtual bool skip(const infinint & pos) override { if(ref == nullptr) throw SRC_BUG; return ref->skip(pos); };
58 virtual bool skip_to_eof() override { if(ref==nullptr) throw SRC_BUG; return ref->skip_to_eof(); };
59 virtual bool skip_relative(S_I x) override { if(ref == nullptr) throw SRC_BUG; return ref->skip_relative(x); };
60 virtual infinint get_position() const override { if(ref == nullptr) throw SRC_BUG; return ref->get_position(); };
61
62 protected:
63 virtual void inherited_read_ahead(const infinint & amount) override { ref->read_ahead(amount); };
64 virtual U_I inherited_read(char *a, U_I size) override;
65 virtual void inherited_write(const char *a, U_I size) override;
66 virtual void inherited_sync_write() override {}; // nothing to do
67 virtual void inherited_flush_read() override {}; // nothing to do
68 virtual void inherited_terminate() override {}; // nothing to do
69
70 private:
71 secu_string key;
72 U_I len;
73 generic_file *ref;
74 unsigned char *buffer;
75 U_I buf_size;
76 };
77
79
80 } // end of namespace
81
82 #endif
libdar::scrambler::inherited_read
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
libdar::scrambler
scrambler is a very weak encryption scheme
Definition: scrambler.hpp:46
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:62
libdar::scrambler::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
Definition: scrambler.hpp:57
libdar::scrambler::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
Definition: scrambler.hpp:59
libdar::scrambler::inherited_sync_write
virtual void inherited_sync_write() override
write down any pending data
Definition: scrambler.hpp:66
libdar::scrambler::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition: scrambler.hpp:56
generic_file.hpp
class generic_file is defined here as well as class fichier
erreurs.hpp
contains all the excetion class thrown by libdar
libdar::scrambler::inherited_terminate
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
Definition: scrambler.hpp:68
libdar::scrambler::inherited_write
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
secu_string.hpp
this file contains the definition of secu_string class, a std::string like class but allocated in sec...
libdar::generic_file::read_ahead
void read_ahead(const infinint &amount)
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition: generic_file.hpp:77
libdar::secu_string
class secu_string
Definition: secu_string.hpp:58
libdar::scrambler::inherited_flush_read
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition: scrambler.hpp:67
libdar::scrambler::inherited_read_ahead
virtual void inherited_read_ahead(const infinint &amount) override
tells the object that several calls to read() will follow to probably obtain at least the given amoun...
Definition: scrambler.hpp:63
libdar::scrambler::get_position
virtual infinint get_position() const override
get the current read/write position
Definition: scrambler.hpp:60
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::scrambler::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
Definition: scrambler.hpp:58