From a69470d7e02af2d7d6a4c781eef57727c0672fc0 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Mon, 4 Feb 2019 14:35:58 +0100 Subject: [PATCH] zkey-cryptsetup: Use PBKDF2 as default PBKDF for new key slots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LUKS2 encrypted volumes use Argon2i as default password based key derivation function (PBKDF). Argon2i is a so-called memory-hard function. It requires a certain amount of physical memory to make dictionary attacks more costly. Unfortunately, when multiple encrypted volumes are unlocked automatically during system startup via /etc/crypttab, the use of Argon2i will most likely cause an out-of-memory error in systemd. To avoid the out-of-memory error, use PBKDF2 instead. Because PAES uses secure keys as volume keys, the security of the key derivation function used to derive the key to encrypt the volume key in the LUKS key slots is of less relevance. Thus it is safe to use a weaker key derivation function. Signed-off-by: Ingo Franzki Reviewed-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zkey/zkey-cryptsetup.1 | 28 ++++++++++++++++++++++++++++ zkey/zkey-cryptsetup.c | 16 ++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/zkey/zkey-cryptsetup.1 b/zkey/zkey-cryptsetup.1 index 988ef76c..fd1741aa 100644 --- a/zkey/zkey-cryptsetup.1 +++ b/zkey/zkey-cryptsetup.1 @@ -180,6 +180,20 @@ and to control which part of the key file is used as passphrase. These options behave in the same way as with \fBcryptsetup\fP. .PP +The +.B reencipher +command creates a new key slot with the re-enciphered secure AES volume key. +The new key slot uses +.B PBKDF2 +as password based key derivation function. LUKS2 volumes typically default to +.B Argon2i +as password based key derivation function, +but this might cause out-of-memory errors when multiple encrypted volumes are +unlocked automatically at boot through /etc/crypttab. Because PAES +uses secure AES keys as volume keys, the security of the key derivation +function used to encrypt the volume key in the LUKS key slots is of less +relevance. +.PP .B Note: The \fBreencipher\fP command requires the CCA host library (libcsulcca.so) to be installed. For the supported environments and downloads, see: @@ -288,6 +302,20 @@ and .B \-\-keyfile\-size to control which part of the key file is used as passphrase. These options behave in the same way the same as with \fBcryptsetup\fP. +.PP +The +.B setkey +command creates a new key slot with the re-enciphered secure AES volume key. +The new key slot uses +.B PBKDF2 +as password based key derivation function. LUKS2 volumes typically default to +.B Argon2i +as password based key derivation function, +but this might cause out-of-memory errors when multiple encrypted volumes are +unlocked automatically at boot through /etc/crypttab. Because PAES +uses secure AES keys as volume keys, the security of the key derivation +function used to encrypt the volume key in the LUKS key slots is of less +relevance. . . . diff --git a/zkey/zkey-cryptsetup.c b/zkey/zkey-cryptsetup.c index f7098f81..c269b8b7 100644 --- a/zkey/zkey-cryptsetup.c +++ b/zkey/zkey-cryptsetup.c @@ -1096,7 +1096,11 @@ static int put_vp_token(struct crypt_device *cd, int token, */ static int open_device(const char *device, struct crypt_device **cd) { - const struct crypt_pbkdf_type *pbkdf; + const struct crypt_pbkdf_type pbkdf2 = { + .type = CRYPT_KDF_PBKDF2, + .hash = "sha256", + .time_ms = 2000, + }; struct crypt_device *cdev = NULL; int rc; @@ -1128,10 +1132,14 @@ static int open_device(const char *device, struct crypt_device **cd) goto out; } - pbkdf = crypt_get_pbkdf_type(cdev); - rc = crypt_set_pbkdf_type(cdev, pbkdf); + /* + * Set PBKDF2 as default key derivation function. LUKS2 uses + * Argon2i as default, but this might cause out-of-memory errors when + * multiple LUKS2 volumes are opened automatically via /etc/crypttab + */ + rc = crypt_set_pbkdf_type(cdev, &pbkdf2); if (rc != 0) { - warnx("Failed to set the PBKDF-type for device '%s': %s", + warnx("Failed to set the PBKDF for device '%s': %s", device, strerror(-rc)); goto out; }