/*
* 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
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;
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;
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;
}
int LUKS2_digest_verify_by_digest(struct crypt_device *cd,
- struct luks2_hdr *hdr,
int digest,
const struct volume_key *vk)
{
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)
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;
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 */
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;
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)
}
} 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);
}
if (r < 0)
return r;
- // FIXME: do not write header in nothing changed
return commit ? LUKS2_hdr_write(cd, hdr) : 0;
}
}
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;