|
|
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_EncryptionModeCBC
10: #define TC_HEADER_Encryption_EncryptionModeCBC
11:
12: #include "Platform/Platform.h"
13: #include "EncryptionMode.h"
14:
15: namespace TrueCrypt
16: {
17: class EncryptionModeCBC : public EncryptionMode
18: {
19: public:
20: EncryptionModeCBC () { }
21: virtual ~EncryptionModeCBC () { }
22:
23: virtual void Decrypt (byte *data, uint64 length) const;
24: virtual void DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
25: virtual void Encrypt (byte *data, uint64 length) const;
26: virtual void EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
27: virtual size_t GetKeySize () const { return 32; };
28: virtual wstring GetName () const { return L"CBC"; };
29: virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeCBC); }
30: virtual void SetKey (const ConstBufferPtr &key);
31:
32: protected:
33: void DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const;
34: void EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const;
35: void InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const;
36: bool IsOuterCBC (const CipherList &ciphers) const;
37:
38: SecureBuffer IV;
39: static const int WhiteningIVOffset = 8;
40:
41: private:
42: EncryptionModeCBC (const EncryptionModeCBC &);
43: EncryptionModeCBC &operator= (const EncryptionModeCBC &);
44: };
45: }
46:
47: #endif // TC_HEADER_Encryption_EncryptionModeCBC
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.