mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-12 11:28:26 -06:00
Linux/macOS: Remove TrueCrypt support
This commit is contained in:
@@ -1086,12 +1086,12 @@ namespace VeraCrypt
|
||||
if (memcmp (derivedKey.Ptr(), "\x8d\x51\xfa\x31", 4) != 0)
|
||||
throw TestFailed (SRC_POS);
|
||||
|
||||
Pkcs5HmacSha512 pkcs5HmacSha512(false);
|
||||
Pkcs5HmacSha512 pkcs5HmacSha512;
|
||||
pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5);
|
||||
if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0)
|
||||
throw TestFailed (SRC_POS);
|
||||
|
||||
Pkcs5HmacWhirlpool pkcs5HmacWhirlpool(false);
|
||||
Pkcs5HmacWhirlpool pkcs5HmacWhirlpool;
|
||||
pkcs5HmacWhirlpool.DeriveKey (derivedKey, password, salt, 5);
|
||||
if (memcmp (derivedKey.Ptr(), "\x50\x7c\x36\x6f", 4) != 0)
|
||||
throw TestFailed (SRC_POS);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
Pkcs5Kdf::Pkcs5Kdf (bool truecryptMode) : m_truecryptMode(truecryptMode)
|
||||
Pkcs5Kdf::Pkcs5Kdf ()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace VeraCrypt
|
||||
DeriveKey (key, password, salt, GetIterationCount(pim));
|
||||
}
|
||||
|
||||
shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const wstring &name, bool truecryptMode)
|
||||
shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const wstring &name)
|
||||
{
|
||||
foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms(truecryptMode))
|
||||
foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms())
|
||||
{
|
||||
if (kdf->GetName() == name)
|
||||
return kdf;
|
||||
@@ -39,9 +39,9 @@ namespace VeraCrypt
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
}
|
||||
|
||||
shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const Hash &hash, bool truecryptMode)
|
||||
shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const Hash &hash)
|
||||
{
|
||||
foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms(truecryptMode))
|
||||
foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms())
|
||||
{
|
||||
if (typeid (*kdf->GetHash()) == typeid (hash))
|
||||
return kdf;
|
||||
@@ -50,23 +50,15 @@ namespace VeraCrypt
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
}
|
||||
|
||||
Pkcs5KdfList Pkcs5Kdf::GetAvailableAlgorithms (bool truecryptMode)
|
||||
Pkcs5KdfList Pkcs5Kdf::GetAvailableAlgorithms ()
|
||||
{
|
||||
Pkcs5KdfList l;
|
||||
|
||||
if (truecryptMode)
|
||||
{
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 (true)));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool (true)));
|
||||
}
|
||||
else
|
||||
{
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 (false)));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha256 ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool (false)));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacStreebog ()));
|
||||
}
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha256 ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacStreebog ()));
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -29,20 +29,17 @@ namespace VeraCrypt
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, int pim, const ConstBufferPtr &salt) const;
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const = 0;
|
||||
static shared_ptr <Pkcs5Kdf> GetAlgorithm (const wstring &name, bool truecryptMode);
|
||||
static shared_ptr <Pkcs5Kdf> GetAlgorithm (const Hash &hash, bool truecryptMode);
|
||||
static Pkcs5KdfList GetAvailableAlgorithms (bool truecryptMode);
|
||||
static shared_ptr <Pkcs5Kdf> GetAlgorithm (const wstring &name);
|
||||
static shared_ptr <Pkcs5Kdf> GetAlgorithm (const Hash &hash);
|
||||
static Pkcs5KdfList GetAvailableAlgorithms ();
|
||||
virtual shared_ptr <Hash> GetHash () const = 0;
|
||||
virtual int GetIterationCount (int pim) const = 0;
|
||||
virtual wstring GetName () const = 0;
|
||||
virtual Pkcs5Kdf* Clone () const = 0;
|
||||
virtual bool IsDeprecated () const { return GetHash()->IsDeprecated(); }
|
||||
bool GetTrueCryptMode () const { return m_truecryptMode;}
|
||||
void SetTrueCryptMode (bool truecryptMode) { m_truecryptMode = truecryptMode;}
|
||||
|
||||
protected:
|
||||
bool m_truecryptMode;
|
||||
Pkcs5Kdf (bool truecryptMode);
|
||||
Pkcs5Kdf ();
|
||||
|
||||
void ValidateParameters (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
|
||||
@@ -54,7 +51,7 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacBlake2s_Boot : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacBlake2s_Boot () : Pkcs5Kdf(false) { }
|
||||
Pkcs5HmacBlake2s_Boot () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacBlake2s_Boot () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
@@ -71,7 +68,7 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacBlake2s : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacBlake2s () : Pkcs5Kdf(false) { }
|
||||
Pkcs5HmacBlake2s () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacBlake2s () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
@@ -88,7 +85,7 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacSha256_Boot : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacSha256_Boot () : Pkcs5Kdf(false) { }
|
||||
Pkcs5HmacSha256_Boot () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacSha256_Boot () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
@@ -105,7 +102,7 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacSha256 : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacSha256 () : Pkcs5Kdf(false) { }
|
||||
Pkcs5HmacSha256 () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacSha256 () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
@@ -122,14 +119,14 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacSha512 : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacSha512 (bool truecryptMode) : Pkcs5Kdf(truecryptMode) { }
|
||||
Pkcs5HmacSha512 () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacSha512 () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha512); }
|
||||
virtual int GetIterationCount (int pim) const { return m_truecryptMode? 1000 : (pim <= 0 ? 500000 : (15000 + (pim * 1000))); }
|
||||
virtual int GetIterationCount (int pim) const { return (pim <= 0 ? 500000 : (15000 + (pim * 1000))); }
|
||||
virtual wstring GetName () const { return L"HMAC-SHA-512"; }
|
||||
virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha512(m_truecryptMode); }
|
||||
virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha512(); }
|
||||
|
||||
private:
|
||||
Pkcs5HmacSha512 (const Pkcs5HmacSha512 &);
|
||||
@@ -139,14 +136,14 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacWhirlpool : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacWhirlpool (bool truecryptMode) : Pkcs5Kdf(truecryptMode) { }
|
||||
Pkcs5HmacWhirlpool () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacWhirlpool () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Whirlpool); }
|
||||
virtual int GetIterationCount (int pim) const { return m_truecryptMode? 1000 : (pim <= 0 ? 500000 : (15000 + (pim * 1000))); }
|
||||
virtual int GetIterationCount (int pim) const { return (pim <= 0 ? 500000 : (15000 + (pim * 1000))); }
|
||||
virtual wstring GetName () const { return L"HMAC-Whirlpool"; }
|
||||
virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacWhirlpool(m_truecryptMode); }
|
||||
virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacWhirlpool(); }
|
||||
|
||||
private:
|
||||
Pkcs5HmacWhirlpool (const Pkcs5HmacWhirlpool &);
|
||||
@@ -156,7 +153,7 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacStreebog : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacStreebog () : Pkcs5Kdf(false) { }
|
||||
Pkcs5HmacStreebog () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacStreebog () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
@@ -173,7 +170,7 @@ namespace VeraCrypt
|
||||
class Pkcs5HmacStreebog_Boot : public Pkcs5Kdf
|
||||
{
|
||||
public:
|
||||
Pkcs5HmacStreebog_Boot () : Pkcs5Kdf(false) { }
|
||||
Pkcs5HmacStreebog_Boot () : Pkcs5Kdf() { }
|
||||
virtual ~Pkcs5HmacStreebog_Boot () { }
|
||||
|
||||
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace VeraCrypt
|
||||
TopWriteOffset (0),
|
||||
TotalDataRead (0),
|
||||
TotalDataWritten (0),
|
||||
TrueCryptMode (false),
|
||||
Pim (0),
|
||||
EncryptionNotCompleted (false)
|
||||
{
|
||||
@@ -71,7 +70,7 @@ namespace VeraCrypt
|
||||
return EA->GetMode();
|
||||
}
|
||||
|
||||
void Volume::Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, int protectionPim, shared_ptr <Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
|
||||
void Volume::Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, int protectionPim, shared_ptr <Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
|
||||
{
|
||||
make_shared_auto (File, file);
|
||||
|
||||
@@ -102,18 +101,14 @@ namespace VeraCrypt
|
||||
throw;
|
||||
}
|
||||
|
||||
return Open (file, password, pim, kdf, truecryptMode, keyfiles, emvSupportEnabled, protection, protectionPassword, protectionPim, protectionKdf,protectionKeyfiles, volumeType, useBackupHeaders, partitionInSystemEncryptionScope);
|
||||
return Open (file, password, pim, kdf, keyfiles, emvSupportEnabled, protection, protectionPassword, protectionPim, protectionKdf,protectionKeyfiles, volumeType, useBackupHeaders, partitionInSystemEncryptionScope);
|
||||
}
|
||||
|
||||
void Volume::Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, int protectionPim, shared_ptr <Pkcs5Kdf> protectionKdf,shared_ptr <KeyfileList> protectionKeyfiles, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
|
||||
void Volume::Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, int protectionPim, shared_ptr <Pkcs5Kdf> protectionKdf,shared_ptr <KeyfileList> protectionKeyfiles, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
|
||||
{
|
||||
if (!volumeFile)
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
|
||||
// TrueCrypt doesn't support SHA-256 and Streebog
|
||||
if (kdf && truecryptMode && (kdf->GetName() == L"HMAC-SHA-256" || kdf->GetName() == L"HMAC-Streebog"))
|
||||
throw UnsupportedAlgoInTrueCryptMode (SRC_POS);
|
||||
|
||||
Protection = protection;
|
||||
VolumeFile = volumeFile;
|
||||
SystemEncryption = partitionInSystemEncryptionScope;
|
||||
@@ -190,11 +185,11 @@ namespace VeraCrypt
|
||||
|
||||
shared_ptr <VolumeHeader> header = layout->GetHeader();
|
||||
|
||||
if (header->Decrypt (headerBuffer, *passwordKey, pim, kdf, truecryptMode, layout->GetSupportedKeyDerivationFunctions(truecryptMode), layoutEncryptionAlgorithms, layoutEncryptionModes))
|
||||
if (header->Decrypt (headerBuffer, *passwordKey, pim, kdf, layout->GetSupportedKeyDerivationFunctions(), layoutEncryptionAlgorithms, layoutEncryptionModes))
|
||||
{
|
||||
// Header decrypted
|
||||
|
||||
if (!truecryptMode && typeid (*layout) == typeid (VolumeLayoutV2Normal) && header->GetRequiredMinProgramVersion() < 0x10b)
|
||||
if (typeid (*layout) == typeid (VolumeLayoutV2Normal) && header->GetRequiredMinProgramVersion() < 0x10b)
|
||||
{
|
||||
// VolumeLayoutV1Normal has been opened as VolumeLayoutV2Normal
|
||||
layout.reset (new VolumeLayoutV1Normal);
|
||||
@@ -202,7 +197,6 @@ namespace VeraCrypt
|
||||
layout->SetHeader (header);
|
||||
}
|
||||
|
||||
TrueCryptMode = truecryptMode;
|
||||
Pim = pim;
|
||||
Type = layout->GetType();
|
||||
SectorSize = header->GetSectorSize();
|
||||
@@ -248,7 +242,7 @@ namespace VeraCrypt
|
||||
Volume protectedVolume;
|
||||
|
||||
protectedVolume.Open (VolumeFile,
|
||||
protectionPassword, protectionPim, protectionKdf, truecryptMode, protectionKeyfiles,
|
||||
protectionPassword, protectionPim, protectionKdf, protectionKeyfiles,
|
||||
emvSupportEnabled,
|
||||
VolumeProtection::ReadOnly,
|
||||
shared_ptr <VolumePassword> (), 0, shared_ptr <Pkcs5Kdf> (),shared_ptr <KeyfileList> (),
|
||||
@@ -287,8 +281,8 @@ namespace VeraCrypt
|
||||
Buffer mbr (VolumeFile->GetDeviceSectorSize());
|
||||
driveDevice.ReadAt (mbr, 0);
|
||||
|
||||
// Search for the string "VeraCrypt" or "TrueCrypt"
|
||||
const char* bootSignature = truecryptMode? "TrueCrypt" : TC_APP_NAME;
|
||||
// Search for the string "VeraCrypt"
|
||||
const char* bootSignature = TC_APP_NAME;
|
||||
size_t nameLen = strlen (bootSignature);
|
||||
for (size_t i = 0; i < mbr.Size() - nameLen; ++i)
|
||||
{
|
||||
|
||||
@@ -52,20 +52,6 @@ namespace VeraCrypt
|
||||
return Data.substr (pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool HasTrueCryptExtension () const
|
||||
{
|
||||
wstring sExt = GetExtension ();
|
||||
if ((sExt.size () == 2)
|
||||
&& (sExt[0] == L't' || sExt[0] == L'T')
|
||||
&& (sExt[1] == L'c' || sExt[1] == L'C')
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
wstring Data;
|
||||
@@ -118,13 +104,12 @@ namespace VeraCrypt
|
||||
uint64 GetTotalDataRead () const { return TotalDataRead; }
|
||||
uint64 GetTotalDataWritten () const { return TotalDataWritten; }
|
||||
VolumeType::Enum GetType () const { return Type; }
|
||||
bool GetTrueCryptMode() const { return TrueCryptMode; }
|
||||
int GetPim() const { return Pim;}
|
||||
uint64 GetVolumeCreationTime () const { return Header->GetVolumeCreationTime(); }
|
||||
bool IsHiddenVolumeProtectionTriggered () const { return HiddenVolumeProtectionTriggered; }
|
||||
bool IsInSystemEncryptionScope () const { return SystemEncryption; }
|
||||
void Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr <Pkcs5Kdf> protectionKdf = shared_ptr <Pkcs5Kdf> (),shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false);
|
||||
void Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr <Pkcs5Kdf> protectionKdf = shared_ptr <Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false);
|
||||
void Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr <Pkcs5Kdf> protectionKdf = shared_ptr <Pkcs5Kdf> (),shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false);
|
||||
void Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr <Pkcs5Kdf> protectionKdf = shared_ptr <Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false);
|
||||
void ReadSectors (const BufferPtr &buffer, uint64 byteOffset);
|
||||
void ReEncryptHeader (bool backupHeader, const ConstBufferPtr &newSalt, const ConstBufferPtr &newHeaderKey, shared_ptr <Pkcs5Kdf> newPkcs5Kdf);
|
||||
void WriteSectors (const ConstBufferPtr &buffer, uint64 byteOffset);
|
||||
@@ -152,7 +137,6 @@ namespace VeraCrypt
|
||||
uint64 TopWriteOffset;
|
||||
uint64 TotalDataRead;
|
||||
uint64 TotalDataWritten;
|
||||
bool TrueCryptMode;
|
||||
int Pim;
|
||||
bool EncryptionNotCompleted;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace VeraCrypt
|
||||
EncryptNew (headerBuffer, options.Salt, options.HeaderKey, options.Kdf);
|
||||
}
|
||||
|
||||
bool VolumeHeader::Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
|
||||
bool VolumeHeader::Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, int pim, shared_ptr <Pkcs5Kdf> kdf, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
|
||||
{
|
||||
if (password.Size() < 1)
|
||||
throw PasswordEmpty (SRC_POS);
|
||||
@@ -125,7 +125,7 @@ namespace VeraCrypt
|
||||
header.CopyFrom (encryptedData.GetRange (EncryptedHeaderDataOffset, EncryptedHeaderDataSize));
|
||||
ea->Decrypt (header);
|
||||
|
||||
if (Deserialize (header, ea, mode, truecryptMode))
|
||||
if (Deserialize (header, ea, mode))
|
||||
{
|
||||
EA = ea;
|
||||
Pkcs5 = pkcs5;
|
||||
@@ -138,18 +138,12 @@ namespace VeraCrypt
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VolumeHeader::Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode, bool truecryptMode)
|
||||
bool VolumeHeader::Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode)
|
||||
{
|
||||
if (header.Size() != EncryptedHeaderDataSize)
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
|
||||
if (truecryptMode && (header[0] != 'T' ||
|
||||
header[1] != 'R' ||
|
||||
header[2] != 'U' ||
|
||||
header[3] != 'E'))
|
||||
return false;
|
||||
|
||||
if (!truecryptMode && (header[0] != 'V' ||
|
||||
if ((header[0] != 'V' ||
|
||||
header[1] != 'E' ||
|
||||
header[2] != 'R' ||
|
||||
header[3] != 'A'))
|
||||
@@ -173,16 +167,9 @@ namespace VeraCrypt
|
||||
|
||||
RequiredMinProgramVersion = DeserializeEntry <uint16> (header, offset);
|
||||
|
||||
if (!truecryptMode && (RequiredMinProgramVersion > Version::Number()))
|
||||
if ((RequiredMinProgramVersion > Version::Number()))
|
||||
throw HigherVersionRequired (SRC_POS);
|
||||
|
||||
if (truecryptMode)
|
||||
{
|
||||
if (RequiredMinProgramVersion < 0x600 || RequiredMinProgramVersion > 0x71a)
|
||||
throw UnsupportedTrueCryptFormat (SRC_POS);
|
||||
RequiredMinProgramVersion = CurrentRequiredMinProgramVersion;
|
||||
}
|
||||
|
||||
VolumeKeyAreaCrc32 = DeserializeEntry <uint32> (header, offset);
|
||||
VolumeCreationTime = DeserializeEntry <uint64> (header, offset);
|
||||
HeaderCreationTime = DeserializeEntry <uint64> (header, offset);
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace VeraCrypt
|
||||
virtual ~VolumeHeader ();
|
||||
|
||||
void Create (const BufferPtr &headerBuffer, VolumeHeaderCreationOptions &options);
|
||||
bool Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes);
|
||||
bool Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, int pim, shared_ptr <Pkcs5Kdf> kdf, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes);
|
||||
void EncryptNew (const BufferPtr &newHeaderBuffer, const ConstBufferPtr &newSalt, const ConstBufferPtr &newHeaderKey, shared_ptr <Pkcs5Kdf> newPkcs5Kdf);
|
||||
uint64 GetEncryptedAreaStart () const { return EncryptedAreaStart; }
|
||||
uint64 GetEncryptedAreaLength () const { return EncryptedAreaLength; }
|
||||
@@ -78,7 +78,7 @@ namespace VeraCrypt
|
||||
void SetSize (uint32 headerSize);
|
||||
|
||||
protected:
|
||||
bool Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode, bool truecryptMode);
|
||||
bool Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode);
|
||||
template <typename T> T DeserializeEntry (const ConstBufferPtr &header, size_t &offset) const;
|
||||
template <typename T> T DeserializeEntryAt (const ConstBufferPtr &header, const size_t &offset) const;
|
||||
void Init ();
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace VeraCrypt
|
||||
Type = static_cast <VolumeType::Enum> (sr.DeserializeInt32 ("Type"));
|
||||
VirtualDevice = sr.DeserializeWString ("VirtualDevice");
|
||||
sr.Deserialize ("VolumeCreationTime", VolumeCreationTime);
|
||||
sr.Deserialize ("TrueCryptMode", TrueCryptMode);
|
||||
sr.Deserialize ("Pim", Pim);
|
||||
}
|
||||
|
||||
@@ -95,7 +94,6 @@ namespace VeraCrypt
|
||||
sr.Serialize ("Type", static_cast <uint32> (Type));
|
||||
sr.Serialize ("VirtualDevice", wstring (VirtualDevice));
|
||||
sr.Serialize ("VolumeCreationTime", VolumeCreationTime);
|
||||
sr.Serialize ("TrueCryptMode", TrueCryptMode);
|
||||
sr.Serialize ("Pim", Pim);
|
||||
}
|
||||
|
||||
@@ -120,7 +118,6 @@ namespace VeraCrypt
|
||||
TopWriteOffset = volume.GetTopWriteOffset();
|
||||
TotalDataRead = volume.GetTotalDataRead();
|
||||
TotalDataWritten = volume.GetTotalDataWritten();
|
||||
TrueCryptMode = volume.GetTrueCryptMode();
|
||||
Pim = volume.GetPim ();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace VeraCrypt
|
||||
VolumeType::Enum Type;
|
||||
DevicePath VirtualDevice;
|
||||
VolumeTime VolumeCreationTime;
|
||||
bool TrueCryptMode;
|
||||
int Pim;
|
||||
|
||||
private:
|
||||
|
||||
@@ -222,17 +222,14 @@ namespace VeraCrypt
|
||||
return volumeHostSize;
|
||||
}
|
||||
|
||||
Pkcs5KdfList VolumeLayoutSystemEncryption::GetSupportedKeyDerivationFunctions (bool truecryptMode) const
|
||||
Pkcs5KdfList VolumeLayoutSystemEncryption::GetSupportedKeyDerivationFunctions () const
|
||||
{
|
||||
Pkcs5KdfList l;
|
||||
if (!truecryptMode)
|
||||
{
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha256_Boot ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s_Boot ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 (false)));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool (false)));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacStreebog ()));
|
||||
}
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha256_Boot ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s_Boot ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ()));
|
||||
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacStreebog ()));
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace VeraCrypt
|
||||
virtual uint32 GetHeaderSize () const { return HeaderSize; }
|
||||
virtual uint64 GetMaxDataSize (uint64 volumeSize) const = 0;
|
||||
virtual EncryptionAlgorithmList GetSupportedEncryptionAlgorithms () const { return SupportedEncryptionAlgorithms; }
|
||||
virtual Pkcs5KdfList GetSupportedKeyDerivationFunctions (bool truecryptMode) const { return Pkcs5Kdf::GetAvailableAlgorithms(truecryptMode); }
|
||||
virtual Pkcs5KdfList GetSupportedKeyDerivationFunctions () const { return Pkcs5Kdf::GetAvailableAlgorithms(); }
|
||||
virtual EncryptionModeList GetSupportedEncryptionModes () const { return SupportedEncryptionModes; }
|
||||
virtual VolumeType::Enum GetType () const { return Type; }
|
||||
virtual bool HasBackupHeader () const = 0;
|
||||
@@ -126,7 +126,7 @@ namespace VeraCrypt
|
||||
virtual uint64 GetDataOffset (uint64 volumeHostSize) const;
|
||||
virtual uint64 GetDataSize (uint64 volumeHostSize) const;
|
||||
virtual uint64 GetMaxDataSize (uint64 volumeSize) const { throw NotApplicable (SRC_POS); }
|
||||
virtual Pkcs5KdfList GetSupportedKeyDerivationFunctions (bool truecryptMode) const;
|
||||
virtual Pkcs5KdfList GetSupportedKeyDerivationFunctions () const;
|
||||
virtual bool HasBackupHeader () const { return false; }
|
||||
virtual bool HasDriveHeader () const { return true; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user