mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Add segments validation for reencryption.
Effective segments during LUKS2 reencryption must match key characteristics of backup segment (cipher, sector_size, segment type).
This commit is contained in:
committed by
Milan Broz
parent
7420f879e0
commit
b61ec23e48
@@ -410,3 +410,23 @@ json_object *LUKS2_get_segment_by_flag(struct luks2_hdr *hdr, const char *flag)
|
||||
|
||||
return jobj_segment;
|
||||
}
|
||||
|
||||
/* compares key characteristics of both segments */
|
||||
bool json_segment_cmp(json_object *jobj_segment_1, json_object *jobj_segment_2)
|
||||
{
|
||||
const char *type = json_segment_type(jobj_segment_1);
|
||||
const char *type2 = json_segment_type(jobj_segment_2);
|
||||
|
||||
if (!type || !type2)
|
||||
return false;
|
||||
|
||||
if (strcmp(type, type2))
|
||||
return false;
|
||||
|
||||
if (!strcmp(type, "crypt"))
|
||||
return (json_segment_get_sector_size(jobj_segment_1) == json_segment_get_sector_size(jobj_segment_2) &&
|
||||
!strcmp(json_segment_get_cipher(jobj_segment_1),
|
||||
json_segment_get_cipher(jobj_segment_2)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user