From ac9a2c08e33fcdc149f21624ee84a72d2b3761e4 Mon Sep 17 00:00:00 2001 From: Klaus Zipfel Date: Wed, 26 May 2021 09:36:32 +0200 Subject: [PATCH] Fixing incorrect offsets for data/IV with TCRYPT system-encryption with a detached header Related: #587 --- lib/tcrypt/tcrypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tcrypt/tcrypt.c b/lib/tcrypt/tcrypt.c index 945e0126..bf20b69e 100644 --- a/lib/tcrypt/tcrypt.c +++ b/lib/tcrypt/tcrypt.c @@ -1028,7 +1028,7 @@ uint64_t TCRYPT_get_data_offset(struct crypt_device *cd, /* Mapping through whole device, not partition! */ if (params->flags & CRYPT_TCRYPT_SYSTEM_HEADER) { - if (crypt_dev_is_partition(device_path(crypt_metadata_device(cd)))) + if (crypt_dev_is_partition(device_path(crypt_data_device(cd)))) return 0; goto hdr_offset; } @@ -1073,7 +1073,7 @@ uint64_t TCRYPT_get_iv_offset(struct crypt_device *cd, iv_offset = hdr->d.mk_offset / SECTOR_SIZE; if (params->flags & CRYPT_TCRYPT_SYSTEM_HEADER) - iv_offset += crypt_dev_partition_offset(device_path(crypt_metadata_device(cd))); + iv_offset += crypt_dev_partition_offset(device_path(crypt_data_device(cd))); return iv_offset; }