Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luks/escrow: Only add backup passphrase when asked to #1344

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Loading