From bc987c8d18ddeb6fec46113a7fe7588555b592e7 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Mon, 29 Jul 2019 17:05:31 +0200 Subject: [PATCH] zkey: Allow 'zkey-cryptsetup setkey' to set different key types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a secure key has been converted from type CCA-AESDATA to type CCA-AESCIPHER, the secure key stored in the LUKS2 header of a volume encrypted with that key should also changed. Command 'zkey-cryptsetup setkey' allows to set (replace) the volume key in the LUKS2 header. It now accepts keys to be set that have a different size of the original volume keys. CCA-AESCIPHER keys are larger than CCA-AESDATA keys. Signed-off-by: Ingo Franzki Reviewed-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zkey/zkey-cryptsetup.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/zkey/zkey-cryptsetup.c b/zkey/zkey-cryptsetup.c index ab020313..7ba28426 100644 --- a/zkey/zkey-cryptsetup.c +++ b/zkey/zkey-cryptsetup.c @@ -2169,14 +2169,7 @@ static int command_setkey(void) if (rc < 0) goto out; - if (keysize != newkey_size) { - warnx("The secure key in file '%s' has an invalid size", - g.master_key_file); - rc = -EINVAL; - goto out; - } - - if (memcmp(newkey, key, keysize) == 0) { + if (keysize == newkey_size && memcmp(newkey, key, keysize) == 0) { warnx("The secure key in file '%s' is equal to the current " "volume key, setkey is ignored", g.master_key_file); rc = 0;