Skip to content

Commit

Permalink
Rename 'keyring' member to 'keyring_key_type' in volume_key.
Browse files Browse the repository at this point in the history
The keyring field is misleading since the
field indeed contains the type identification
id.
  • Loading branch information
oniko committed Nov 27, 2024
1 parent 82bee1c commit 9f1aee4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct volume_key {
int id;
size_t keylength; /* length in bytes */
const char *key_description; /* keyring key name/description */
key_type_t keyring; /* type of keyring where the key is stored */
key_type_t keyring_key_type; /* kernel keyring key type */
bool uploaded; /* uploaded to keyring, can drop it */
struct volume_key *next;
char key[];
Expand All @@ -63,7 +63,7 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key);
struct volume_key *crypt_generate_volume_key(struct crypt_device *cd, size_t keylength);
void crypt_free_volume_key(struct volume_key *vk);
int crypt_volume_key_set_description(struct volume_key *key,
const char *key_description, key_type_t keyring);
const char *key_description, key_type_t keyring_key_type);
int crypt_volume_key_set_description_by_name(struct volume_key *vk, const char *key_name);
void crypt_volume_key_set_id(struct volume_key *vk, int id);
int crypt_volume_key_get_id(const struct volume_key *vk);
Expand Down
4 changes: 2 additions & 2 deletions lib/libdevmapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ static char *get_dm_crypt_params(const struct dm_target *tgt, uint32_t flags)
if (null_cipher)
hexkey = crypt_bytes_to_hex(0, NULL);
else if (flags & CRYPT_ACTIVATE_KEYRING_KEY) {
if (!tgt->u.crypt.vk->key_description || tgt->u.crypt.vk->keyring == INVALID_KEY)
if (!tgt->u.crypt.vk->key_description || tgt->u.crypt.vk->keyring_key_type == INVALID_KEY)
goto out;
keystr_len = strlen(tgt->u.crypt.vk->key_description) +
int_log10(tgt->u.crypt.vk->keylength) +
Expand All @@ -600,7 +600,7 @@ static char *get_dm_crypt_params(const struct dm_target *tgt, uint32_t flags)
if (!hexkey)
goto out;
r = snprintf(hexkey, keystr_len, ":%zu:%s:%s", tgt->u.crypt.vk->keylength,
key_type_name(tgt->u.crypt.vk->keyring), tgt->u.crypt.vk->key_description);
key_type_name(tgt->u.crypt.vk->keyring_key_type), tgt->u.crypt.vk->key_description);
if (r < 0 || r >= keystr_len)
goto out;
} else
Expand Down
4 changes: 2 additions & 2 deletions lib/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -3357,7 +3357,7 @@ static int _reload_device(struct crypt_device *cd, const char *name,
if (tgt->type == DM_CRYPT && sdmd->flags & CRYPT_ACTIVATE_KEYRING_KEY) {
r = crypt_volume_key_set_description(tgt->u.crypt.vk,
src->u.crypt.vk->key_description,
src->u.crypt.vk->keyring);
src->u.crypt.vk->keyring_key_type);
if (r)
goto out;
} else if (tgt->type == DM_CRYPT) {
Expand Down Expand Up @@ -3479,7 +3479,7 @@ static int _reload_device_with_integrity(struct crypt_device *cd,
if (sdmd->flags & CRYPT_ACTIVATE_KEYRING_KEY) {
r = crypt_volume_key_set_description(tgt->u.crypt.vk,
src->u.crypt.vk->key_description,
src->u.crypt.vk->keyring);
src->u.crypt.vk->keyring_key_type);
if (r)
goto out;
} else {
Expand Down
12 changes: 6 additions & 6 deletions lib/volumekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key)
return NULL;

vk->key_description = NULL;
vk->keyring = INVALID_KEY;
vk->keyring_key_type = INVALID_KEY;
vk->keylength = keylength;
vk->uploaded = false;
vk->id = KEY_NOT_VERIFIED;
Expand All @@ -43,14 +43,14 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key)
}

int crypt_volume_key_set_description(struct volume_key *vk,
const char *key_description, key_type_t keyring)
const char *key_description, key_type_t keyring_key_type)
{
if (!vk)
return -EINVAL;

free(CONST_CAST(void*)vk->key_description);
vk->key_description = NULL;
vk->keyring = keyring;
vk->keyring_key_type = keyring_key_type;
if (key_description && !(vk->key_description = strdup(key_description)))
return -ENOMEM;

Expand All @@ -60,12 +60,12 @@ int crypt_volume_key_set_description(struct volume_key *vk,
int crypt_volume_key_set_description_by_name(struct volume_key *vk, const char *key_name)
{
const char *key_description = NULL;
key_type_t keyring = keyring_type_and_name(key_name, &key_description);
key_type_t keyring_key_type = keyring_type_and_name(key_name, &key_description);

if (keyring == INVALID_KEY)
if (keyring_key_type == INVALID_KEY)
return -EINVAL;

return crypt_volume_key_set_description(vk, key_description, keyring);
return crypt_volume_key_set_description(vk, key_description, keyring_key_type);
}

void crypt_volume_key_set_id(struct volume_key *vk, int id)
Expand Down

0 comments on commit 9f1aee4

Please sign in to comment.