mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-10 21:23:40 +01:00
Reduce time for reporting wrong password by removing support for legacy hidden format because it was never functional and it was superseded by current hidden format.
This commit is contained in:
parent
02cbecff64
commit
4b9f8b232b
@ -43,7 +43,6 @@ enum
|
||||
{
|
||||
TC_VOLUME_TYPE_NORMAL = 0,
|
||||
TC_VOLUME_TYPE_HIDDEN,
|
||||
TC_VOLUME_TYPE_HIDDEN_LEGACY,
|
||||
TC_VOLUME_TYPE_COUNT
|
||||
};
|
||||
|
||||
|
@ -9024,18 +9024,6 @@ int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *pa
|
||||
headerOffset.QuadPart = useBackupHeader ? context->HostSize - TC_VOLUME_HEADER_SIZE : TC_HIDDEN_VOLUME_HEADER_OFFSET;
|
||||
break;
|
||||
|
||||
case TC_VOLUME_TYPE_HIDDEN_LEGACY:
|
||||
if (useBackupHeader)
|
||||
{
|
||||
status = ERR_PASSWORD_WRONG;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (context->IsDevice && deviceGeometry.BytesPerSector != TC_SECTOR_SIZE_LEGACY)
|
||||
continue;
|
||||
|
||||
headerOffset.QuadPart = context->HostSize - TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!SetFilePointerEx ((HANDLE) context->HostFileHandle, headerOffset, NULL, FILE_BEGIN))
|
||||
|
@ -258,12 +258,6 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, Pas
|
||||
headerOffset.QuadPart = TC_HIDDEN_VOLUME_HEADER_OFFSET;
|
||||
break;
|
||||
|
||||
case TC_VOLUME_TYPE_HIDDEN_LEGACY:
|
||||
if (bDevice && driveInfo.BytesPerSector != TC_SECTOR_SIZE_LEGACY)
|
||||
continue;
|
||||
|
||||
headerOffset.QuadPart = hostSize - TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!SetFilePointerEx ((HANDLE) dev, headerOffset, NULL, FILE_BEGIN))
|
||||
@ -356,7 +350,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, Pas
|
||||
cryptoInfo->master_keydata,
|
||||
&ci,
|
||||
cryptoInfo->VolumeSize.Value,
|
||||
(volumeType == TC_VOLUME_TYPE_HIDDEN || volumeType == TC_VOLUME_TYPE_HIDDEN_LEGACY) ? cryptoInfo->hiddenVolumeSize : 0,
|
||||
(volumeType == TC_VOLUME_TYPE_HIDDEN) ? cryptoInfo->hiddenVolumeSize : 0,
|
||||
cryptoInfo->EncryptedAreaStart.Value,
|
||||
cryptoInfo->EncryptedAreaLength.Value,
|
||||
cryptoInfo->RequiredProgramVersion,
|
||||
|
@ -319,10 +319,6 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
||||
{
|
||||
Dump ("Trying to open volume type %d\n", volumeType);
|
||||
|
||||
if (mount->bPartitionInInactiveSysEncScope
|
||||
&& volumeType == TC_VOLUME_TYPE_HIDDEN_LEGACY)
|
||||
continue;
|
||||
|
||||
/* Read the volume header */
|
||||
|
||||
if (!mount->bPartitionInInactiveSysEncScope
|
||||
@ -348,16 +344,6 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
||||
|
||||
headerOffset.QuadPart = mount->UseBackupHeader ? lDiskLength.QuadPart - TC_HIDDEN_VOLUME_HEADER_OFFSET : TC_HIDDEN_VOLUME_HEADER_OFFSET;
|
||||
break;
|
||||
|
||||
case TC_VOLUME_TYPE_HIDDEN_LEGACY:
|
||||
if (mount->UseBackupHeader)
|
||||
continue;
|
||||
|
||||
if (bRawDevice && Extension->HostBytesPerSector != TC_SECTOR_SIZE_LEGACY)
|
||||
continue;
|
||||
|
||||
headerOffset.QuadPart = lDiskLength.QuadPart - TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY;
|
||||
break;
|
||||
}
|
||||
|
||||
Dump ("Reading volume header at %I64d\n", headerOffset.QuadPart);
|
||||
@ -455,7 +441,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
||||
|
||||
ReadVolumeHeaderRecoveryMode = mount->RecoveryMode;
|
||||
|
||||
if ((volumeType == TC_VOLUME_TYPE_HIDDEN || volumeType == TC_VOLUME_TYPE_HIDDEN_LEGACY) && mount->bProtectHiddenVolume)
|
||||
if ((volumeType == TC_VOLUME_TYPE_HIDDEN) && mount->bProtectHiddenVolume)
|
||||
{
|
||||
mount->nReturnCode = ReadVolumeHeaderWCache (
|
||||
FALSE,
|
||||
@ -577,13 +563,9 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
||||
break;
|
||||
|
||||
case TC_VOLUME_TYPE_HIDDEN:
|
||||
case TC_VOLUME_TYPE_HIDDEN_LEGACY:
|
||||
|
||||
cryptoInfoPtr = mount->bProtectHiddenVolume ? tmpCryptoInfo : Extension->cryptoInfo;
|
||||
|
||||
if (volumeType == TC_VOLUME_TYPE_HIDDEN_LEGACY)
|
||||
Extension->cryptoInfo->hiddenVolumeOffset = lDiskLength.QuadPart - cryptoInfoPtr->hiddenVolumeSize - TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY;
|
||||
else
|
||||
Extension->cryptoInfo->hiddenVolumeOffset = cryptoInfoPtr->EncryptedAreaStart.Value;
|
||||
|
||||
Dump ("Hidden volume offset = %I64d\n", Extension->cryptoInfo->hiddenVolumeOffset);
|
||||
@ -613,9 +595,6 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
|
||||
|
||||
Extension->cryptoInfo->hiddenVolumeProtectedSize = tmpCryptoInfo->hiddenVolumeSize;
|
||||
|
||||
if (volumeType == TC_VOLUME_TYPE_HIDDEN_LEGACY)
|
||||
Extension->cryptoInfo->hiddenVolumeProtectedSize += TC_VOLUME_HEADER_SIZE_LEGACY;
|
||||
|
||||
Dump ("Hidden volume protection active: %I64d-%I64d (%I64d)\n", Extension->cryptoInfo->hiddenVolumeOffset, Extension->cryptoInfo->hiddenVolumeProtectedSize + Extension->cryptoInfo->hiddenVolumeOffset - 1, Extension->cryptoInfo->hiddenVolumeProtectedSize);
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ namespace VeraCrypt
|
||||
|
||||
if (hiddenVolume)
|
||||
{
|
||||
if (typeid (*normalVolume->GetLayout()) == typeid (VolumeLayoutV1Normal) && typeid (*hiddenVolume->GetLayout()) != typeid (VolumeLayoutV1Hidden))
|
||||
if (typeid (*normalVolume->GetLayout()) == typeid (VolumeLayoutV1Normal))
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
|
||||
if (typeid (*normalVolume->GetLayout()) == typeid (VolumeLayoutV2Normal) && typeid (*hiddenVolume->GetLayout()) != typeid (VolumeLayoutV2Hidden))
|
||||
@ -1281,7 +1281,7 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
shared_ptr <VolumeLayout> layout = volume->GetLayout();
|
||||
if (typeid (*layout) == typeid (VolumeLayoutV1Normal) || typeid (*layout) == typeid (VolumeLayoutV1Hidden))
|
||||
if (typeid (*layout) == typeid (VolumeLayoutV1Normal))
|
||||
{
|
||||
ShowError ("VOLUME_HAS_NO_BACKUP_HEADER");
|
||||
return;
|
||||
|
@ -129,13 +129,6 @@ namespace VeraCrypt
|
||||
if (useBackupHeaders && !layout->HasBackupHeader())
|
||||
continue;
|
||||
|
||||
if (typeid (*layout) == typeid (VolumeLayoutV1Hidden)
|
||||
&& deviceHosted
|
||||
&& hostDeviceSectorSize != TC_SECTOR_SIZE_LEGACY)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SecureBuffer headerBuffer (layout->GetHeaderSize());
|
||||
|
||||
if (layout->HasDriveHeader())
|
||||
@ -249,9 +242,6 @@ namespace VeraCrypt
|
||||
|
||||
ProtectedRangeStart = protectedVolume.VolumeDataOffset;
|
||||
ProtectedRangeEnd = protectedVolume.VolumeDataOffset + protectedVolume.VolumeDataSize;
|
||||
|
||||
if (typeid (*protectedVolume.Layout) == typeid (VolumeLayoutV1Hidden))
|
||||
ProtectedRangeEnd += protectedVolume.Layout->GetHeaderSize();
|
||||
}
|
||||
catch (PasswordException&)
|
||||
{
|
||||
|
@ -28,7 +28,6 @@ namespace VeraCrypt
|
||||
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV2Normal ()));
|
||||
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Normal ()));
|
||||
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV2Hidden ()));
|
||||
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Hidden ()));
|
||||
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutSystemEncryption ()));
|
||||
|
||||
if (type != VolumeType::Unknown)
|
||||
@ -85,35 +84,6 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
|
||||
VolumeLayoutV1Hidden::VolumeLayoutV1Hidden ()
|
||||
{
|
||||
Type = VolumeType::Hidden;
|
||||
HeaderOffset = -TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY;
|
||||
HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY;
|
||||
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
|
||||
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
|
||||
|
||||
SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
|
||||
}
|
||||
|
||||
uint64 VolumeLayoutV1Hidden::GetDataOffset (uint64 volumeHostSize) const
|
||||
{
|
||||
return volumeHostSize - GetDataSize (volumeHostSize) + HeaderOffset;
|
||||
}
|
||||
|
||||
uint64 VolumeLayoutV1Hidden::GetDataSize (uint64 volumeHostSize) const
|
||||
{
|
||||
return Header->GetHiddenVolumeDataSize ();
|
||||
}
|
||||
|
||||
|
||||
VolumeLayoutV2Normal::VolumeLayoutV2Normal ()
|
||||
{
|
||||
Type = VolumeType::Normal;
|
||||
|
@ -78,24 +78,6 @@ namespace VeraCrypt
|
||||
};
|
||||
|
||||
|
||||
class VolumeLayoutV1Hidden : public VolumeLayout
|
||||
{
|
||||
public:
|
||||
VolumeLayoutV1Hidden ();
|
||||
virtual ~VolumeLayoutV1Hidden () { }
|
||||
|
||||
virtual int GetBackupHeaderOffset () const { throw NotApplicable (SRC_POS); }
|
||||
virtual uint64 GetDataOffset (uint64 volumeHostSize) const;
|
||||
virtual uint64 GetDataSize (uint64 volumeHostSize) const;
|
||||
virtual uint64 GetMaxDataSize (uint64 volumeSize) const { throw NotApplicable (SRC_POS); }
|
||||
virtual bool HasBackupHeader () const { return false; }
|
||||
|
||||
private:
|
||||
VolumeLayoutV1Hidden (const VolumeLayoutV1Hidden &);
|
||||
VolumeLayoutV1Hidden &operator= (const VolumeLayoutV1Hidden &);
|
||||
};
|
||||
|
||||
|
||||
class VolumeLayoutV2Normal : public VolumeLayout
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user