From 435fbf74bfdf383db1238633326be558ef2d3ff2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 10:38:45 +0200 Subject: Merging upstream version 2:2.7.2. Signed-off-by: Daniel Baumann --- lib/setup.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/setup.c') diff --git a/lib/setup.c b/lib/setup.c index ff84292..70b2cee 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -2496,7 +2496,7 @@ int crypt_format_luks2_opal(struct crypt_device *cd, (device_size_bytes - range_size_bytes) / SECTOR_SIZE); if (cipher) { - r = LUKS2_check_encryption_sector(cd, device_size_bytes, data_offset_bytes, sector_size, + r = LUKS2_check_encryption_sector(cd, range_size_bytes, data_offset_bytes, sector_size, sector_size_autodetect, integrity == NULL, §or_size); if (r < 0) @@ -2517,7 +2517,7 @@ int crypt_format_luks2_opal(struct crypt_device *cd, sector_size, data_offset_bytes, metadata_size_bytes, keyslots_size_bytes, - device_size_bytes, + range_size_bytes, opal_segment_number, opal_params->user_key_size); if (r < 0) @@ -2556,7 +2556,8 @@ int crypt_format_luks2_opal(struct crypt_device *cd, r = opal_setup_ranges(cd, crypt_data_device(cd), user_key ?: cd->volume_key, range_offset_blocks, range_size_bytes / opal_block_bytes, - opal_segment_number, opal_params->admin_key, opal_params->admin_key_size); + opal_block_bytes, opal_segment_number, + opal_params->admin_key, opal_params->admin_key_size); if (r < 0) { if (r == -EPERM) log_err(cd, _("Incorrect OPAL Admin key.")); @@ -5327,7 +5328,8 @@ static int _activate_luks2_by_volume_key(struct crypt_device *cd, } r = _open_and_activate_reencrypt_device_by_vk(cd, &cd->u.luks2.hdr, name, vk, flags); } else { - assert(crypt_volume_key_get_id(vk) == LUKS2_digest_by_segment(&cd->u.luks2.hdr, CRYPT_DEFAULT_SEGMENT)); + /* hw-opal data segment type does not require volume key for activation */ + assert(!vk || crypt_volume_key_get_id(vk) == LUKS2_digest_by_segment(&cd->u.luks2.hdr, CRYPT_DEFAULT_SEGMENT)); r = LUKS2_activate(cd, name, vk, external_key, flags); } -- cgit v1.2.3