Skip to content

Commit

Permalink
Add temporary helpers to indicate uploaded volume key.
Browse files Browse the repository at this point in the history
To be removed later when we add clear implementation
to hide access to volume key uploaded attribute.
  • Loading branch information
oniko authored and mbroz committed Feb 16, 2025
1 parent 9e0bced commit 1bec71d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions lib/volumekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 1bec71d

Please sign in to comment.