mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-19 06:40:08 +01:00
Move init_keyslot_context in luks utils.
and rename it to luks_init_keyslot_context.
This commit is contained in:
committed by
Milan Broz
parent
261bef3409
commit
9f0dd9cc4c
@@ -270,3 +270,33 @@ out:
|
||||
close(fd);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: Refactor password and passwordLen params away after keyslot context support
|
||||
* is added in --encrypt reencryption mode.
|
||||
*/
|
||||
int luks_init_keyslot_context(struct crypt_device *cd,
|
||||
const char *msg,
|
||||
char **password, size_t *passwordLen, bool verify, bool pwquality,
|
||||
bool reencrypt, /* tmp hack to use old get_key */
|
||||
struct crypt_keyslot_context **kc)
|
||||
{
|
||||
int r = -EINVAL;
|
||||
|
||||
if (ARG_SET(OPT_KEY_DESCRIPTION_ID))
|
||||
r = crypt_keyslot_context_init_by_keyring(cd, ARG_STR(OPT_KEY_DESCRIPTION_ID), kc);
|
||||
else if (ARG_SET(OPT_KEY_FILE_ID) && !tools_is_stdin(ARG_STR(OPT_KEY_FILE_ID)) && !reencrypt)
|
||||
r = crypt_keyslot_context_init_by_keyfile(cd, ARG_STR(OPT_KEY_FILE_ID),
|
||||
ARG_UINT32(OPT_KEYFILE_SIZE_ID),
|
||||
ARG_UINT64(OPT_KEYFILE_OFFSET_ID), kc);
|
||||
else if (password) {
|
||||
r = tools_get_key(msg, password, passwordLen, ARG_UINT64(OPT_KEYFILE_OFFSET_ID),
|
||||
ARG_UINT32(OPT_KEYFILE_SIZE_ID), ARG_STR(OPT_KEY_FILE_ID),
|
||||
ARG_UINT32(OPT_TIMEOUT_ID), verify, pwquality, cd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = crypt_keyslot_context_init_by_passphrase(cd, *password, *passwordLen, kc);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user