|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3:
4: Governed by the TrueCrypt License 2.4 the full text of which is contained
5: in the file License.txt included in TrueCrypt binary and source code
6: distribution packages.
7: */
8:
9: #ifndef TC_HEADER_Encryption_EncryptionMode
10: #define TC_HEADER_Encryption_EncryptionMode
11:
12: #include "Platform/Platform.h"
13: #include "Cipher.h"
14:
15: namespace TrueCrypt
16: {
17: class EncryptionMode;
18: typedef list < shared_ptr <EncryptionMode> > EncryptionModeList;
19:
20: class EncryptionMode
21: {
22: public:
23: virtual ~EncryptionMode ();
24:
25: virtual void Decrypt (byte *data, uint64 length) const = 0;
26: virtual void DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0;
27: virtual void Encrypt (byte *data, uint64 length) const = 0;
28: virtual void EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0;
29: static EncryptionModeList GetAvailableModes ();
30: virtual size_t GetKeySize () const = 0;
31: virtual wstring GetName () const = 0;
32: virtual shared_ptr <EncryptionMode> GetNew () const = 0;
33: virtual bool IsKeySet () const { return KeySet; }
34: virtual void SetKey (const ConstBufferPtr &key) = 0;
35: virtual void SetCiphers (const CipherList &ciphers) { Ciphers = ciphers; }
36: virtual void SetSectorOffset (int64 offset) { SectorOffset = offset; }
37:
38: protected:
39: EncryptionMode ();
40:
41: virtual void ValidateState () const;
42: void ValidateParameters (byte *data, uint64 length) const;
43: virtual void ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const;
44:
45: static const size_t EncryptionDataUnitSize = 512;
46:
47: CipherList Ciphers;
48: bool KeySet;
49: uint64 SectorOffset;
50:
51: private:
52: EncryptionMode (const EncryptionMode &);
53: EncryptionMode &operator= (const EncryptionMode &);
54: };
55: }
56:
57: #endif // TC_HEADER_Encryption_EncryptionMode
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.