Skip to content

Commit

Permalink
Merge pull request #5826 from vojtechtrefny/master_luks-opal
Browse files Browse the repository at this point in the history
Add support for creating LUKS HW-OPAL devices
  • Loading branch information
vojtechtrefny authored Aug 22, 2024
2 parents f7c1d3a + 989f6d0 commit c672868
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
19 changes: 17 additions & 2 deletions pyanaconda/modules/common/structures/partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def __init__(self):
self._escrow_certificate = ""
self._backup_passphrase_enabled = False

self._opal_admin_passphrase = ""

@property
def partitioning_scheme(self) -> Int:
"""The partitioning scheme.
Expand Down Expand Up @@ -255,12 +257,25 @@ def backup_passphrase_enabled(self) -> Bool:
def backup_passphrase_enabled(self, enabled: Bool):
self._backup_passphrase_enabled = enabled

@property
def opal_admin_passphrase(self) -> Str:
"""OPAL admin passphrase to be used when configuring hardware encryption
:return: a string with the OPAL admin passphrase
"""
return self._opal_admin_passphrase

@opal_admin_passphrase.setter
def opal_admin_passphrase(self, value: Str):
self._opal_admin_passphrase = value

def __repr__(self):
"""Generate a string representation."""
return generate_string_from_data(
self,
skip=["passphrase"],
add={"passphrase_set": bool(self.passphrase)}
skip=["passphrase", "opal_admin_passphrase"],
add={"passphrase_set": bool(self.passphrase),
"opal_admin_passphrase_set": bool(self.opal_admin_passphrase)}
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def process_kickstart(self, data):
request.escrow_certificate = data.autopart.escrowcert
request.backup_passphrase_enabled = data.autopart.backuppassphrase

request.opal_admin_passphrase = data.autopart.hw_passphrase

self.set_request(request)

def setup_kickstart(self, data):
Expand Down Expand Up @@ -123,6 +125,9 @@ def setup_kickstart(self, data):
data.autopart.escrowcert = self.request.escrow_certificate
data.autopart.backuppassphrase = self.request.backup_passphrase_enabled

# Don't generate sensitive information.
data.autopart.hw_passphrase = ""

@property
def request(self):
"""The partitioning request."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def _get_luks_format_args(storage, request):
"pbkdf_args": pbkdf_args,
"escrow_cert": escrow_cert,
"add_backup_passphrase": request.backup_passphrase_enabled,
"opal_admin_passphrase": request.opal_admin_passphrase,
}

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ def _execute_partition_data(self, storage, data, partition_data):
escrow_cert=cert,
add_backup_passphrase=partition_data.backuppassphrase,
luks_version=partition_data.luks_version,
pbkdf_args=pbkdf_args
pbkdf_args=pbkdf_args,
opal_admin_passphrase=partition_data.hw_passphrase,
)
luksdev = LUKSDevice(
"luks%d" % storage.next_id,
Expand All @@ -426,7 +427,8 @@ def _execute_partition_data(self, storage, data, partition_data):
escrow_cert=cert,
add_backup_passphrase=partition_data.backuppassphrase,
luks_version=partition_data.luks_version,
pbkdf_args=pbkdf_args
pbkdf_args=pbkdf_args,
opal_admin_passphrase=partition_data.hw_passphrase,
)
luksdev = LUKSDevice("luks%d" % storage.next_id,
fmt=luksformat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_request_property(self):
'pbkdf-iterations': get_variant(Int, 1000),
'escrow-certificate': get_variant(Str, 'file:///tmp/escrow.crt'),
'backup-passphrase-enabled': get_variant(Bool, True),
'opal-admin-passphrase': get_variant(Str, '123456'),
}
self._check_dbus_property(
"Request",
Expand Down Expand Up @@ -200,6 +201,7 @@ def test_luks1_format_args(self):
request.cipher = "aes-xts-plain64"
request.escrow_certificate = "file:///tmp/escrow.crt"
request.backup_passphrase_enabled = True
request.opal_admin_passphrase = "passphrase"

args = AutomaticPartitioningTask._get_luks_format_args(storage, request)
assert args == {
Expand All @@ -209,6 +211,7 @@ def test_luks1_format_args(self):
"pbkdf_args": None,
"escrow_cert": "CERTIFICATE",
"add_backup_passphrase": True,
"opal_admin_passphrase": "passphrase",
}

def test_luks2_format_args(self):
Expand All @@ -231,6 +234,7 @@ def test_luks2_format_args(self):
"luks_version": "luks2",
"escrow_cert": None,
"add_backup_passphrase": False,
"opal_admin_passphrase": "",
}

assert isinstance(pbkdf_args, LUKS2PBKDFArgs)
Expand Down

0 comments on commit c672868

Please sign in to comment.