mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
wolfCrypt as crypto backend for VeraCrypt (#1227)
* wolfCrypt as crypto backend for VeraCrypt * Refactor to use EncryptionModeWolfCryptXTS class
This commit is contained in:
@@ -257,7 +257,11 @@ namespace VeraCrypt
|
||||
void RandomNumberGenerator::Test ()
|
||||
{
|
||||
shared_ptr <Hash> origPoolHash = PoolHash;
|
||||
PoolHash.reset (new Blake2s());
|
||||
#ifndef WOLFCRYPT_BACKEND
|
||||
PoolHash.reset (new Blake2s());
|
||||
#else
|
||||
PoolHash.reset (new Sha256());
|
||||
#endif
|
||||
|
||||
Pool.Zero();
|
||||
Buffer buffer (1);
|
||||
@@ -267,15 +271,23 @@ namespace VeraCrypt
|
||||
AddToPool (buffer);
|
||||
}
|
||||
|
||||
#ifndef WOLFCRYPT_BACKEND
|
||||
if (Crc32::ProcessBuffer (Pool) != 0x9c743238)
|
||||
throw TestFailed (SRC_POS);
|
||||
#else
|
||||
if (Crc32::ProcessBuffer (Pool) != 0xac95ac1a)
|
||||
#endif
|
||||
throw TestFailed (SRC_POS);
|
||||
|
||||
buffer.Allocate (PoolSize);
|
||||
buffer.CopyFrom (PeekPool());
|
||||
AddToPool (buffer);
|
||||
|
||||
if (Crc32::ProcessBuffer (Pool) != 0xd2d09c8d)
|
||||
throw TestFailed (SRC_POS);
|
||||
#ifndef WOLFCRYPT_BACKEND
|
||||
if (Crc32::ProcessBuffer (Pool) != 0xd2d09c8d)
|
||||
#else
|
||||
if (Crc32::ProcessBuffer (Pool) != 0xb79f3c12)
|
||||
#endif
|
||||
throw TestFailed (SRC_POS);
|
||||
|
||||
PoolHash = origPoolHash;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include "Platform/SystemInfo.h"
|
||||
#include "Platform/TextReader.h"
|
||||
#include "Volume/EncryptionModeXTS.h"
|
||||
#ifdef WOLFCRYPT_BACKEND
|
||||
#include "Volume/EncryptionModeWolfCryptXTS.h"
|
||||
#endif
|
||||
#include "Driver/Fuse/FuseService.h"
|
||||
#include "Core/Unix/CoreServiceProxy.h"
|
||||
|
||||
@@ -302,8 +305,13 @@ namespace VeraCrypt
|
||||
|
||||
void CoreLinux::MountVolumeNative (shared_ptr <Volume> volume, MountOptions &options, const DirectoryPath &auxMountPoint) const
|
||||
{
|
||||
bool xts = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeXTS));
|
||||
bool algoNotSupported = (typeid (*volume->GetEncryptionAlgorithm()) == typeid (Kuznyechik))
|
||||
bool xts = (typeid (*volume->GetEncryptionMode()) ==
|
||||
#ifdef WOLFCRYPT_BACKEND
|
||||
typeid (EncryptionModeWolfCryptXTS));
|
||||
#else
|
||||
typeid (EncryptionModeXTS));
|
||||
#endif
|
||||
bool algoNotSupported = (typeid (*volume->GetEncryptionAlgorithm()) == typeid (Kuznyechik))
|
||||
|| (typeid (*volume->GetEncryptionAlgorithm()) == typeid (CamelliaKuznyechik))
|
||||
|| (typeid (*volume->GetEncryptionAlgorithm()) == typeid (KuznyechikTwofish))
|
||||
|| (typeid (*volume->GetEncryptionAlgorithm()) == typeid (KuznyechikAES))
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
#include "Volume/EncryptionTest.h"
|
||||
#include "Volume/EncryptionModeXTS.h"
|
||||
#ifdef WOLFCRYPT_BACKEND
|
||||
#include "Volume/EncryptionModeWolfCryptXTS.h"
|
||||
#endif
|
||||
#include "Core.h"
|
||||
|
||||
#ifdef TC_UNIX
|
||||
@@ -360,8 +363,13 @@ namespace VeraCrypt
|
||||
|
||||
// Data area keys
|
||||
options->EA->SetKey (MasterKey.GetRange (0, options->EA->GetKeySize()));
|
||||
shared_ptr <EncryptionMode> mode (new EncryptionModeXTS ());
|
||||
mode->SetKey (MasterKey.GetRange (options->EA->GetKeySize(), options->EA->GetKeySize()));
|
||||
#ifdef WOLFCRYPT_BACKEND
|
||||
shared_ptr <EncryptionMode> mode (new EncryptionModeWolfCryptXTS ());
|
||||
options->EA->SetKeyXTS (MasterKey.GetRange (options->EA->GetKeySize(), options->EA->GetKeySize()));
|
||||
#else
|
||||
shared_ptr <EncryptionMode> mode (new EncryptionModeXTS ());
|
||||
#endif
|
||||
mode->SetKey (MasterKey.GetRange (options->EA->GetKeySize(), options->EA->GetKeySize()));
|
||||
options->EA->SetMode (mode);
|
||||
|
||||
Options = options;
|
||||
|
||||
Reference in New Issue
Block a user