mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix bad parsing of capi:xts(aes)-plain
Corrent logic confuses it with aes-plain (capi:xts(aes)-plain does not work in luksFormat). For CAPI format we need to skip this test.
This commit is contained in:
@@ -28,15 +28,17 @@ int crypt_parse_name_and_mode(const char *s, char *cipher, int *key_nums,
|
||||
|
||||
if (sscanf(s, "%" MAX_CIPHER_LEN_STR "[^-]-%" MAX_CIPHER_LEN_STR "s",
|
||||
cipher, cipher_mode) == 2) {
|
||||
if (!strcmp(cipher_mode, "plain"))
|
||||
strcpy(cipher_mode, "cbc-plain");
|
||||
if (!strncmp(cipher, "capi:", 5)) {
|
||||
/* CAPI must not use internal cipher driver names with dash */
|
||||
if (strchr(cipher_mode, ')'))
|
||||
return -EINVAL;
|
||||
if (key_nums)
|
||||
*key_nums = 1;
|
||||
} else if (key_nums) {
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(cipher_mode, "plain"))
|
||||
strcpy(cipher_mode, "cbc-plain");
|
||||
if (key_nums) {
|
||||
char *tmp = strchr(cipher, ':');
|
||||
*key_nums = tmp ? atoi(++tmp) : 1;
|
||||
if (!*key_nums)
|
||||
@@ -56,7 +58,8 @@ int crypt_parse_name_and_mode(const char *s, char *cipher, int *key_nums,
|
||||
}
|
||||
|
||||
if (sscanf(s, "%" MAX_CIPHER_LEN_STR "[^-]", cipher) == 1) {
|
||||
strcpy(cipher_mode, "cbc-plain");
|
||||
if (strncmp(cipher, "capi:", 5))
|
||||
strcpy(cipher_mode, "cbc-plain");
|
||||
if (key_nums)
|
||||
*key_nums = 1;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user