VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/VolumeHeader.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-30 16:01:49 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-30 16:06:20 (GMT)
commitc178e325b807258199ae45b2c50c265b4d7ce7af (patch)
tree905297a12e86b71d4611ff13d1df7e99c1e20b61 /src/Volume/VolumeHeader.cpp
parent8d787dcd7128fce554f473da62e20162b0b6c9c4 (diff)
downloadVeraCrypt-c178e325b807258199ae45b2c50c265b4d7ce7af.zip
VeraCrypt-c178e325b807258199ae45b2c50c265b4d7ce7af.tar.gz
Linux/MacOSX: Implement TrueCrypt conversion and loading support. Correct many GTK issues linked to multi-threaded origine of events by implementing an automatic mechanism for handling such requests in the main thread.
Diffstat (limited to 'src/Volume/VolumeHeader.cpp')
-rwxr-xr-xsrc/Volume/VolumeHeader.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/Volume/VolumeHeader.cpp b/src/Volume/VolumeHeader.cpp
index fbdece5..dea3b1e 100755
--- a/src/Volume/VolumeHeader.cpp
+++ b/src/Volume/VolumeHeader.cpp
@@ -78,7 +78,7 @@ namespace VeraCrypt
EncryptNew (headerBuffer, options.Salt, options.HeaderKey, options.Kdf);
}
- bool VolumeHeader::Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, shared_ptr <Pkcs5Kdf> kdf, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
+ bool VolumeHeader::Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
{
if (password.Size() < 1)
throw PasswordEmpty (SRC_POS);
@@ -121,7 +121,7 @@ namespace VeraCrypt
header.CopyFrom (encryptedData.GetRange (EncryptedHeaderDataOffset, EncryptedHeaderDataSize));
ea->Decrypt (header);
- if (Deserialize (header, ea, mode))
+ if (Deserialize (header, ea, mode, truecryptMode))
{
EA = ea;
Pkcs5 = pkcs5;
@@ -134,15 +134,21 @@ namespace VeraCrypt
return false;
}
- bool VolumeHeader::Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode)
+ bool VolumeHeader::Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode, bool truecryptMode)
{
if (header.Size() != EncryptedHeaderDataSize)
throw ParameterIncorrect (SRC_POS);
- if (header[0] != 'V' ||
+ if (truecryptMode && (header[0] != 'T' ||
+ header[1] != 'R' ||
+ header[2] != 'U' ||
+ header[3] != 'E'))
+ return false;
+
+ if (!truecryptMode && (header[0] != 'V' ||
header[1] != 'E' ||
header[2] != 'R' ||
- header[3] != 'A')
+ header[3] != 'A'))
return false;
size_t offset = 4;
@@ -163,9 +169,16 @@ namespace VeraCrypt
RequiredMinProgramVersion = DeserializeEntry <uint16> (header, offset);
- if (RequiredMinProgramVersion > Version::Number())
+ if (!truecryptMode && (RequiredMinProgramVersion > Version::Number()))
throw HigherVersionRequired (SRC_POS);
+ if (truecryptMode)
+ {
+ if (RequiredMinProgramVersion < 0x700 || RequiredMinProgramVersion > 0x71a)
+ throw UnsupportedTrueCryptFormat (SRC_POS);
+ RequiredMinProgramVersion = CurrentRequiredMinProgramVersion;
+ }
+
VolumeKeyAreaCrc32 = DeserializeEntry <uint32> (header, offset);
VolumeCreationTime = DeserializeEntry <uint64> (header, offset);
HeaderCreationTime = DeserializeEntry <uint64> (header, offset);