Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
xyakimo1 committed Sep 30, 2024
1 parent 63f3d95 commit cebdabc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/python/gi/overrides/BlockDev.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def __init__(self, *args, **kwargs): # pylint: disable=unused-argument
__all__.append("CryptoKeyslotContext")

class CryptoLUKSReencryptParams(BlockDev.CryptoLUKSReencryptParams):
def __new__(cls, key_size, cipher, cipher_mode, resilience="checksum" , hash="sha256", max_hotzone_size=0, sector_size=4096, new_volume_key=True, offline=False, pbkdf=None):
def __new__(cls, key_size, cipher, cipher_mode, resilience="checksum" , hash="sha256", max_hotzone_size=0, sector_size=512, new_volume_key=True, offline=False, pbkdf=None):
if pbkdf is None:
pbkdf = CryptoLUKSPBKDF()
ret = BlockDev.CryptoLUKSReencryptParams.new(key_size=key_size, cipher=cipher, cipher_mode=cipher_mode, resilience=resilience, hash=hash, max_hotzone_size=max_hotzone_size, sector_size=sector_size, new_volume_key=new_volume_key, offline=offline, pbkdf=pbkdf)
Expand Down
21 changes: 19 additions & 2 deletions tests/crypto_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,15 +1206,16 @@ def test_convert_luks2_to_luks2_fails(self):

class CryptoTestReencrypt(CryptoTestCase):

def _luks_reencrypt(self, device, ctx, offline, new_volume_key=True, prog_func=None, requested_mode="cbc-essiv:sha256"):
def _luks_reencrypt(self, device, ctx, offline, new_volume_key=True, prog_func=None, requested_mode="cbc-essiv:sha256", sector_size=512):
mode_before = BlockDev.crypto_luks_info(device).mode

params = BlockDev.CryptoLUKSReencryptParams(
key_size=256,
cipher="aes",
cipher_mode=requested_mode,
offline=offline,
new_volume_key=new_volume_key
new_volume_key=new_volume_key,
sector_size=sector_size
)

succ = BlockDev.crypto_luks_reencrypt(device, params, ctx, prog_func)
Expand All @@ -1232,6 +1233,22 @@ def test_offline_reencryption(self):

self._luks_reencrypt(device=self.loop_dev, ctx=ctx, offline=True)

@tag_test(TestTags.SLOW, TestTags.CORE)
def test_sector_size_change(self):
""" Verify that sector size can be changed during reencryption """
self._luks2_format(self.loop_dev, PASSWD)
ctx = BlockDev.CryptoKeyslotContext(passphrase=PASSWD)

info = BlockDev.crypto_luks_info(self.loop_dev)
self.assertIsNotNone(info)
self.assertEqual(info.sector_size, 512)

self._luks_reencrypt(device=self.loop_dev, ctx=ctx, offline=True, sector_size=4096)

info = BlockDev.crypto_luks_info(self.loop_dev)
self.assertIsNotNone(info)
self.assertEqual(info.sector_size, 4096)

@tag_test(TestTags.SLOW, TestTags.CORE)
def test_online_reencryption(self):
""" Verify that online reencryption works """
Expand Down

0 comments on commit cebdabc

Please sign in to comment.