AbZip  1.0.0
encryption.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 Andy Bray
4 **
5 ** This file is part of AbZip.
6 **
7 ** AbZip is free software: you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation, either version 3 of the License, or
10 ** (at your option) any later version.
11 **
12 ** AbZip is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with AbZip. If not, see <http://www.gnu.org/licenses/>.
19 **
20 ****************************************************************************/
21 
22 #ifndef ENCRYPTION_H
23 #define ENCRYPTION_H
24 
25 #include <QObject>
26 #include <QIODevice>
27 
28 #define RAND_SEED 3141592654UL // use PI as default pattern
29 #define AES_METHOD (99)
30 
32 enum tEncryptionType
33 {
34  encNone,
35  encCRC = 8, // Z_DEFLATE
36  encAES = AES_METHOD
37 };
38 
39 
41 {
42 public:
43  Encryption();
44  virtual ~Encryption(){}
45 
46  static Encryption* createEncryptor( quint32 type );
47 
48  virtual bool init( const QString& password ) = 0;
49  virtual void encryptBytes( char* buffer, qint64 read) = 0;
50  virtual void decryptBytes( char* buffer, qint64 read) = 0;
51 
52  virtual bool decryptHeader(QIODevice* ioDevice, const QString& password, quint16 crc ) = 0;
53  virtual qint32 encryptHeader(QIODevice* ioDevice, const QString& password, quint16 crc) = 0;
54 
55  // Not 'pure virtual' as not all encryption methods will need this
56  virtual qint32 decryptFooter(QIODevice* , quint16 ){ return 0;}
57  virtual qint32 encryptFooter(QIODevice* ){ return 0;}
58 
59 
60  virtual qint32 size(){ return 0; }
61 
62  bool isSupported( int method );
63 };
64 
65 #endif // ENCRYPTION_H
Definition: encryption.h:40