aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Kozina <okozina@redhat.com>2021-02-19 19:00:59 +0100
committerMilan Broz <gmazyland@gmail.com>2021-02-26 00:16:06 +0100
commit56a01574ff6eed663abe8f994a2108abe7ac3c66 (patch)
tree860c57a36da8f2976945875eb1bfadddb61be6ee
parentc68cd0a4835c835d2dbe842574d4a1442a832c62 (diff)
downloadcryptsetup-56a01574ff6eed663abe8f994a2108abe7ac3c66.tar.gz
Allow LUKS resume for device with cipher_null.
-rw-r--r--lib/libdevmapper.c8
-rw-r--r--lib/setup.c12
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c
index 374ada13..e6d7e68a 100644
--- a/lib/libdevmapper.c
+++ b/lib/libdevmapper.c
@@ -2943,7 +2943,9 @@ int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name,
if (!(dmt_flags & DM_KEY_WIPE_SUPPORTED))
goto out;
- if (vk->key_description)
+ if (!vk->keylength)
+ msg_size = 11; // key set -
+ else if (vk->key_description)
msg_size = strlen(vk->key_description) + int_log10(vk->keylength) + 18;
else
msg_size = vk->keylength * 2 + 10; // key set <key>
@@ -2955,7 +2957,9 @@ int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name,
}
strcpy(msg, "key set ");
- if (vk->key_description)
+ if (!vk->keylength)
+ snprintf(msg + 8, msg_size - 8, "-");
+ else if (vk->key_description)
snprintf(msg + 8, msg_size - 8, ":%zu:logon:%s", vk->keylength, vk->key_description);
else
hex_key(&msg[8], vk->keylength, vk->key);
diff --git a/lib/setup.c b/lib/setup.c
index 67a888b2..fc44075d 100644
--- a/lib/setup.c
+++ b/lib/setup.c
@@ -3104,9 +3104,15 @@ static int resume_by_volume_key(struct crypt_device *cd,
const char *name)
{
int digest, r;
+ struct volume_key *zerokey = NULL;
- /* LUKS2 path only */
- if (crypt_use_keyring_for_vk(cd) && !crypt_is_cipher_null(crypt_get_cipher_spec(cd))) {
+ if (crypt_is_cipher_null(crypt_get_cipher_spec(cd))) {
+ zerokey = crypt_alloc_volume_key(0, NULL);
+ if (!zerokey)
+ return -ENOMEM;
+ vk = zerokey;
+ } else if (crypt_use_keyring_for_vk(cd)) {
+ /* LUKS2 path only */
digest = LUKS2_digest_by_segment(&cd->u.luks2.hdr, CRYPT_DEFAULT_SEGMENT);
if (digest < 0)
return -EINVAL;
@@ -3126,6 +3132,8 @@ static int resume_by_volume_key(struct crypt_device *cd,
if (r < 0)
crypt_drop_keyring_key(cd, vk);
+ crypt_free_volume_key(zerokey);
+
return r;
}