mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Allow LUKS resume for device with cipher_null.
This commit is contained in:
@@ -2927,7 +2927,9 @@ int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name,
|
|||||||
if (!(dmt_flags & DM_KEY_WIPE_SUPPORTED))
|
if (!(dmt_flags & DM_KEY_WIPE_SUPPORTED))
|
||||||
goto out;
|
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;
|
msg_size = strlen(vk->key_description) + int_log10(vk->keylength) + 18;
|
||||||
else
|
else
|
||||||
msg_size = vk->keylength * 2 + 10; // key set <key>
|
msg_size = vk->keylength * 2 + 10; // key set <key>
|
||||||
@@ -2939,7 +2941,9 @@ int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg, "key set ");
|
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);
|
snprintf(msg + 8, msg_size - 8, ":%zu:logon:%s", vk->keylength, vk->key_description);
|
||||||
else
|
else
|
||||||
hex_key(&msg[8], vk->keylength, vk->key);
|
hex_key(&msg[8], vk->keylength, vk->key);
|
||||||
|
|||||||
12
lib/setup.c
12
lib/setup.c
@@ -3115,9 +3115,15 @@ static int resume_by_volume_key(struct crypt_device *cd,
|
|||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
int digest, r;
|
int digest, r;
|
||||||
|
struct volume_key *zerokey = NULL;
|
||||||
|
|
||||||
/* LUKS2 path only */
|
if (crypt_is_cipher_null(crypt_get_cipher_spec(cd))) {
|
||||||
if (crypt_use_keyring_for_vk(cd) && !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);
|
digest = LUKS2_digest_by_segment(&cd->u.luks2.hdr, CRYPT_DEFAULT_SEGMENT);
|
||||||
if (digest < 0)
|
if (digest < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -3137,6 +3143,8 @@ static int resume_by_volume_key(struct crypt_device *cd,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
crypt_drop_keyring_key(cd, vk);
|
crypt_drop_keyring_key(cd, vk);
|
||||||
|
|
||||||
|
crypt_free_volume_key(zerokey);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user