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.

This commit is contained in:
Mounir IDRASSI
2014-12-30 17:01:49 +01:00
parent 8d787dcd71
commit c178e325b8
39 changed files with 540 additions and 172 deletions

View File

@@ -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);