Skip to content

Commit

Permalink
Rename "opal_passphrase" to "opal_admin_passphrase"
Browse files Browse the repository at this point in the history
To make the naming consistent with the other projects.
  • Loading branch information
vojtechtrefny committed Aug 9, 2024
1 parent 319e6a6 commit bf401c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions blivet/formats/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def __init__(self, **kwargs):
:type luks_sector_size: int
:keyword subsystem: LUKS subsystem
:type subsystem: str
:keyword opal_passphrase: OPAL admin passphrase
:type opal_passphrase: str
:keyword opal_admin_passphrase: OPAL admin passphrase
:type opal_admin_passphrase: str
.. note::
Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(self, **kwargs):
if self.luks_sector_size and self.luks_version != "luks2":
raise ValueError("Sector size argument is valid only for LUKS version 2.")

self.__opal_passphrase = kwargs.get("opal_passphrase")
self.__opal_admin_passphrase = kwargs.get("opal_admin_passphrase")

def __repr__(self):
s = DeviceFormat.__repr__(self)
Expand Down Expand Up @@ -229,11 +229,11 @@ def _set_passphrase(self, passphrase):

passphrase = property(fset=_set_passphrase)

def _set_opal_passphrase(self, opal_passphrase):
def _set_opal_admin_passphrase(self, opal_admin_passphrase):
""" Set the OPAL admin passphrase for this device. """
self.__opal_passphrase = opal_passphrase
self.__opal_admin_passphrase = opal_admin_passphrase

opal_passphrase = property(fset=_set_opal_passphrase)
opal_admin_passphrase = property(fset=_set_opal_admin_passphrase)

@property
def has_key(self):
Expand Down Expand Up @@ -390,9 +390,9 @@ def _create(self, **kwargs):
raise LUKSError("Passphrase or key file must be set for LUKS create")

if self.is_opal:
if not self.__opal_passphrase:
if not self.__opal_admin_passphrase:
raise LUKSError("OPAL admin passphrase must be specified when creating LUKS HW-OPAL format")
opal_context = blockdev.CryptoKeyslotContext(passphrase=self.__opal_passphrase)
opal_context = blockdev.CryptoKeyslotContext(passphrase=self.__opal_admin_passphrase)

try:
if self.is_opal:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/formats_tests/luks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_luks_opal(self):
self.assertTrue(fmt.is_opal)
self.assertTrue(fmt.protected)

fmt = LUKS(luks_version="luks2-hw-opal", passphrase="passphrase", opal_passphrase="passphrase")
fmt = LUKS(luks_version="luks2-hw-opal", passphrase="passphrase", opal_admin_passphrase="passphrase")
with patch("blivet.devicelibs.crypto.calculate_luks2_max_memory", return_value=None):
with patch("blivet.devicelibs.crypto.get_optimal_luks_sector_size", return_value=512):
with patch("blivet.devices.lvm.blockdev.crypto") as crypto:
Expand All @@ -151,7 +151,7 @@ def test_luks_opal(self):
self.assertEqual(crypto.opal_format.call_args[1]["cipher"], "aes-xts-plain64")
self.assertEqual(crypto.opal_format.call_args[1]["key_size"], 512)

fmt = LUKS(luks_version="luks2-hw-opal-only", passphrase="passphrase", opal_passphrase="passphrase")
fmt = LUKS(luks_version="luks2-hw-opal-only", passphrase="passphrase", opal_admin_passphrase="passphrase")
with patch("blivet.devicelibs.crypto.calculate_luks2_max_memory", return_value=None):
with patch("blivet.devicelibs.crypto.get_optimal_luks_sector_size", return_value=512):
with patch("blivet.devices.lvm.blockdev.crypto") as crypto:
Expand Down

0 comments on commit bf401c7

Please sign in to comment.