Skip to content

Commit 4fe1601

Browse files
committed
bitlocker: Open bitlocker devices with clearkey
Always trying to open with clearkey when available
1 parent 72173b2 commit 4fe1601

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

lib/setup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5921,7 +5921,7 @@ int crypt_volume_key_get_by_keyslot_context(struct crypt_device *cd,
59215921
struct volume_key *vk = NULL;
59225922

59235923
if (!cd || !volume_key || !volume_key_size ||
5924-
(!kc && !isLUKS(cd->type) && !isTCRYPT(cd->type) && !isVERITY(cd->type)))
5924+
(!kc && !isLUKS(cd->type) && !isTCRYPT(cd->type) && !isVERITY(cd->type) && !isBITLK(cd->type)))
59255925
return -EINVAL;
59265926

59275927
if (isLUKS2(cd->type) && keyslot != CRYPT_ANY_SLOT)
@@ -5981,6 +5981,8 @@ int crypt_volume_key_get_by_keyslot_context(struct crypt_device *cd,
59815981
} else if (isBITLK(cd->type)) {
59825982
if (kc && kc->get_bitlk_volume_key)
59835983
r = kc->get_bitlk_volume_key(cd, kc, &cd->u.bitlk.params, &vk);
5984+
else if (!kc)
5985+
r = BITLK_get_volume_key(cd, NULL, 0, &cd->u.bitlk.params, &vk);
59845986
if (r < 0)
59855987
log_err(cd, _("Cannot retrieve volume key for BITLK device."));
59865988
} else if (isFVAULT2(cd->type)) {

src/cryptsetup.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ static int action_open_bitlk(void)
509509
r = crypt_activate_by_volume_key(cd, activated_name,
510510
key, keysize, activate_flags);
511511
} else {
512+
r = crypt_activate_by_passphrase(cd, activated_name, CRYPT_ANY_SLOT, NULL, 0, activate_flags);
513+
if (r != -EPERM)
514+
goto out;
515+
512516
tries = set_tries_tty(false);
513517
do {
514518
r = tools_get_key(NULL, &password, &passwordLen,
@@ -617,14 +621,19 @@ static int bitlkDump_with_volume_key(struct crypt_device *cd)
617621
if (!vk)
618622
return -ENOMEM;
619623

620-
r = tools_get_key(NULL, &password, &passwordLen,
621-
ARG_UINT64(OPT_KEYFILE_OFFSET_ID), ARG_UINT32(OPT_KEYFILE_SIZE_ID), ARG_STR(OPT_KEY_FILE_ID),
622-
ARG_UINT32(OPT_TIMEOUT_ID), 0, 0, cd);
623-
if (r < 0)
624-
goto out;
625-
626624
r = crypt_volume_key_get(cd, CRYPT_ANY_SLOT, vk, &vk_size,
627-
password, passwordLen);
625+
password, passwordLen);
626+
if (r < 0) {
627+
r = tools_get_key(NULL, &password, &passwordLen,
628+
ARG_UINT64(OPT_KEYFILE_OFFSET_ID), ARG_UINT32(OPT_KEYFILE_SIZE_ID), ARG_STR(OPT_KEY_FILE_ID),
629+
ARG_UINT32(OPT_TIMEOUT_ID), 0, 0, cd);
630+
if (r < 0)
631+
goto out;
632+
633+
r = crypt_volume_key_get(cd, CRYPT_ANY_SLOT, vk, &vk_size,
634+
password, passwordLen);
635+
}
636+
628637
tools_passphrase_msg(r);
629638
check_signal(&r);
630639
if (r < 0)

0 commit comments

Comments
 (0)