Skip to content

Commit

Permalink
Merge pull request #1344 from vojtechtrefny/main_escrow-backup-passph…
Browse files Browse the repository at this point in the history
…rase-fix

luks/escrow: Only add backup passphrase when asked to
  • Loading branch information
vojtechtrefny authored Feb 27, 2025
2 parents ce03a48 + bdeb2ce commit f997827
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blivet/formats/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ def escrow(self, directory, backup_passphrase):

try:
blockdev.crypto.escrow_device(self.device, self.__passphrase, self.escrow_cert,
directory, backup_passphrase)
directory,
backup_passphrase if self.add_backup_passphrase else None)
except blockdev.CryptoError as e:
raise LUKSError(e)

Expand Down
11 changes: 11 additions & 0 deletions tests/unit_tests/formats_tests/luks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,14 @@ def test_luks_opal(self):
# cipher and key size are not valid for HW encryption only
self.assertEqual(crypto.opal_format.call_args[1]["cipher"], None)
self.assertEqual(crypto.opal_format.call_args[1]["key_size"], 0)

def test_escrow_packet(self):
fmt = LUKS(device="/dev/test", passphrase="passphrase", escrow_cert="/tmp/escrow.crt")
with patch("blivet.devices.lvm.blockdev.crypto") as crypto:
fmt.escrow(directory="/tmp", backup_passphrase="test")
crypto.escrow_device.assert_called_with("/dev/test", "passphrase", "/tmp/escrow.crt", "/tmp", None)

fmt.add_backup_passphrase = True
with patch("blivet.devices.lvm.blockdev.crypto") as crypto:
fmt.escrow(directory="/tmp", backup_passphrase="test")
crypto.escrow_device.assert_called_with("/dev/test", "passphrase", "/tmp/escrow.crt", "/tmp", "test")

0 comments on commit f997827

Please sign in to comment.