diff options
Diffstat (limited to 'src/Volume/EncryptionTest.cpp')
-rw-r--r-- | src/Volume/EncryptionTest.cpp | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/Volume/EncryptionTest.cpp b/src/Volume/EncryptionTest.cpp index 71f55f07..ffe998b0 100644 --- a/src/Volume/EncryptionTest.cpp +++ b/src/Volume/EncryptionTest.cpp | |||
@@ -11,8 +11,6 @@ | |||
11 | #include "Crc32.h" | 11 | #include "Crc32.h" |
12 | #include "EncryptionAlgorithm.h" | 12 | #include "EncryptionAlgorithm.h" |
13 | #include "EncryptionMode.h" | 13 | #include "EncryptionMode.h" |
14 | #include "EncryptionModeCBC.h" | ||
15 | #include "EncryptionModeLRW.h" | ||
16 | #include "EncryptionModeXTS.h" | 14 | #include "EncryptionModeXTS.h" |
17 | #include "EncryptionTest.h" | 15 | #include "EncryptionTest.h" |
18 | #include "Pkcs5Kdf.h" | 16 | #include "Pkcs5Kdf.h" |
@@ -35,83 +33,9 @@ namespace VeraCrypt | |||
35 | TestCiphers(); | 33 | TestCiphers(); |
36 | TestXtsAES(); | 34 | TestXtsAES(); |
37 | TestXts(); | 35 | TestXts(); |
38 | TestLegacyModes(); | ||
39 | TestPkcs5(); | 36 | TestPkcs5(); |
40 | } | 37 | } |
41 | 38 | ||
42 | void EncryptionTest::TestLegacyModes () | ||
43 | { | ||
44 | byte buf[ENCRYPTION_DATA_UNIT_SIZE * 2]; | ||
45 | byte iv[32]; | ||
46 | unsigned int i; | ||
47 | uint32 crc; | ||
48 | uint64 secNo = 0x0234567890ABCDEFull; | ||
49 | |||
50 | for (i = 0; i < sizeof (buf); i++) | ||
51 | buf[i] = (byte) i; | ||
52 | |||
53 | for (i = 0; i < sizeof (iv); i++) | ||
54 | iv[i] = (byte) i; | ||
55 | |||
56 | EncryptionModeList encModes = EncryptionMode::GetAvailableModes (); | ||
57 | |||
58 | foreach_ref (EncryptionAlgorithm &ea, EncryptionAlgorithm::GetAvailableAlgorithms()) | ||
59 | { | ||
60 | foreach (shared_ptr <EncryptionMode> mode, encModes) | ||
61 | { | ||
62 | if (typeid (*mode) == typeid (EncryptionModeXTS)) | ||
63 | continue; | ||
64 | |||
65 | if (!mode->IsKeySet()) | ||
66 | { | ||
67 | mode->SetKey (ConstBufferPtr (iv, mode->GetKeySize())); | ||
68 | mode->SetSectorOffset (1); | ||
69 | } | ||
70 | |||
71 | if (ea.IsModeSupported (mode)) | ||
72 | { | ||
73 | ea.SetMode (mode); | ||
74 | ea.SetKey (ConstBufferPtr (buf, ea.GetKeySize())); | ||
75 | |||
76 | ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); | ||
77 | ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); | ||
78 | ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); | ||
79 | |||
80 | crc = ::GetCrc32 (buf, sizeof (buf)); | ||
81 | |||
82 | if (typeid (*mode) == typeid (EncryptionModeLRW)) | ||
83 | { | ||
84 | if (typeid (ea) == typeid (AES) && crc != 0x5237acf9) throw TestFailed (SRC_POS); | ||
85 | if (typeid (ea) == typeid (AESTwofish) && crc != 0x4ed0fd80) throw TestFailed (SRC_POS); | ||
86 | if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0xea04b3cf) throw TestFailed (SRC_POS); | ||
87 | if (typeid (ea) == typeid (Blowfish) && crc != 0xf94d5300) throw TestFailed (SRC_POS); | ||
88 | if (typeid (ea) == typeid (Cast5) && crc != 0x33971e82) throw TestFailed (SRC_POS); | ||
89 | if (typeid (ea) == typeid (Serpent) && crc != 0x7fb86805) throw TestFailed (SRC_POS); | ||
90 | if (typeid (ea) == typeid (TripleDES) && crc != 0x2b20bb84) throw TestFailed (SRC_POS); | ||
91 | if (typeid (ea) == typeid (Twofish) && crc != 0xa9de0f0b) throw TestFailed (SRC_POS); | ||
92 | if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xca65c5cd) throw TestFailed (SRC_POS); | ||
93 | } | ||
94 | |||
95 | if (typeid (*mode) == typeid (EncryptionModeCBC)) | ||
96 | { | ||
97 | if (typeid (ea) == typeid (AES) && crc != 0x2274f53d) throw TestFailed (SRC_POS); | ||
98 | if (typeid (ea) == typeid (AESBlowfish) && crc != 0xa7a80c84) throw TestFailed (SRC_POS); | ||
99 | if (typeid (ea) == typeid (AESBlowfishSerpent) && crc != 0xa0584562) throw TestFailed (SRC_POS); | ||
100 | if (typeid (ea) == typeid (AESTwofish) && crc != 0x3c226444) throw TestFailed (SRC_POS); | ||
101 | if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0x5e5e77fd) throw TestFailed (SRC_POS); | ||
102 | if (typeid (ea) == typeid (Blowfish) && crc != 0x033899a1) throw TestFailed (SRC_POS); | ||
103 | if (typeid (ea) == typeid (Cast5) && crc != 0x331cecc7) throw TestFailed (SRC_POS); | ||
104 | if (typeid (ea) == typeid (Serpent) && crc != 0x42dff3d4) throw TestFailed (SRC_POS); | ||
105 | if (typeid (ea) == typeid (TripleDES) && crc != 0xfe497d0c) throw TestFailed (SRC_POS); | ||
106 | if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xa7b659f3) throw TestFailed (SRC_POS); | ||
107 | } | ||
108 | |||
109 | ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | |||
115 | 39 | ||
116 | struct CipherTestVector | 40 | struct CipherTestVector |
117 | { | 41 | { |
@@ -872,11 +796,6 @@ namespace VeraCrypt | |||
872 | if (memcmp (derivedKey.Ptr(), "\x7a\x3d\x7c\x03", 4) != 0) | 796 | if (memcmp (derivedKey.Ptr(), "\x7a\x3d\x7c\x03", 4) != 0) |
873 | throw TestFailed (SRC_POS); | 797 | throw TestFailed (SRC_POS); |
874 | 798 | ||
875 | Pkcs5HmacSha1 pkcs5HmacSha1; | ||
876 | pkcs5HmacSha1.DeriveKey (derivedKey, password, salt, 5, FALSE); | ||
877 | if (memcmp (derivedKey.Ptr(), "\x5c\x75\xce\xf0", 4) != 0) | ||
878 | throw TestFailed (SRC_POS); | ||
879 | |||
880 | Pkcs5HmacSha512 pkcs5HmacSha512; | 799 | Pkcs5HmacSha512 pkcs5HmacSha512; |
881 | pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5, FALSE); | 800 | pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5, FALSE); |
882 | if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0) | 801 | if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0) |