mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 03:40:05 +01:00
Move LUKS2 segments handling in separate file.
This commit is contained in:
committed by
Milan Broz
parent
7569519530
commit
36ac5fe735
@@ -171,22 +171,7 @@ json_object *LUKS2_get_digest_jobj(struct luks2_hdr *hdr, int digest)
|
|||||||
|
|
||||||
json_object *LUKS2_get_segment_jobj(struct luks2_hdr *hdr, int segment)
|
json_object *LUKS2_get_segment_jobj(struct luks2_hdr *hdr, int segment)
|
||||||
{
|
{
|
||||||
json_object *jobj1, *jobj2;
|
return hdr ? json_segments_get_segment(json_get_segments_jobj(hdr->jobj), segment) : NULL;
|
||||||
char segment_name[16];
|
|
||||||
|
|
||||||
if (!hdr || segment < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (snprintf(segment_name, sizeof(segment_name), "%u", segment) < 1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(hdr->jobj, "segments", &jobj1))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!json_object_object_get_ex(jobj1, segment_name, &jobj2))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return jobj2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1643,24 +1628,17 @@ uint64_t LUKS2_get_data_offset(struct luks2_hdr *hdr)
|
|||||||
|
|
||||||
const char *LUKS2_get_cipher(struct luks2_hdr *hdr, int segment)
|
const char *LUKS2_get_cipher(struct luks2_hdr *hdr, int segment)
|
||||||
{
|
{
|
||||||
json_object *jobj1, *jobj2, *jobj3;
|
json_object *jobj_segment;
|
||||||
char buf[16];
|
|
||||||
|
|
||||||
if (segment < 0 || snprintf(buf, sizeof(buf), "%u", segment) < 1)
|
if (!hdr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!json_object_object_get_ex(hdr->jobj, "segments", &jobj1))
|
jobj_segment = json_segments_get_segment(json_get_segments_jobj(hdr->jobj), segment);
|
||||||
|
if (!jobj_segment)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!json_object_object_get_ex(jobj1, buf, &jobj2))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (json_object_object_get_ex(jobj2, "encryption", &jobj3))
|
|
||||||
return json_object_get_string(jobj3);
|
|
||||||
|
|
||||||
/* FIXME: default encryption (for other segment types) must be string here. */
|
/* FIXME: default encryption (for other segment types) must be string here. */
|
||||||
return "null";
|
return json_segment_get_cipher(jobj_segment) ?: "null";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *LUKS2_get_keyslot_cipher(struct luks2_hdr *hdr, int keyslot, size_t *key_size)
|
const char *LUKS2_get_keyslot_cipher(struct luks2_hdr *hdr, int keyslot, size_t *key_size)
|
||||||
|
|||||||
Reference in New Issue
Block a user