Fix Veracrypt compatible support for longer passphrases.

Previous fix for longer passhphrases increased maximal
passphrase length even if it was not needed, for example
if used with SHA256 hash in combination with keyfiles.

This patch tries to fix the problem, so some older volumes
can be opened again.

Also some test images are added for regression testing.

Fixes: #542.
This commit is contained in:
Milan Broz
2020-03-16 17:09:41 +01:00
parent 1dab341b33
commit 2eb25910a1
3 changed files with 9 additions and 7 deletions

View File

@@ -535,13 +535,11 @@ static int TCRYPT_init_hdr(struct crypt_device *cd,
if (posix_memalign((void*)&key, crypt_getpagesize(), TCRYPT_HDR_KEY_LEN))
return -ENOMEM;
if (params->flags & CRYPT_TCRYPT_VERA_MODES) {
max_passphrase_size = VCRYPT_KEY_POOL_LEN;
if (params->flags & CRYPT_TCRYPT_VERA_MODES &&
params->passphrase_size > TCRYPT_KEY_POOL_LEN) {
/* Really. Keyfile pool length depends on passphrase size in Veracrypt. */
if (params->passphrase_size > TCRYPT_KEY_POOL_LEN)
keyfiles_pool_length = VCRYPT_KEY_POOL_LEN;
else
keyfiles_pool_length = TCRYPT_KEY_POOL_LEN;
max_passphrase_size = VCRYPT_KEY_POOL_LEN;
keyfiles_pool_length = VCRYPT_KEY_POOL_LEN;
} else {
max_passphrase_size = TCRYPT_KEY_POOL_LEN;
keyfiles_pool_length = TCRYPT_KEY_POOL_LEN;