mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 11:50:10 +01:00
Add severeal helpers (get methods) for volume key.
crypt_volume_key_length() for key length crypt_volume_key_get_key() to access key data (if initialized) crypt_volume_key_description() for kernel key description crypt_volume_key_kernel_key_type() for kernel keyring key type
This commit is contained in:
committed by
Milan Broz
parent
63f7dc739b
commit
fd9be9e777
@@ -69,9 +69,13 @@ 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,
|
struct volume_key *crypt_generate_volume_key(struct crypt_device *cd, size_t keylength,
|
||||||
key_quality_info quality);
|
key_quality_info quality);
|
||||||
void crypt_free_volume_key(struct volume_key *vk);
|
void crypt_free_volume_key(struct volume_key *vk);
|
||||||
|
const char *crypt_volume_key_get_key(const struct volume_key *vk);
|
||||||
|
size_t crypt_volume_key_length(const struct volume_key *vk);
|
||||||
int crypt_volume_key_set_description(struct volume_key *key,
|
int crypt_volume_key_set_description(struct volume_key *key,
|
||||||
const char *key_description, key_type_t keyring_key_type);
|
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);
|
int crypt_volume_key_set_description_by_name(struct volume_key *vk, const char *key_name);
|
||||||
|
key_type_t crypt_volume_key_kernel_key_type(const struct volume_key *vk);
|
||||||
|
const char *crypt_volume_key_description(const struct volume_key *vk);
|
||||||
void crypt_volume_key_set_id(struct volume_key *vk, int id);
|
void crypt_volume_key_set_id(struct volume_key *vk, int id);
|
||||||
int crypt_volume_key_get_id(const struct volume_key *vk);
|
int crypt_volume_key_get_id(const struct volume_key *vk);
|
||||||
void crypt_volume_key_add_next(struct volume_key **vks, struct volume_key *vk);
|
void crypt_volume_key_add_next(struct volume_key **vks, struct volume_key *vk);
|
||||||
|
|||||||
@@ -39,6 +39,20 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key)
|
|||||||
return vk;
|
return vk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *crypt_volume_key_get_key(const struct volume_key *vk)
|
||||||
|
{
|
||||||
|
assert(vk);
|
||||||
|
|
||||||
|
return (const char *)vk->key;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t crypt_volume_key_length(const struct volume_key *vk)
|
||||||
|
{
|
||||||
|
assert(vk);
|
||||||
|
|
||||||
|
return vk->keylength;
|
||||||
|
}
|
||||||
|
|
||||||
int crypt_volume_key_set_description(struct volume_key *vk,
|
int crypt_volume_key_set_description(struct volume_key *vk,
|
||||||
const char *key_description, key_type_t keyring_key_type)
|
const char *key_description, key_type_t keyring_key_type)
|
||||||
{
|
{
|
||||||
@@ -65,6 +79,21 @@ int crypt_volume_key_set_description_by_name(struct volume_key *vk, const char *
|
|||||||
return crypt_volume_key_set_description(vk, key_description, keyring_key_type);
|
return crypt_volume_key_set_description(vk, key_description, keyring_key_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *crypt_volume_key_description(const struct volume_key *vk)
|
||||||
|
{
|
||||||
|
assert(vk);
|
||||||
|
|
||||||
|
return vk->key_description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
key_type_t crypt_volume_key_kernel_key_type(const struct volume_key *vk)
|
||||||
|
{
|
||||||
|
assert(vk);
|
||||||
|
|
||||||
|
return vk->keyring_key_type;
|
||||||
|
}
|
||||||
|
|
||||||
void crypt_volume_key_set_id(struct volume_key *vk, int id)
|
void crypt_volume_key_set_id(struct volume_key *vk, int id)
|
||||||
{
|
{
|
||||||
if (vk && id >= 0)
|
if (vk && id >= 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user