Add id member in volume_key structure.

Also adds set/get helper routines.
This commit is contained in:
Ondrej Kozina
2019-02-18 15:59:44 +01:00
committed by Milan Broz
parent fc0c857cfe
commit b0330d62e5
2 changed files with 15 additions and 0 deletions

View File

@@ -75,6 +75,7 @@
struct crypt_device;
struct volume_key {
int id;
size_t keylength;
const char *key_description;
char key[];
@@ -84,6 +85,8 @@ 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);
void crypt_volume_key_set_id(struct volume_key *vk, int id);
int crypt_volume_key_get_id(const struct volume_key *vk);
struct crypt_pbkdf_type *crypt_get_pbkdf(struct crypt_device *cd);
int init_pbkdf_type(struct crypt_device *cd,

View File

@@ -39,6 +39,7 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key)
vk->key_description = NULL;
vk->keylength = keylength;
vk->id = -1;
/* keylength 0 is valid => no key */
if (vk->keylength) {
@@ -64,6 +65,17 @@ int crypt_volume_key_set_description(struct volume_key *vk, const char *key_desc
return 0;
}
void crypt_volume_key_set_id(struct volume_key *vk, int id)
{
if (vk && id >= 0)
vk->id = id;
}
int crypt_volume_key_get_id(const struct volume_key *vk)
{
return vk ? vk->id : -1;
}
void crypt_free_volume_key(struct volume_key *vk)
{
if (vk) {