Add temporary helpers to indicate uploaded volume key.

To be removed later when we add clear implementation
to hide access to volume key uploaded attribute.
This commit is contained in:
Ondrej Kozina
2025-02-12 16:55:07 +01:00
committed by Milan Broz
parent 9e0bcedbaa
commit 1bec71dbe1
3 changed files with 18 additions and 2 deletions

View File

@@ -85,6 +85,10 @@ struct volume_key *crypt_volume_key_by_id(struct volume_key *vk, int id);
void crypt_volume_key_pass_safe_alloc(struct volume_key *vk, void **safe_alloc);
bool crypt_volume_key_is_set(const struct volume_key *vk);
/* FIXME: temporary helpers to be removed later */
bool crypt_volume_key_is_uploaded(const struct volume_key *vk);
void crypt_volume_key_set_uploaded(struct volume_key *vk);
struct crypt_pbkdf_type *crypt_get_pbkdf(struct crypt_device *cd);
int init_pbkdf_type(struct crypt_device *cd,
const struct crypt_pbkdf_type *pbkdf,

View File

@@ -7484,7 +7484,7 @@ int crypt_volume_key_load_in_keyring(struct crypt_device *cd, struct volume_key
log_err(cd, _("Failed to load key in kernel keyring."));
} else {
crypt_set_key_in_keyring(cd, 1);
vk->uploaded = true;
crypt_volume_key_set_uploaded(vk);
}
return kid < 0 ? -EINVAL : 0;
@@ -7674,7 +7674,7 @@ void crypt_drop_uploaded_keyring_key(struct crypt_device *cd, struct volume_key
struct volume_key *vk = vks;
while (vk) {
if (vk->uploaded)
if (crypt_volume_key_is_uploaded(vk))
crypt_drop_keyring_key_by_description(cd, crypt_volume_key_description(vk), LOGON_KEY);
vk = crypt_volume_key_next(vk);
}

View File

@@ -231,3 +231,15 @@ bool crypt_volume_key_is_set(const struct volume_key *vk)
{
return vk && vk->key;
}
bool crypt_volume_key_is_uploaded(const struct volume_key *vk)
{
return vk && vk->uploaded;
}
void crypt_volume_key_set_uploaded(struct volume_key *vk)
{
assert(vk);
vk->uploaded = true;
}