Rename internal keyslot context functions.

This commit is contained in:
Ondrej Kozina
2024-09-04 16:41:35 +02:00
committed by Milan Broz
parent 9311c923ca
commit 6ef0650332
3 changed files with 51 additions and 51 deletions

View File

@@ -432,7 +432,7 @@ static int get_volume_key_by_vk_in_keyring(struct crypt_device *cd,
return get_key_by_vk_in_keyring(cd, kc, -2 /* unused */, -2 /* unused */, r_vk);
}
static void unlock_method_init_internal(struct crypt_keyslot_context *kc)
static void crypt_keyslot_context_init_common(struct crypt_keyslot_context *kc)
{
assert(kc);
@@ -449,7 +449,7 @@ static void keyring_context_free(struct crypt_keyslot_context *kc)
free(kc->u.kr.i_key_description);
}
void crypt_keyslot_unlock_by_keyring_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_keyring_internal(struct crypt_keyslot_context *kc,
const char *key_description)
{
assert(kc);
@@ -468,7 +468,7 @@ void crypt_keyslot_unlock_by_keyring_internal(struct crypt_keyslot_context *kc,
kc->get_verity_volume_key = NULL;
kc->get_integrity_volume_key = NULL;
kc->context_free = keyring_context_free;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
static void key_context_free(struct crypt_keyslot_context *kc)
@@ -478,7 +478,7 @@ static void key_context_free(struct crypt_keyslot_context *kc)
crypt_free_volume_key(kc->u.k.i_vk);
}
void crypt_keyslot_unlock_by_key_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_key_internal(struct crypt_keyslot_context *kc,
const char *volume_key,
size_t volume_key_size)
{
@@ -498,7 +498,7 @@ void crypt_keyslot_unlock_by_key_init_internal(struct crypt_keyslot_context *kc,
kc->get_verity_volume_key = get_generic_signed_key_by_key;
kc->get_integrity_volume_key = get_generic_volume_key_by_key;
kc->context_free = key_context_free;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
static void signed_key_context_free(struct crypt_keyslot_context *kc)
@@ -509,7 +509,7 @@ static void signed_key_context_free(struct crypt_keyslot_context *kc)
crypt_free_volume_key(kc->u.ks.i_vk_sig);
}
void crypt_keyslot_unlock_by_signed_key_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_signed_key_internal(struct crypt_keyslot_context *kc,
const char *volume_key,
size_t volume_key_size,
const char *signature,
@@ -534,10 +534,10 @@ void crypt_keyslot_unlock_by_signed_key_init_internal(struct crypt_keyslot_conte
kc->get_verity_volume_key = get_generic_signed_key_by_key;
kc->get_integrity_volume_key = NULL;
kc->context_free = signed_key_context_free;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
void crypt_keyslot_unlock_by_passphrase_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_passphrase_internal(struct crypt_keyslot_context *kc,
const char *passphrase,
size_t passphrase_size)
{
@@ -556,7 +556,7 @@ void crypt_keyslot_unlock_by_passphrase_init_internal(struct crypt_keyslot_conte
kc->get_verity_volume_key = NULL;
kc->get_integrity_volume_key = NULL;
kc->context_free = NULL;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
static void keyfile_context_free(struct crypt_keyslot_context *kc)
@@ -566,7 +566,7 @@ static void keyfile_context_free(struct crypt_keyslot_context *kc)
free(kc->u.kf.i_keyfile);
}
void crypt_keyslot_unlock_by_keyfile_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_keyfile_internal(struct crypt_keyslot_context *kc,
const char *keyfile,
size_t keyfile_size,
uint64_t keyfile_offset)
@@ -589,7 +589,7 @@ void crypt_keyslot_unlock_by_keyfile_init_internal(struct crypt_keyslot_context
kc->get_verity_volume_key = NULL;
kc->get_integrity_volume_key = NULL;
kc->context_free = keyfile_context_free;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
static void token_context_free(struct crypt_keyslot_context *kc)
@@ -600,7 +600,7 @@ static void token_context_free(struct crypt_keyslot_context *kc)
crypt_safe_free(kc->u.t.i_pin);
}
void crypt_keyslot_unlock_by_token_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_token_internal(struct crypt_keyslot_context *kc,
int token,
const char *type,
const char *pin,
@@ -627,7 +627,7 @@ void crypt_keyslot_unlock_by_token_init_internal(struct crypt_keyslot_context *k
kc->get_verity_volume_key = NULL;
kc->get_integrity_volume_key = NULL;
kc->context_free = token_context_free;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
static void vk_in_keyring_context_free(struct crypt_keyslot_context *kc)
@@ -637,7 +637,7 @@ static void vk_in_keyring_context_free(struct crypt_keyslot_context *kc)
free(kc->u.vk_kr.i_key_description);
}
void crypt_keyslot_unlock_by_vk_in_keyring_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_vk_in_keyring_internal(struct crypt_keyslot_context *kc,
const char *key_description)
{
assert(kc);
@@ -656,7 +656,7 @@ void crypt_keyslot_unlock_by_vk_in_keyring_internal(struct crypt_keyslot_context
kc->get_verity_volume_key = NULL;
kc->get_integrity_volume_key = NULL;
kc->context_free = vk_in_keyring_context_free;
unlock_method_init_internal(kc);
crypt_keyslot_context_init_common(kc);
}
void crypt_keyslot_context_destroy_internal(struct crypt_keyslot_context *kc)
@@ -710,7 +710,7 @@ static int _crypt_keyslot_context_init_by_passphrase(const char *passphrase,
passphrase = "";
}
crypt_keyslot_unlock_by_passphrase_init_internal(tmp, passphrase, passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(tmp, passphrase, passphrase_size);
if (self_contained) {
tmp->i_passphrase = i_passphrase;
@@ -768,7 +768,7 @@ static int _crypt_keyslot_context_init_by_keyfile(const char *keyfile,
keyfile = i_keyfile;
}
crypt_keyslot_unlock_by_keyfile_init_internal(tmp, keyfile, keyfile_size, keyfile_offset);
crypt_keyslot_context_init_by_keyfile_internal(tmp, keyfile, keyfile_size, keyfile_offset);
if (self_contained) {
tmp->u.kf.i_keyfile = i_keyfile;
@@ -833,7 +833,7 @@ static int _crypt_keyslot_context_init_by_token(int token,
pin = i_pin;
}
crypt_keyslot_unlock_by_token_init_internal(tmp, token, type, pin, pin_size, usrptr);
crypt_keyslot_context_init_by_token_internal(tmp, token, type, pin, pin_size, usrptr);
if (self_contained) {
tmp->u.t.i_pin = i_pin;
@@ -899,7 +899,7 @@ static int _crypt_keyslot_context_init_by_volume_key(const char *volume_key,
volume_key = i_vk->key;
}
crypt_keyslot_unlock_by_key_init_internal(tmp, volume_key, volume_key_size);
crypt_keyslot_context_init_by_key_internal(tmp, volume_key, volume_key_size);
if (self_contained) {
tmp->u.k.i_vk = i_vk;
@@ -960,7 +960,7 @@ static int _crypt_keyslot_context_init_by_signed_key(const char *volume_key,
signature = i_vk_sig->key;
}
crypt_keyslot_unlock_by_signed_key_init_internal(tmp, volume_key, volume_key_size,
crypt_keyslot_context_init_by_signed_key_internal(tmp, volume_key, volume_key_size,
signature, signature_size);
if (self_contained) {
@@ -1026,7 +1026,7 @@ static int _crypt_keyslot_context_init_by_keyring(const char *key_description,
key_description = i_key_description;
}
crypt_keyslot_unlock_by_keyring_internal(tmp, key_description);
crypt_keyslot_context_init_by_keyring_internal(tmp, key_description);
if (self_contained) {
tmp->u.kr.i_key_description = i_key_description;
@@ -1078,7 +1078,7 @@ static int _crypt_keyslot_context_init_by_vk_in_keyring(const char *key_descript
key_description = i_key_description;
}
crypt_keyslot_unlock_by_vk_in_keyring_internal(tmp, key_description);
crypt_keyslot_context_init_by_vk_in_keyring_internal(tmp, key_description);
if (self_contained) {
tmp->u.vk_kr.i_key_description = i_key_description;

View File

@@ -123,36 +123,36 @@ struct crypt_keyslot_context {
void crypt_keyslot_context_destroy_internal(struct crypt_keyslot_context *method);
void crypt_keyslot_unlock_by_key_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_key_internal(struct crypt_keyslot_context *kc,
const char *volume_key,
size_t volume_key_size);
void crypt_keyslot_unlock_by_signed_key_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_signed_key_internal(struct crypt_keyslot_context *kc,
const char *volume_key,
size_t volume_key_size,
const char *signature,
size_t signature_size);
void crypt_keyslot_unlock_by_passphrase_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_passphrase_internal(struct crypt_keyslot_context *kc,
const char *passphrase,
size_t passphrase_size);
void crypt_keyslot_unlock_by_keyfile_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_keyfile_internal(struct crypt_keyslot_context *kc,
const char *keyfile,
size_t keyfile_size,
uint64_t keyfile_offset);
void crypt_keyslot_unlock_by_token_init_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_token_internal(struct crypt_keyslot_context *kc,
int token,
const char *type,
const char *pin,
size_t pin_size,
void *usrptr);
void crypt_keyslot_unlock_by_keyring_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_keyring_internal(struct crypt_keyslot_context *kc,
const char *key_description);
void crypt_keyslot_unlock_by_vk_in_keyring_internal(struct crypt_keyslot_context *kc,
void crypt_keyslot_context_init_by_vk_in_keyring_internal(struct crypt_keyslot_context *kc,
const char *key_description);
const char *keyslot_context_type_string(const struct crypt_keyslot_context *kc);

View File

@@ -4397,7 +4397,7 @@ int crypt_resume_by_passphrase(struct crypt_device *cd,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_passphrase_init_internal(&kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(&kc, passphrase, passphrase_size);
r = crypt_resume_by_keyslot_context(cd, name, keyslot, &kc);
crypt_keyslot_context_destroy_internal(&kc);
@@ -4414,7 +4414,7 @@ int crypt_resume_by_keyfile_device_offset(struct crypt_device *cd,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_keyfile_init_internal(&kc, keyfile, keyfile_size, keyfile_offset);
crypt_keyslot_context_init_by_keyfile_internal(&kc, keyfile, keyfile_size, keyfile_offset);
r = crypt_resume_by_keyslot_context(cd, name, keyslot, &kc);
crypt_keyslot_context_destroy_internal(&kc);
@@ -4450,7 +4450,7 @@ int crypt_resume_by_volume_key(struct crypt_device *cd,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_key_init_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_context_init_by_key_internal(&kc, volume_key, volume_key_size);
r = crypt_resume_by_keyslot_context(cd, name, CRYPT_ANY_SLOT /* unused */, &kc);
crypt_keyslot_context_destroy_internal(&kc);
@@ -4467,7 +4467,7 @@ int crypt_resume_by_token_pin(struct crypt_device *cd, const char *name,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_token_init_internal(&kc, token, type, pin, pin_size, usrptr);
crypt_keyslot_context_init_by_token_internal(&kc, token, type, pin, pin_size, usrptr);
r = crypt_resume_by_keyslot_context(cd, name, CRYPT_ANY_SLOT, &kc);
crypt_keyslot_context_destroy_internal(&kc);
@@ -4490,8 +4490,8 @@ int crypt_keyslot_add_by_passphrase(struct crypt_device *cd,
if (!passphrase || !new_passphrase)
return -EINVAL;
crypt_keyslot_unlock_by_passphrase_init_internal(&kc, passphrase, passphrase_size);
crypt_keyslot_unlock_by_passphrase_init_internal(&new_kc, new_passphrase, new_passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(&kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(&new_kc, new_passphrase, new_passphrase_size);
r = crypt_keyslot_add_by_keyslot_context(cd, CRYPT_ANY_SLOT, &kc, keyslot, &new_kc, 0);
@@ -4634,8 +4634,8 @@ int crypt_keyslot_add_by_keyfile_device_offset(struct crypt_device *cd,
if (!keyfile || !new_keyfile)
return -EINVAL;
crypt_keyslot_unlock_by_keyfile_init_internal(&kc, keyfile, keyfile_size, keyfile_offset);
crypt_keyslot_unlock_by_keyfile_init_internal(&new_kc, new_keyfile, new_keyfile_size, new_keyfile_offset);
crypt_keyslot_context_init_by_keyfile_internal(&kc, keyfile, keyfile_size, keyfile_offset);
crypt_keyslot_context_init_by_keyfile_internal(&new_kc, new_keyfile, new_keyfile_size, new_keyfile_offset);
r = crypt_keyslot_add_by_keyslot_context(cd, CRYPT_ANY_SLOT, &kc, keyslot, &new_kc, 0);
@@ -4684,8 +4684,8 @@ int crypt_keyslot_add_by_volume_key(struct crypt_device *cd,
if (!passphrase)
return -EINVAL;
crypt_keyslot_unlock_by_key_init_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_unlock_by_passphrase_init_internal(&new_kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_key_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_context_init_by_passphrase_internal(&new_kc, passphrase, passphrase_size);
r = crypt_keyslot_add_by_keyslot_context(cd, CRYPT_ANY_SLOT, &kc, keyslot, &new_kc, 0);
@@ -5839,7 +5839,7 @@ int crypt_activate_by_passphrase(struct crypt_device *cd,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_passphrase_init_internal(&kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(&kc, passphrase, passphrase_size);
r = crypt_activate_by_keyslot_context(cd, name, keyslot, &kc, CRYPT_ANY_SLOT, NULL, flags);
crypt_keyslot_context_destroy_internal(&kc);
@@ -5857,7 +5857,7 @@ int crypt_activate_by_keyfile_device_offset(struct crypt_device *cd,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_keyfile_init_internal(&kc, keyfile, keyfile_size, keyfile_offset);
crypt_keyslot_context_init_by_keyfile_internal(&kc, keyfile, keyfile_size, keyfile_offset);
r = crypt_activate_by_keyslot_context(cd, name, keyslot, &kc, CRYPT_ANY_SLOT, NULL, flags);
crypt_keyslot_context_destroy_internal(&kc);
@@ -5896,7 +5896,7 @@ int crypt_activate_by_volume_key(struct crypt_device *cd,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_key_init_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_context_init_by_key_internal(&kc, volume_key, volume_key_size);
r = crypt_activate_by_keyslot_context(cd, name, CRYPT_ANY_SLOT /* unused */, &kc, CRYPT_ANY_SLOT, NULL, flags);
crypt_keyslot_context_destroy_internal(&kc);
@@ -5923,10 +5923,10 @@ int crypt_activate_by_signed_key(struct crypt_device *cd,
}
if (signature)
crypt_keyslot_unlock_by_signed_key_init_internal(&kc, volume_key, volume_key_size,
crypt_keyslot_context_init_by_signed_key_internal(&kc, volume_key, volume_key_size,
signature, signature_size);
else
crypt_keyslot_unlock_by_key_init_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_context_init_by_key_internal(&kc, volume_key, volume_key_size);
r = crypt_activate_by_keyslot_context(cd, name, -2 /* unused */, &kc, CRYPT_ANY_SLOT, NULL, flags);
crypt_keyslot_context_destroy_internal(&kc);
@@ -6116,7 +6116,7 @@ int crypt_volume_key_get(struct crypt_device *cd,
if (!passphrase)
return crypt_volume_key_get_by_keyslot_context(cd, keyslot, volume_key, volume_key_size, NULL);
crypt_keyslot_unlock_by_passphrase_init_internal(&kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(&kc, passphrase, passphrase_size);
r = crypt_volume_key_get_by_keyslot_context(cd, keyslot, volume_key, volume_key_size, &kc);
@@ -7129,7 +7129,7 @@ int crypt_activate_by_token_pin(struct crypt_device *cd, const char *name,
int r;
struct crypt_keyslot_context kc;
crypt_keyslot_unlock_by_token_init_internal(&kc, token, type, pin, pin_size, usrptr);
crypt_keyslot_context_init_by_token_internal(&kc, token, type, pin, pin_size, usrptr);
r = crypt_activate_by_keyslot_context(cd, name, CRYPT_ANY_SLOT, &kc, CRYPT_ANY_SLOT, NULL, flags);
crypt_keyslot_context_destroy_internal(&kc);
@@ -7536,9 +7536,9 @@ int crypt_keyslot_add_by_key(struct crypt_device *cd,
if ((flags & CRYPT_VOLUME_KEY_SET) && crypt_keyslot_status(cd, keyslot) > CRYPT_SLOT_INACTIVE &&
isLUKS2(cd->type)) {
if (volume_key)
crypt_keyslot_unlock_by_key_init_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_context_init_by_key_internal(&kc, volume_key, volume_key_size);
else
crypt_keyslot_unlock_by_passphrase_init_internal(&kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_passphrase_internal(&kc, passphrase, passphrase_size);
r = verify_and_update_segment_digest(cd, &cd->u.luks2.hdr, keyslot, &kc);
@@ -7547,8 +7547,8 @@ int crypt_keyslot_add_by_key(struct crypt_device *cd,
return r;
}
crypt_keyslot_unlock_by_key_init_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_unlock_by_passphrase_init_internal(&new_kc, passphrase, passphrase_size);
crypt_keyslot_context_init_by_key_internal(&kc, volume_key, volume_key_size);
crypt_keyslot_context_init_by_passphrase_internal(&new_kc, passphrase, passphrase_size);
r = crypt_keyslot_add_by_keyslot_context(cd, CRYPT_ANY_SLOT, &kc, keyslot, &new_kc, flags);
@@ -7899,7 +7899,7 @@ int crypt_activate_by_keyring(struct crypt_device *cd,
if (!cd || !key_description)
return -EINVAL;
crypt_keyslot_unlock_by_keyring_internal(&kc, key_description);
crypt_keyslot_context_init_by_keyring_internal(&kc, key_description);
r = crypt_activate_by_keyslot_context(cd, name, keyslot, &kc, CRYPT_ANY_SLOT, NULL, flags);
crypt_keyslot_context_destroy_internal(&kc);