|
Tomas Bzatek |
10280e |
From 9fdf616dd3a1dc8d9c17a7cd48995dd11068eedd Mon Sep 17 00:00:00 2001
|
|
Tomas Bzatek |
10280e |
From: Tomas Bzatek <tbzatek@redhat.com>
|
|
Tomas Bzatek |
10280e |
Date: Thu, 25 May 2023 14:20:05 +0200
|
|
Tomas Bzatek |
10280e |
Subject: [PATCH] LUKS FIPS fixes
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
---
|
|
Tomas Bzatek |
10280e |
src/tests/dbus-tests/test_50_block.py | 8 ++-
|
|
Tomas Bzatek |
10280e |
src/tests/dbus-tests/test_70_encrypted.py | 67 ++++++++++-------------
|
|
Tomas Bzatek |
10280e |
src/tests/integration-test | 30 +++++-----
|
|
Tomas Bzatek |
10280e |
3 files changed, 50 insertions(+), 55 deletions(-)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
diff --git a/src/tests/dbus-tests/test_50_block.py b/src/tests/dbus-tests/test_50_block.py
|
|
Tomas Bzatek |
10280e |
index 2154eea8..09f8fb95 100644
|
|
Tomas Bzatek |
10280e |
--- a/src/tests/dbus-tests/test_50_block.py
|
|
Tomas Bzatek |
10280e |
+++ b/src/tests/dbus-tests/test_50_block.py
|
|
Tomas Bzatek |
10280e |
@@ -12,6 +12,8 @@ import udiskstestcase
|
|
Tomas Bzatek |
10280e |
class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
'''This is a basic block device test suite'''
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
+ LUKS_PASSPHRASE = 'shouldnotseeme'
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
def _close_luks(self, disk):
|
|
Tomas Bzatek |
10280e |
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -241,7 +243,7 @@ class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# format the disk
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
|
|
Tomas Bzatek |
10280e |
- disk.Format('xfs', {'encrypt.passphrase': 'test'}, dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
+ disk.Format('xfs', {'encrypt.passphrase': self.LUKS_PASSPHRASE}, dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# cleanup -- close the luks and remove format
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self.wipe_fs, self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
@@ -249,7 +251,7 @@ class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# configuration items as arrays of dbus.Byte
|
|
Tomas Bzatek |
10280e |
opts = self.str_to_ay('verify')
|
|
Tomas Bzatek |
10280e |
- passwd = self.str_to_ay('test')
|
|
Tomas Bzatek |
10280e |
+ passwd = self.str_to_ay(self.LUKS_PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# set the new configuration
|
|
Tomas Bzatek |
10280e |
conf = dbus.Dictionary({'passphrase-contents': passwd,
|
|
Tomas Bzatek |
10280e |
@@ -294,7 +296,7 @@ class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# format the disk
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
|
|
Tomas Bzatek |
10280e |
- disk.Format('xfs', {'encrypt.passphrase': 'test'}, dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
+ disk.Format('xfs', {'encrypt.passphrase': self.LUKS_PASSPHRASE}, dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# cleanup -- close the luks and remove format
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self.wipe_fs, self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
diff --git a/src/tests/dbus-tests/test_70_encrypted.py b/src/tests/dbus-tests/test_70_encrypted.py
|
|
Tomas Bzatek |
10280e |
index effcceac..2f5a8854 100644
|
|
Tomas Bzatek |
10280e |
--- a/src/tests/dbus-tests/test_70_encrypted.py
|
|
Tomas Bzatek |
10280e |
+++ b/src/tests/dbus-tests/test_70_encrypted.py
|
|
Tomas Bzatek |
10280e |
@@ -40,6 +40,9 @@ def _get_blkid_version():
|
|
Tomas Bzatek |
10280e |
class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
'''This is an encrypted device test suite'''
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
+ PASSPHRASE = 'shouldnotseeme'
|
|
Tomas Bzatek |
10280e |
+ LUKS_NAME = 'myshinylittleluks'
|
|
Tomas Bzatek |
10280e |
+
|
|
Tomas Bzatek |
10280e |
def _create_luks(self, device, passphrase, binary=False):
|
|
Tomas Bzatek |
10280e |
raise NotImplementedError()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -60,7 +63,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
disk_name = os.path.basename(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + disk_name)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- self._create_luks(disk, 'test')
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(disk, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, disk)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -124,7 +127,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
disk_name = os.path.basename(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + disk_name)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- self._create_luks(disk, 'test')
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(disk, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, disk)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -160,11 +163,11 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
# wrong password
|
|
Tomas Bzatek |
10280e |
msg = 'org.freedesktop.UDisks2.Error.Failed: Error unlocking %s *' % self.vdevs[0]
|
|
Tomas Bzatek |
10280e |
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
|
Tomas Bzatek |
10280e |
- disk.Unlock('shbdkjaf', self.no_options,
|
|
Tomas Bzatek |
10280e |
+ disk.Unlock('abcdefghijklmn', self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# right password
|
|
Tomas Bzatek |
10280e |
- luks = disk.Unlock('test', self.no_options,
|
|
Tomas Bzatek |
10280e |
+ luks = disk.Unlock(self.PASSPHRASE, self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(luks)
|
|
Tomas Bzatek |
10280e |
self.assertTrue(os.path.exists('/dev/disk/by-uuid/%s' % luks_uuid))
|
|
Tomas Bzatek |
10280e |
@@ -180,7 +183,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# read-only
|
|
Tomas Bzatek |
10280e |
ro_opts = dbus.Dictionary({'read-only': dbus.Boolean(True)}, signature=dbus.Signature('sv'))
|
|
Tomas Bzatek |
10280e |
- luks = disk.Unlock('test', ro_opts,
|
|
Tomas Bzatek |
10280e |
+ luks = disk.Unlock(self.PASSPHRASE, ro_opts,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(luks)
|
|
Tomas Bzatek |
10280e |
self.assertTrue(os.path.exists('/dev/disk/by-uuid/%s' % luks_uuid))
|
|
Tomas Bzatek |
10280e |
@@ -196,13 +199,10 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
crypttab = self.read_file('/etc/crypttab')
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self.write_file, '/etc/crypttab', crypttab)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- passwd = 'test'
|
|
Tomas Bzatek |
10280e |
- luks_name = 'myshinylittleluks'
|
|
Tomas Bzatek |
10280e |
-
|
|
Tomas Bzatek |
10280e |
disk_name = os.path.basename(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + disk_name)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- self._create_luks(disk, passwd)
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(disk, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, disk)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -212,20 +212,20 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# add new entry to the crypttab
|
|
Tomas Bzatek |
10280e |
- new_crypttab = crypttab + '%s UUID=%s none\n' % (luks_name, disk_uuid)
|
|
Tomas Bzatek |
10280e |
+ new_crypttab = crypttab + '%s UUID=%s none\n' % (self.LUKS_NAME, disk_uuid)
|
|
Tomas Bzatek |
10280e |
self.write_file('/etc/crypttab', new_crypttab)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
dbus_conf = disk.GetSecretConfiguration(self.no_options, dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(dbus_conf)
|
|
Tomas Bzatek |
10280e |
- self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), luks_name)
|
|
Tomas Bzatek |
10280e |
+ self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), self.LUKS_NAME)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# unlock the device
|
|
Tomas Bzatek |
10280e |
- luks = disk.Unlock(passwd, self.no_options,
|
|
Tomas Bzatek |
10280e |
+ luks = disk.Unlock(self.PASSPHRASE, self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(luks)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# unlock should use name from crypttab for the /dev/mapper device
|
|
Tomas Bzatek |
10280e |
- dm_path = '/dev/mapper/%s' % luks_name
|
|
Tomas Bzatek |
10280e |
+ dm_path = '/dev/mapper/%s' % self.LUKS_NAME
|
|
Tomas Bzatek |
10280e |
self.assertTrue(os.path.exists(dm_path))
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# preferred 'device' should be /dev/mapper/name too
|
|
Tomas Bzatek |
10280e |
@@ -240,8 +240,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
crypttab = self.read_file('/etc/crypttab')
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self.write_file, '/etc/crypttab', crypttab)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- passwd = b'test\0test'
|
|
Tomas Bzatek |
10280e |
- luks_name = 'myshinylittleluks'
|
|
Tomas Bzatek |
10280e |
+ passwd = b'testtesttest\0testtesttest'
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# create key file
|
|
Tomas Bzatek |
10280e |
_fd, key_file = tempfile.mkstemp()
|
|
Tomas Bzatek |
10280e |
@@ -262,12 +261,12 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# add new entry to the crypttab
|
|
Tomas Bzatek |
10280e |
- new_crypttab = crypttab + '%s UUID=%s %s\n' % (luks_name, disk_uuid, key_file)
|
|
Tomas Bzatek |
10280e |
+ new_crypttab = crypttab + '%s UUID=%s %s\n' % (self.LUKS_NAME, disk_uuid, key_file)
|
|
Tomas Bzatek |
10280e |
self.write_file('/etc/crypttab', new_crypttab)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
dbus_conf = disk.GetSecretConfiguration(self.no_options, dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(dbus_conf)
|
|
Tomas Bzatek |
10280e |
- self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), luks_name)
|
|
Tomas Bzatek |
10280e |
+ self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), self.LUKS_NAME)
|
|
Tomas Bzatek |
10280e |
self.assertEqual(self.ay_to_str(dbus_conf[0][1]['passphrase-path']), key_file)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# unlock the device using empty passphrase (should use the key file)
|
|
Tomas Bzatek |
10280e |
@@ -276,7 +275,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(luks)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# unlock should use name from crypttab for the /dev/mapper device
|
|
Tomas Bzatek |
10280e |
- dm_path = '/dev/mapper/%s' % luks_name
|
|
Tomas Bzatek |
10280e |
+ dm_path = '/dev/mapper/%s' % self.LUKS_NAME
|
|
Tomas Bzatek |
10280e |
self.assertTrue(os.path.exists(dm_path))
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# preferred 'device' should be /dev/mapper/name too
|
|
Tomas Bzatek |
10280e |
@@ -289,7 +288,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
disk_name = os.path.basename(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + disk_name)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- self._create_luks(disk, 'test')
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(disk, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, disk)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -316,11 +315,11 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
disk_name = os.path.basename(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + disk_name)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- self._create_luks(disk, 'test')
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(disk, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, disk)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- disk.ChangePassphrase('test', 'password', self.no_options,
|
|
Tomas Bzatek |
10280e |
+ disk.ChangePassphrase(self.PASSPHRASE, self.PASSPHRASE + '222', self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
@@ -328,11 +327,11 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
# old password, should fail
|
|
Tomas Bzatek |
10280e |
msg = 'org.freedesktop.UDisks2.Error.Failed: Error unlocking %s *' % self.vdevs[0]
|
|
Tomas Bzatek |
10280e |
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
|
Tomas Bzatek |
10280e |
- disk.Unlock('test', self.no_options,
|
|
Tomas Bzatek |
10280e |
+ disk.Unlock(self.PASSPHRASE, self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# new password
|
|
Tomas Bzatek |
10280e |
- luks = disk.Unlock('password', self.no_options,
|
|
Tomas Bzatek |
10280e |
+ luks = disk.Unlock(self.PASSPHRASE + '222', self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(luks)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -343,7 +342,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
def test_resize(self):
|
|
Tomas Bzatek |
10280e |
device = self.get_device(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
- self._create_luks(device, 'test')
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(device, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, device)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -372,8 +371,6 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
fstab = self.read_file('/etc/fstab')
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self.write_file, '/etc/fstab', fstab)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- passphrase = 'test'
|
|
Tomas Bzatek |
10280e |
-
|
|
Tomas Bzatek |
10280e |
disk_name = os.path.basename(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
disk = self.get_object('/block_devices/' + disk_name)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -384,7 +381,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(part)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# create LUKS on the partition and add it to crypttab
|
|
Tomas Bzatek |
10280e |
- self._create_luks(part, passphrase)
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(part, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
conf = dbus.Dictionary({'name': self.str_to_ay('udisks_luks_test'),
|
|
Tomas Bzatek |
10280e |
@@ -521,10 +518,8 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
|
Tomas Bzatek |
10280e |
super(UdisksEncryptedTestLUKS2, self).setUp()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
def test_resize(self):
|
|
Tomas Bzatek |
10280e |
- passwd = 'test'
|
|
Tomas Bzatek |
10280e |
-
|
|
Tomas Bzatek |
10280e |
device = self.get_device(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
- self._create_luks(device, passwd)
|
|
Tomas Bzatek |
10280e |
+ self._create_luks(device, self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, device)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -550,7 +545,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# right passphrase
|
|
Tomas Bzatek |
10280e |
d = dbus.Dictionary(signature='sv')
|
|
Tomas Bzatek |
10280e |
- d['passphrase'] = passwd
|
|
Tomas Bzatek |
10280e |
+ d['passphrase'] = self.PASSPHRASE
|
|
Tomas Bzatek |
10280e |
device.Resize(dbus.UInt64(100*1024*1024), d,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -559,7 +554,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# resize back to the original size (using binary passphrase)
|
|
Tomas Bzatek |
10280e |
d = dbus.Dictionary(signature='sv')
|
|
Tomas Bzatek |
10280e |
- d['keyfile_contents'] = self.str_to_ay(passwd, False)
|
|
Tomas Bzatek |
10280e |
+ d['keyfile_contents'] = self.str_to_ay(self.PASSPHRASE, False)
|
|
Tomas Bzatek |
10280e |
device.Resize(dbus.UInt64(clear_size), d,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -577,7 +572,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# create LUKS without specifying version
|
|
Tomas Bzatek |
10280e |
options = dbus.Dictionary(signature='sv')
|
|
Tomas Bzatek |
10280e |
- options['encrypt.passphrase'] = 'test'
|
|
Tomas Bzatek |
10280e |
+ options['encrypt.passphrase'] = self.PASSPHRASE
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
disk.Format('xfs', options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Block')
|
|
Tomas Bzatek |
10280e |
@@ -613,14 +608,12 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
|
|
Tomas Bzatek |
10280e |
def test_integrity(self):
|
|
Tomas Bzatek |
10280e |
- passwd = 'test'
|
|
Tomas Bzatek |
10280e |
-
|
|
Tomas Bzatek |
10280e |
cryptsetup_version = _get_cryptsetup_version()
|
|
Tomas Bzatek |
10280e |
if cryptsetup_version < LooseVersion('2.2.0'):
|
|
Tomas Bzatek |
10280e |
self.skipTest('Integrity devices are not marked as internal in cryptsetup < 2.2.0')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
device = self.get_device(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
- self._create_luks_integrity(self.vdevs[0], passwd)
|
|
Tomas Bzatek |
10280e |
+ self._create_luks_integrity(self.vdevs[0], self.PASSPHRASE)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
self.addCleanup(self._remove_luks, device)
|
|
Tomas Bzatek |
10280e |
self.udev_settle()
|
|
Tomas Bzatek |
10280e |
@@ -630,7 +623,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
|
Tomas Bzatek |
10280e |
# the device is not opened, we need to read the UUID from LUKS metadata
|
|
Tomas Bzatek |
10280e |
luks_uuid = BlockDev.crypto_luks_uuid(self.vdevs[0])
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
- luks_path = device.Unlock('test', self.no_options,
|
|
Tomas Bzatek |
10280e |
+ luks_path = device.Unlock(self.PASSPHRASE, self.no_options,
|
|
Tomas Bzatek |
10280e |
dbus_interface=self.iface_prefix + '.Encrypted')
|
|
Tomas Bzatek |
10280e |
self.assertIsNotNone(luks_path)
|
|
Tomas Bzatek |
10280e |
self.assertTrue(os.path.exists('/dev/disk/by-uuid/%s' % luks_uuid))
|
|
Tomas Bzatek |
10280e |
diff --git a/src/tests/integration-test b/src/tests/integration-test
|
|
Tomas Bzatek |
10280e |
index 4499a6a9..71955559 100755
|
|
Tomas Bzatek |
10280e |
--- a/src/tests/integration-test
|
|
Tomas Bzatek |
10280e |
+++ b/src/tests/integration-test
|
|
Tomas Bzatek |
10280e |
@@ -1336,7 +1336,7 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
def setup_crypto_device(self):
|
|
Tomas Bzatek |
10280e |
self.fs_create(None, 'ext4', GLib.Variant('a{sv}', {
|
|
Tomas Bzatek |
10280e |
- 'encrypt.passphrase': GLib.Variant('s', 's3kr1t'),
|
|
Tomas Bzatek |
10280e |
+ 'encrypt.passphrase': GLib.Variant('s', 's3kr1ts3kr1t'),
|
|
Tomas Bzatek |
10280e |
'label': GLib.Variant('s', 'treasure')}))
|
|
Tomas Bzatek |
10280e |
self.client.settle()
|
|
Tomas Bzatek |
10280e |
crypt_obj = self.client.get_object(self.udisks_block().get_object_path())
|
|
Tomas Bzatek |
10280e |
@@ -1347,7 +1347,7 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
@staticmethod
|
|
Tomas Bzatek |
10280e |
def unlock_crypto_device(encrypted):
|
|
Tomas Bzatek |
10280e |
return encrypted.call_unlock_sync(
|
|
Tomas Bzatek |
10280e |
- 's3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
+ 's3kr1ts3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
def tearDown(self):
|
|
Tomas Bzatek |
10280e |
"""clean up behind failed test cases"""
|
|
Tomas Bzatek |
10280e |
@@ -1415,7 +1415,7 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
udev_dump = subprocess.Popen(['udevadm', 'info', '--export-db'],
|
|
Tomas Bzatek |
10280e |
stdout=subprocess.PIPE)
|
|
Tomas Bzatek |
10280e |
out = udev_dump.communicate()[0]
|
|
Tomas Bzatek |
10280e |
- self.assertFalse(b's3kr1t' in out, 'password in udev properties')
|
|
Tomas Bzatek |
10280e |
+ self.assertFalse(b's3kr1ts3kr1t' in out, 'password in udev properties')
|
|
Tomas Bzatek |
10280e |
self.assertFalse(b'essiv:sha' in out, 'key information in udev properties')
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
finally:
|
|
Tomas Bzatek |
10280e |
@@ -1525,18 +1525,18 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
encrypted = self.setup_crypto_device()
|
|
Tomas Bzatek |
10280e |
# wrong password, has bytes after a trailing '\0'
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
- '', Luks.keyfile_options(b's3kr1t\0X'), None)
|
|
Tomas Bzatek |
10280e |
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\0X'), None)
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
- '', Luks.keyfile_options(b's3kr1t\n'), None)
|
|
Tomas Bzatek |
10280e |
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\n'), None)
|
|
Tomas Bzatek |
10280e |
# correct password, specified as keyfile
|
|
Tomas Bzatek |
10280e |
- encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1t'), None)
|
|
Tomas Bzatek |
10280e |
+ encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1ts3kr1t'), None)
|
|
Tomas Bzatek |
10280e |
encrypted.call_lock_sync(no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
def test_plaintext_keyfile(self):
|
|
Tomas Bzatek |
10280e |
"""Setup a device using a plaintext keyfile."""
|
|
Tomas Bzatek |
10280e |
# Using a plaintext keyfile should be equivalent to passphrase
|
|
Tomas Bzatek |
10280e |
self.fs_create(None, 'ext4', GLib.Variant('a{sv}', {
|
|
Tomas Bzatek |
10280e |
- 'encrypt.passphrase': GLib.Variant('ay', _bytes_to_ay(b's3kr1t')),
|
|
Tomas Bzatek |
10280e |
+ 'encrypt.passphrase': GLib.Variant('ay', _bytes_to_ay(b's3kr1ts3kr1t')),
|
|
Tomas Bzatek |
10280e |
'label': GLib.Variant('s', 'treasure')}))
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
crypt_obj = self.client.get_object(self.udisks_block().get_object_path())
|
|
Tomas Bzatek |
10280e |
@@ -1547,16 +1547,16 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
'h4ckpassword', no_options, None)
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
- '', Luks.keyfile_options(b's3kr1t\0X'), None)
|
|
Tomas Bzatek |
10280e |
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\0X'), None)
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
- '', Luks.keyfile_options(b's3kr1t\n'), None)
|
|
Tomas Bzatek |
10280e |
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\n'), None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# correct password
|
|
Tomas Bzatek |
10280e |
- encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1t'), None)
|
|
Tomas Bzatek |
10280e |
+ encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1ts3kr1t'), None)
|
|
Tomas Bzatek |
10280e |
encrypted.call_lock_sync(no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# correct password, specified as passphrase
|
|
Tomas Bzatek |
10280e |
- encrypted.call_unlock_sync('s3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
+ encrypted.call_unlock_sync('s3kr1ts3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
encrypted.call_lock_sync(no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
def test_binary_keyfile(self):
|
|
Tomas Bzatek |
10280e |
@@ -1622,11 +1622,11 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
encrypted = self.setup_crypto_device()
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# change: passphrase -> passphrase
|
|
Tomas Bzatek |
10280e |
- encrypted.call_change_passphrase_sync('s3kr1t', 'passphrase', no_options, None)
|
|
Tomas Bzatek |
10280e |
+ encrypted.call_change_passphrase_sync('s3kr1ts3kr1t', 'passphrase', no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# verify new password:
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
- 's3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
+ 's3kr1ts3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
encrypted.call_unlock_sync('passphrase', no_options, None)
|
|
Tomas Bzatek |
10280e |
encrypted.call_lock_sync(no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
@@ -1659,7 +1659,7 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
# change: keyfile -> passphrase
|
|
Tomas Bzatek |
10280e |
encrypted.call_change_passphrase_sync(
|
|
Tomas Bzatek |
10280e |
- '', 's3kr1t', GLib.Variant('a{sv}', {
|
|
Tomas Bzatek |
10280e |
+ '', 's3kr1ts3kr1t', GLib.Variant('a{sv}', {
|
|
Tomas Bzatek |
10280e |
'old_keyfile_contents': GLib.Variant('ay', _bytes_to_ay(key_file_1)),
|
|
Tomas Bzatek |
10280e |
}),
|
|
Tomas Bzatek |
10280e |
None)
|
|
Tomas Bzatek |
10280e |
@@ -1667,7 +1667,7 @@ class Luks(UDisksTestCase):
|
|
Tomas Bzatek |
10280e |
# verify new password:
|
|
Tomas Bzatek |
10280e |
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
|
Tomas Bzatek |
10280e |
'', Luks.keyfile_options(key_file_1), None)
|
|
Tomas Bzatek |
10280e |
- encrypted.call_unlock_sync('s3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
+ encrypted.call_unlock_sync('s3kr1ts3kr1t', no_options, None)
|
|
Tomas Bzatek |
10280e |
encrypted.call_lock_sync(no_options, None)
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
|
|
Tomas Bzatek |
10280e |
--
|
|
Tomas Bzatek |
10280e |
2.39.1
|
|
Tomas Bzatek |
10280e |
|