From 7df9724e20005ccdd3e5daaeebf80eb0c5c46083 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Tue, 27 Mar 2018 13:07:13 +0200 Subject: Crypto: Add support for 5 new cascades of cipher algorithms (Camellia-Kuznyechik, Camellia-Serpent, Kuznyechik-AES, Kuznyechik-Serpent-Camellia and Kuznyechik-Twofish) --- src/Volume/EncryptionAlgorithm.cpp | 51 ++++++++++++ src/Volume/EncryptionAlgorithm.h | 5 ++ src/Volume/EncryptionTest.cpp | 162 ++++++++++++++++++++++++++++++++++++- src/Volume/VolumeLayout.cpp | 17 +++- 4 files changed, 233 insertions(+), 2 deletions(-) (limited to 'src/Volume') diff --git a/src/Volume/EncryptionAlgorithm.cpp b/src/Volume/EncryptionAlgorithm.cpp index e36b500c..b94f69fa 100644 --- a/src/Volume/EncryptionAlgorithm.cpp +++ b/src/Volume/EncryptionAlgorithm.cpp @@ -69,6 +69,11 @@ namespace VeraCrypt l.push_back (shared_ptr (new Kuznyechik ())); l.push_back (shared_ptr (new AESTwofish ())); l.push_back (shared_ptr (new AESTwofishSerpent ())); + l.push_back (shared_ptr (new CamelliaKuznyechik ())); + l.push_back (shared_ptr (new CamelliaSerpent ())); + l.push_back (shared_ptr (new KuznyechikAES ())); + l.push_back (shared_ptr (new KuznyechikSerpentCamellia ())); + l.push_back (shared_ptr (new KuznyechikTwofish ())); l.push_back (shared_ptr (new SerpentAES ())); l.push_back (shared_ptr (new SerpentTwofishAES ())); l.push_back (shared_ptr (new TwofishSerpent ())); @@ -314,4 +319,50 @@ namespace VeraCrypt SupportedModes.push_back (shared_ptr (new EncryptionModeXTS ())); } + + // Kuznyechik-Twofish + KuznyechikTwofish::KuznyechikTwofish () + { + Ciphers.push_back (shared_ptr (new CipherTwofish ())); + Ciphers.push_back (shared_ptr (new CipherKuznyechik ())); + + SupportedModes.push_back (shared_ptr (new EncryptionModeXTS ())); + } + + // Kuznyechik-AES + KuznyechikAES::KuznyechikAES () + { + Ciphers.push_back (shared_ptr (new CipherAES ())); + Ciphers.push_back (shared_ptr (new CipherKuznyechik ())); + + SupportedModes.push_back (shared_ptr (new EncryptionModeXTS ())); + } + + // Kuznyechik-Serpent-Camellia + KuznyechikSerpentCamellia::KuznyechikSerpentCamellia () + { + Ciphers.push_back (shared_ptr (new CipherCamellia ())); + Ciphers.push_back (shared_ptr (new CipherSerpent ())); + Ciphers.push_back (shared_ptr (new CipherKuznyechik ())); + + SupportedModes.push_back (shared_ptr (new EncryptionModeXTS ())); + } + + // Camellia-Kuznyechik + CamelliaKuznyechik::CamelliaKuznyechik () + { + Ciphers.push_back (shared_ptr (new CipherKuznyechik ())); + Ciphers.push_back (shared_ptr (new CipherCamellia ())); + + SupportedModes.push_back (shared_ptr (new EncryptionModeXTS ())); + } + + // Camellia-Serpent + CamelliaSerpent::CamelliaSerpent () + { + Ciphers.push_back (shared_ptr (new CipherSerpent ())); + Ciphers.push_back (shared_ptr (new CipherCamellia ())); + + SupportedModes.push_back (shared_ptr (new EncryptionModeXTS ())); + } } diff --git a/src/Volume/EncryptionAlgorithm.h b/src/Volume/EncryptionAlgorithm.h index c2d7acbd..a701e700 100644 --- a/src/Volume/EncryptionAlgorithm.h +++ b/src/Volume/EncryptionAlgorithm.h @@ -88,6 +88,11 @@ namespace VeraCrypt TC_ENCRYPTION_ALGORITHM (Camellia); TC_ENCRYPTION_ALGORITHM (GOST89); TC_ENCRYPTION_ALGORITHM (Kuznyechik); + TC_ENCRYPTION_ALGORITHM (KuznyechikTwofish); + TC_ENCRYPTION_ALGORITHM (KuznyechikAES); + TC_ENCRYPTION_ALGORITHM (KuznyechikSerpentCamellia); + TC_ENCRYPTION_ALGORITHM (CamelliaKuznyechik); + TC_ENCRYPTION_ALGORITHM (CamelliaSerpent); #undef TC_ENCRYPTION_ALGORITHM } diff --git a/src/Volume/EncryptionTest.cpp b/src/Volume/EncryptionTest.cpp index 23d04ea1..22aea220 100644 --- a/src/Volume/EncryptionTest.cpp +++ b/src/Volume/EncryptionTest.cpp @@ -835,6 +835,136 @@ namespace VeraCrypt break; } } + else if (typeid (ea) == typeid (CamelliaKuznyechik)) + { + switch (testCase) + { + case 0: + if (crc != 0x4ea34e89) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 1: + if (crc != 0xb3ad8559) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 2: + if (crc != 0xde361313) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 3: + if (crc != 0x519d2bf9) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + } + } + else if (typeid (ea) == typeid (KuznyechikTwofish)) + { + switch (testCase) + { + case 0: + if (crc != 0x748f8631) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 1: + if (crc != 0x8a4b0888) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 2: + if (crc != 0xe0310188) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 3: + if (crc != 0xfc2b6b45) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + } + } + else if (typeid (ea) == typeid (CamelliaSerpent)) + { + switch (testCase) + { + case 0: + if (crc != 0x10569a42) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 1: + if (crc != 0x4de95152) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 2: + if (crc != 0xe17b5fe7) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 3: + if (crc != 0xdbf993fa) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + } + } + else if (typeid (ea) == typeid (KuznyechikAES)) + { + switch (testCase) + { + case 0: + if (crc != 0xc479f95d) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 1: + if (crc != 0x58eaf88d) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 2: + if (crc != 0xbe300cc2) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 3: + if (crc != 0x9b681c2e) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + } + } + else if (typeid (ea) == typeid (KuznyechikSerpentCamellia)) + { + switch (testCase) + { + case 0: + if (crc != 0x9d8ac7ee) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 1: + if (crc != 0x5d7d347f) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 2: + if (crc != 0x884b62ee) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + case 3: + if (crc != 0x5c6c3997) + throw TestFailed (SRC_POS); + nTestsPerformed++; + break; + } + } if (crc == 0x9f5edd58) throw TestFailed (SRC_POS); @@ -949,6 +1079,36 @@ namespace VeraCrypt throw TestFailed (SRC_POS); nTestsPerformed++; } + else if (typeid (ea) == typeid (CamelliaKuznyechik)) + { + if (crc != 0xe69d680d) + throw TestFailed (SRC_POS); + nTestsPerformed++; + } + else if (typeid (ea) == typeid (KuznyechikTwofish)) + { + if (crc != 0xe0aef0d1) + throw TestFailed (SRC_POS); + nTestsPerformed++; + } + else if (typeid (ea) == typeid (CamelliaSerpent)) + { + if (crc != 0x58aad727) + throw TestFailed (SRC_POS); + nTestsPerformed++; + } + else if (typeid (ea) == typeid (KuznyechikAES)) + { + if (crc != 0x4641234a) + throw TestFailed (SRC_POS); + nTestsPerformed++; + } + else if (typeid (ea) == typeid (KuznyechikSerpentCamellia)) + { + if (crc != 0x755dad72) + throw TestFailed (SRC_POS); + nTestsPerformed++; + } if (crc == 0x9f5edd58) throw TestFailed (SRC_POS); @@ -961,7 +1121,7 @@ namespace VeraCrypt nTestsPerformed++; } - if (nTestsPerformed != 110) + if (nTestsPerformed != 160) throw TestFailed (SRC_POS); } diff --git a/src/Volume/VolumeLayout.cpp b/src/Volume/VolumeLayout.cpp index 701bca84..0eaed427 100644 --- a/src/Volume/VolumeLayout.cpp +++ b/src/Volume/VolumeLayout.cpp @@ -104,6 +104,11 @@ namespace VeraCrypt SupportedEncryptionAlgorithms.push_back (shared_ptr (new Kuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofishSerpent ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new CamelliaKuznyechik ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new CamelliaSerpent ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikAES ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikSerpentCamellia ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new TwofishSerpent ())); @@ -145,6 +150,11 @@ namespace VeraCrypt SupportedEncryptionAlgorithms.push_back (shared_ptr (new Kuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofishSerpent ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new CamelliaKuznyechik ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new CamelliaSerpent ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikAES ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikSerpentCamellia ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new TwofishSerpent ())); @@ -193,10 +203,15 @@ namespace VeraCrypt SupportedEncryptionAlgorithms.push_back (shared_ptr (new Kuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofishSerpent ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new CamelliaKuznyechik ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new CamelliaSerpent ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikAES ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikSerpentCamellia ())); + SupportedEncryptionAlgorithms.push_back (shared_ptr (new KuznyechikTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new TwofishSerpent ())); - + SupportedEncryptionModes.push_back (shared_ptr (new EncryptionModeXTS ())); } -- cgit v1.2.3