zkey-cryptsetup: Use PBKDF2 as default PBKDF for new key slots

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 <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2019-02-04 14:35:58 +01:00
committed by Jan Höppner
parent b26dbfe832
commit a69470d7e0
2 changed files with 40 additions and 4 deletions
+12 -4
View File
@@ -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;
}