mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-16 21:29:59 +01:00
Refactor get_adjusted_key_size.
This commit is contained in:
committed by
Milan Broz
parent
48683f7316
commit
ff7a21eb94
@@ -1683,7 +1683,8 @@ int luksFormat(struct crypt_device **r_cd, char **r_password, size_t *r_password
|
||||
goto out;
|
||||
}
|
||||
|
||||
keysize = get_adjusted_key_size(cipher_mode, DEFAULT_LUKS1_KEYBITS, integrity_keysize);
|
||||
keysize = get_adjusted_key_size(cipher_mode, ARG_UINT32(OPT_KEY_SIZE_ID),
|
||||
DEFAULT_LUKS1_KEYBITS, integrity_keysize);
|
||||
|
||||
if (ARG_SET(OPT_HW_OPAL_ONLY_ID))
|
||||
keysize = opal_params.user_key_size;
|
||||
|
||||
@@ -139,12 +139,11 @@ int set_tries_tty(bool keyring)
|
||||
return (tools_is_stdin(ARG_STR(OPT_KEY_FILE_ID)) && isatty(STDIN_FILENO)) ? ARG_UINT32(OPT_TRIES_ID) : 1;
|
||||
}
|
||||
|
||||
int get_adjusted_key_size(const char *cipher_mode, uint32_t default_size_bits, int integrity_keysize)
|
||||
int get_adjusted_key_size(const char *cipher_mode, uint32_t keysize_bits,
|
||||
uint32_t default_size_bits, int integrity_keysize)
|
||||
{
|
||||
uint32_t keysize_bits = ARG_UINT32(OPT_KEY_SIZE_ID);
|
||||
|
||||
#if ENABLE_LUKS_ADJUST_XTS_KEYSIZE
|
||||
if (!ARG_SET(OPT_KEY_SIZE_ID) && !strncmp(cipher_mode, "xts-", 4)) {
|
||||
if (!keysize_bits && !strncmp(cipher_mode, "xts-", 4)) {
|
||||
if (default_size_bits == 128)
|
||||
keysize_bits = 256;
|
||||
else if (default_size_bits == 256)
|
||||
|
||||
@@ -27,7 +27,8 @@ int set_pbkdf_params(struct crypt_device *cd, const char *dev_type);
|
||||
|
||||
int set_tries_tty(bool keyring);
|
||||
|
||||
int get_adjusted_key_size(const char *cipher_mode, uint32_t default_size_bits, int integrity_keysize);
|
||||
int get_adjusted_key_size(const char *cipher_mode, uint32_t keysize_bits,
|
||||
uint32_t default_size_bits, int integrity_keysize);
|
||||
|
||||
int luksFormat(struct crypt_device **r_cd, char **r_password, size_t *r_passwordLen);
|
||||
|
||||
|
||||
@@ -1146,7 +1146,8 @@ static int reencrypt_luks2_init(struct crypt_device *cd, const char *data_device
|
||||
|
||||
/* key size */
|
||||
if (ARG_SET(OPT_KEY_SIZE_ID) || new_cipher)
|
||||
key_size = get_adjusted_key_size(mode, DEFAULT_LUKS1_KEYBITS, 0);
|
||||
key_size = get_adjusted_key_size(mode, ARG_UINT32(OPT_KEY_SIZE_ID),
|
||||
DEFAULT_LUKS1_KEYBITS, 0);
|
||||
else
|
||||
key_size = crypt_get_volume_key_size(cd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user