diff options
Diffstat (limited to 'src/Volume/EncryptionAlgorithm.cpp')
-rw-r--r-- | src/Volume/EncryptionAlgorithm.cpp | 89 |
1 files changed, 78 insertions, 11 deletions
diff --git a/src/Volume/EncryptionAlgorithm.cpp b/src/Volume/EncryptionAlgorithm.cpp index e36b500c..0178da00 100644 --- a/src/Volume/EncryptionAlgorithm.cpp +++ b/src/Volume/EncryptionAlgorithm.cpp @@ -12,6 +12,9 @@ #include "EncryptionAlgorithm.h" #include "EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "EncryptionModeWolfCryptXTS.h" +#endif namespace VeraCrypt { @@ -62,17 +65,22 @@ namespace VeraCrypt EncryptionAlgorithmList l; l.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); + #ifndef WOLFCRYPT_BACKEND l.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Camellia ())); - l.push_back (shared_ptr <EncryptionAlgorithm> (new GOST89 ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Kuznyechik ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); + l.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaKuznyechik ())); + l.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaSerpent ())); + l.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikAES ())); + l.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikSerpentCamellia ())); + l.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikTwofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - + #endif return l; } @@ -211,7 +219,25 @@ namespace VeraCrypt } } - void EncryptionAlgorithm::ValidateState () const + #ifdef WOLFCRYPT_BACKEND + void EncryptionAlgorithm::SetKeyXTS (const ConstBufferPtr &key) + { + if (Ciphers.size() < 1) + throw NotInitialized (SRC_POS); + + if (GetKeySize() != key.Size()) + throw ParameterIncorrect (SRC_POS); + + size_t keyOffset = 0; + foreach_ref (Cipher &c, Ciphers) + { + c.SetKeyXTS (key.GetRange (keyOffset, c.GetKeySize())); + keyOffset += c.GetKeySize(); + } + } + #endif + + void EncryptionAlgorithm::ValidateState () const { if (Ciphers.size() < 1 || Mode.get() == nullptr) throw NotInitialized (SRC_POS); @@ -222,9 +248,14 @@ namespace VeraCrypt { Ciphers.push_back (shared_ptr <Cipher> (new CipherAES())); + #ifdef WOLFCRYPT_BACKEND + SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #else SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - } + #endif + } +#ifndef WOLFCRYPT_BACKEND // AES-Twofish AESTwofish::AESTwofish () { @@ -296,22 +327,58 @@ namespace VeraCrypt SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } + // Kuznyechik + Kuznyechik::Kuznyechik () + { + Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik())); + + SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + } + + // Kuznyechik-Twofish + KuznyechikTwofish::KuznyechikTwofish () + { + Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); + + SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + } - // GOST89 - GOST89::GOST89 () + // Kuznyechik-AES + KuznyechikAES::KuznyechikAES () { - Deprecated = true; + Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); - Ciphers.push_back (shared_ptr <Cipher> (new CipherGost89())); + SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + } + + // Kuznyechik-Serpent-Camellia + KuznyechikSerpentCamellia::KuznyechikSerpentCamellia () + { + Ciphers.push_back (shared_ptr <Cipher> (new CipherCamellia ())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } + + // Camellia-Kuznyechik + CamelliaKuznyechik::CamelliaKuznyechik () + { + Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherCamellia ())); - // Kuznyechik - Kuznyechik::Kuznyechik () + SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + } + + // Camellia-Serpent + CamelliaSerpent::CamelliaSerpent () { - Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); + Ciphers.push_back (shared_ptr <Cipher> (new CipherCamellia ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } +#endif } |