Skip to content

Commit

Permalink
Allow using key files with BITLK devices
Browse files Browse the repository at this point in the history
Fixes: #1252
  • Loading branch information
vojtechtrefny committed Feb 7, 2024
1 parent 0b3879a commit bcea14e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/tests/dbus-tests/test_70_encrypted.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,5 +786,21 @@ def test_open_close(self):
objects = udisks.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager')
self.assertNotIn(str(crypt_path), objects.keys())

# unlock with keyfile contents
d = dbus.Dictionary(signature='sv')
d['keyfile_contents'] = self.str_to_ay(self.passphrase, False)
crypt_path = self.loop.Unlock("", d,
dbus_interface=self.iface_prefix + '.Encrypted')
self.assertIsNotNone(crypt_path)
crypt_dev = self.bus.get_object(self.iface_prefix, crypt_path)
self.assertIsNotNone(crypt_dev)

dbus_cleartext = self.get_property(self.loop, '.Encrypted', 'CleartextDevice')
dbus_cleartext.assertEqual(str(crypt_path))
dbus_type = self.get_property(self.loop, '.Encrypted', 'HintEncryptionType')
dbus_type.assertEqual("BITLK")

self.loop.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')


del UdisksEncryptedTest # skip UdisksEncryptedTest
4 changes: 2 additions & 2 deletions src/udiskslinuxencrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ handle_unlock (UDisksEncrypted *encrypted,
goto out;
}

/* fallback mechanism: keyfile_contents (for LUKS) -> passphrase -> crypttab_passphrase -> TCRYPT keyfiles -> error (no key) */
if (is_luks && udisks_variant_lookup_binary (options, "keyfile_contents", &effective_passphrase))
/* fallback mechanism: keyfile_contents (for LUKS and BITLK) -> passphrase -> crypttab_passphrase -> TCRYPT keyfiles -> error (no key) */
if ((is_luks || is_bitlk) && udisks_variant_lookup_binary (options, "keyfile_contents", &effective_passphrase))
{
/* effective_passphrase was set to keyfile_contents, nothing more to do here */
}
Expand Down

0 comments on commit bcea14e

Please sign in to comment.