VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Core/VolumeCreator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/VolumeCreator.cpp')
-rw-r--r--src/Core/VolumeCreator.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Core/VolumeCreator.cpp b/src/Core/VolumeCreator.cpp
index 5f19a66d..fefbddde 100644
--- a/src/Core/VolumeCreator.cpp
+++ b/src/Core/VolumeCreator.cpp
@@ -1,44 +1,47 @@
/*
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
and all other portions of this file are Copyright (c) 2013-2017 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
#include "Volume/EncryptionTest.h"
#include "Volume/EncryptionModeXTS.h"
+#ifdef WOLFCRYPT_BACKEND
+#include "Volume/EncryptionModeWolfCryptXTS.h"
+#endif
#include "Core.h"
#ifdef TC_UNIX
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include "VolumeCreator.h"
#include "FatFormatter.h"
namespace VeraCrypt
{
VolumeCreator::VolumeCreator ()
: SizeDone (0)
{
}
VolumeCreator::~VolumeCreator ()
{
}
void VolumeCreator::Abort ()
{
AbortRequested = true;
}
void VolumeCreator::CheckResult ()
{
if (ThreadException)
@@ -333,62 +336,67 @@ namespace VeraCrypt
shared_ptr <VolumeHeader> hiddenHeader (hiddenLayout.GetHeader());
SecureBuffer hiddenHeaderBuffer (hiddenLayout.GetHeaderSize());
headerOptions.Type = VolumeType::Hidden;
headerOptions.VolumeDataStart = HostSize - hiddenLayout.GetHeaderSize() * 2 - options->Size;
headerOptions.VolumeDataSize = hiddenLayout.GetMaxDataSize (options->Size);
// Master data key
SecureBuffer hiddenMasterKey(options->EA->GetKeySize() * 2);
RandomNumberGenerator::GetData (hiddenMasterKey);
headerOptions.DataKey = hiddenMasterKey;
// PKCS5 salt
SecureBuffer hiddenSalt (VolumeHeader::GetSaltSize());
RandomNumberGenerator::GetData (hiddenSalt);
headerOptions.Salt = hiddenSalt;
// Header key
SecureBuffer hiddenHeaderKey (VolumeHeader::GetLargestSerializedKeySize());
RandomNumberGenerator::GetData (hiddenHeaderKey);
headerOptions.HeaderKey = hiddenHeaderKey;
hiddenHeader->Create (headerBuffer, headerOptions);
VolumeFile->Write (headerBuffer);
}
// 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;
AbortRequested = false;
mProgressInfo.CreationInProgress = true;
struct ThreadFunctor : public Functor
{
ThreadFunctor (VolumeCreator *creator) : Creator (creator) { }
virtual void operator() ()
{
Creator->CreationThread ();
}
VolumeCreator *Creator;
};
Thread thread;
thread.Start (new ThreadFunctor (this));
}
catch (...)
{
VolumeFile.reset();
throw;
}
}
VolumeCreator::KeyInfo VolumeCreator::GetKeyInfo () const
{
KeyInfo info;