X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fluks2%2Fluks2_digest.c;h=933b05951555ce80512bbaae8cd3252e131d603c;hb=6497abd1df88001eb1f45f7348534911b33d05b5;hp=6845a6b675bc73f4a27a784fb571ef1a267e0876;hpb=f7fc3bb4e50cce23dd95111b246b6e034537e2cf;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/lib/luks2/luks2_digest.c b/lib/luks2/luks2_digest.c index 6845a6b..933b059 100644 --- a/lib/luks2/luks2_digest.c +++ b/lib/luks2/luks2_digest.c @@ -1,8 +1,8 @@ /* * LUKS - Linux Unified Key Setup v2, digest handling * - * Copyright (C) 2015-2021 Red Hat, Inc. All rights reserved. - * Copyright (C) 2015-2021 Milan Broz + * Copyright (C) 2015-2023 Red Hat, Inc. All rights reserved. + * Copyright (C) 2015-2023 Milan Broz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,7 +28,7 @@ static const digest_handler *digest_handlers[LUKS2_DIGEST_MAX] = { NULL }; -static const digest_handler *LUKS2_digest_handler_type(struct crypt_device *cd, const char *type) +static const digest_handler *LUKS2_digest_handler_type(const char *type) { int i; @@ -57,10 +57,10 @@ static const digest_handler *LUKS2_digest_handler(struct crypt_device *cd, int d if (!json_object_object_get_ex(jobj1, "type", &jobj2)) return NULL; - return LUKS2_digest_handler_type(cd, json_object_get_string(jobj2)); + return LUKS2_digest_handler_type(json_object_get_string(jobj2)); } -static int LUKS2_digest_find_free(struct crypt_device *cd, struct luks2_hdr *hdr) +static int LUKS2_digest_find_free(struct luks2_hdr *hdr) { int digest = 0; @@ -78,11 +78,11 @@ int LUKS2_digest_create(struct crypt_device *cd, int digest; const digest_handler *dh; - dh = LUKS2_digest_handler_type(cd, type); + dh = LUKS2_digest_handler_type(type); if (!dh) return -EINVAL; - digest = LUKS2_digest_find_free(cd, hdr); + digest = LUKS2_digest_find_free(hdr); if (digest < 0) return -EINVAL; @@ -111,7 +111,6 @@ int LUKS2_digest_by_keyslot(struct luks2_hdr *hdr, int keyslot) } int LUKS2_digest_verify_by_digest(struct crypt_device *cd, - struct luks2_hdr *hdr, int digest, const struct volume_key *vk) { @@ -144,7 +143,7 @@ int LUKS2_digest_verify(struct crypt_device *cd, log_dbg(cd, "Verifying key from keyslot %d, digest %d.", keyslot, digest); - return LUKS2_digest_verify_by_digest(cd, hdr, digest, vk); + return LUKS2_digest_verify_by_digest(cd, digest, vk); } int LUKS2_digest_dump(struct crypt_device *cd, int digest) @@ -164,7 +163,7 @@ int LUKS2_digest_any_matching(struct crypt_device *cd, int digest; for (digest = 0; digest < LUKS2_DIGEST_MAX; digest++) - if (LUKS2_digest_verify_by_digest(cd, hdr, digest, vk) == digest) + if (LUKS2_digest_verify_by_digest(cd, digest, vk) == digest) return digest; return -ENOENT; @@ -175,7 +174,7 @@ int LUKS2_digest_verify_by_segment(struct crypt_device *cd, int segment, const struct volume_key *vk) { - return LUKS2_digest_verify_by_digest(cd, hdr, LUKS2_digest_by_segment(hdr, segment), vk); + return LUKS2_digest_verify_by_digest(cd, LUKS2_digest_by_segment(hdr, segment), vk); } /* FIXME: segment can have more digests */ @@ -256,12 +255,10 @@ int LUKS2_digest_assign(struct crypt_device *cd, struct luks2_hdr *hdr, if (r < 0) return r; - // FIXME: do not write header in nothing changed return commit ? LUKS2_hdr_write(cd, hdr) : 0; } -static int assign_all_segments(struct crypt_device *cd, struct luks2_hdr *hdr, - int digest, int assign) +static int assign_all_segments(struct luks2_hdr *hdr, int digest, int assign) { json_object *jobj1, *jobj_digest, *jobj_digest_segments; @@ -337,7 +334,7 @@ int LUKS2_digest_segment_assign(struct crypt_device *cd, struct luks2_hdr *hdr, json_object_object_foreach(jobj_digests, key, val) { UNUSED(val); if (segment == CRYPT_ANY_SEGMENT) - r = assign_all_segments(cd, hdr, atoi(key), assign); + r = assign_all_segments(hdr, atoi(key), assign); else r = assign_one_segment(cd, hdr, segment, atoi(key), assign); if (r < 0) @@ -345,7 +342,7 @@ int LUKS2_digest_segment_assign(struct crypt_device *cd, struct luks2_hdr *hdr, } } else { if (segment == CRYPT_ANY_SEGMENT) - r = assign_all_segments(cd, hdr, digest, assign); + r = assign_all_segments(hdr, digest, assign); else r = assign_one_segment(cd, hdr, segment, digest, assign); } @@ -353,7 +350,6 @@ int LUKS2_digest_segment_assign(struct crypt_device *cd, struct luks2_hdr *hdr, if (r < 0) return r; - // FIXME: do not write header in nothing changed return commit ? LUKS2_hdr_write(cd, hdr) : 0; } @@ -445,7 +441,7 @@ int LUKS2_volume_key_load_in_keyring_by_keyslot(struct crypt_device *cd, } int LUKS2_volume_key_load_in_keyring_by_digest(struct crypt_device *cd, - struct luks2_hdr *hdr, struct volume_key *vk, int digest) + struct volume_key *vk, int digest) { char *desc = get_key_description_by_digest(cd, digest); int r;