VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Core
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-08-09 00:54:18 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-08-15 01:09:06 +0200
commitf32f65d4f780f150f461ebd3cdc241f8711995eb (patch)
treef472f76c59e6b6743458ab7614a1d70dff51ac7c /src/Core
parent5b381ce7d7ec45e02765b4a180f9aa1ee8aeee40 (diff)
downloadVeraCrypt-f32f65d4f780f150f461ebd3cdc241f8711995eb.tar.gz
VeraCrypt-f32f65d4f780f150f461ebd3cdc241f8711995eb.zip
Linux/MacOSX: Similar fix to Windows one. Write fake hidden volume header that is created from same data format as legitimate one in order to metigate attack that are able to detect the presence of TrueCrypt/VeraCrypt hidden volumes (reported by Ivanov Alexey Mikhailovich from Moscow, Russia)
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/VolumeCreator.cpp63
1 files changed, 57 insertions, 6 deletions
diff --git a/src/Core/VolumeCreator.cpp b/src/Core/VolumeCreator.cpp
index 94aba4bc..403e0c67 100644
--- a/src/Core/VolumeCreator.cpp
+++ b/src/Core/VolumeCreator.cpp
@@ -151,9 +151,37 @@ namespace VeraCrypt
if (Options->Type == VolumeType::Normal)
{
- // Write random data to space reserved for hidden volume backup header
- Core->RandomizeEncryptionAlgorithmKey (Options->EA);
- Options->EA->Encrypt (backupHeader);
+ // Write fake random header to space reserved for hidden volume header
+ VolumeLayoutV2Hidden hiddenLayout;
+ shared_ptr <VolumeHeader> hiddenHeader (hiddenLayout.GetHeader());
+ SecureBuffer hiddenHeaderBuffer (hiddenLayout.GetHeaderSize());
+
+ VolumeHeaderCreationOptions headerOptions;
+ headerOptions.EA = Options->EA;
+ headerOptions.Kdf = Options->VolumeHeaderKdf;
+ headerOptions.Type = VolumeType::Hidden;
+
+ headerOptions.SectorSize = Options->SectorSize;
+
+ 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 (backupHeader, headerOptions);
VolumeFile->Write (backupHeader);
}
@@ -295,9 +323,32 @@ namespace VeraCrypt
if (options->Type == VolumeType::Normal)
{
- // Write random data to space reserved for hidden volume header
- Core->RandomizeEncryptionAlgorithmKey (options->EA);
- options->EA->Encrypt (headerBuffer);
+ // Write fake random header to space reserved for hidden volume header
+ VolumeLayoutV2Hidden hiddenLayout;
+ 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);
}