|
|
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: #include "EncryptionMode.h"
10: #include "EncryptionModeCBC.h"
11: #include "EncryptionModeLRW.h"
12: #include "EncryptionModeXTS.h"
13:
14: namespace TrueCrypt
15: {
16: EncryptionMode::EncryptionMode () : KeySet (false), SectorOffset (0)
17: {
18: }
19:
20: EncryptionMode::~EncryptionMode ()
21: {
22: }
23:
24: EncryptionModeList EncryptionMode::GetAvailableModes ()
25: {
26: EncryptionModeList l;
27:
28: l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
29: l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
30: l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
31:
32: return l;
33: }
34:
35: void EncryptionMode::ValidateState () const
36: {
37: if (!KeySet || Ciphers.size() < 1)
38: throw NotInitialized (SRC_POS);
39: }
40:
41: void EncryptionMode::ValidateParameters (byte *data, uint64 length) const
42: {
43: if ((Ciphers.size() > 0 && (length % Ciphers.front()->GetBlockSize()) != 0))
44: throw ParameterIncorrect (SRC_POS);
45: }
46:
47: void EncryptionMode::ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const
48: {
49: if (sectorCount == 0 || sectorSize == 0 || (sectorSize % EncryptionDataUnitSize) != 0)
50: throw ParameterIncorrect (SRC_POS);
51: }
52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.