LUKS encryption using CEX in an IBM Z or IBM LinuxONE environment
Enabling hardware-based Linux Unified Key Setup (LUKS) encryption via IBM Crypto Express (CEX) in an IBM Z or IBM LinuxONE environment for Red Hat OpenShift cluster setups.
LUKS is a standardized way to encrypt block devices on Linux systems. The CEX based LUKS encryption is similar to the existing LUKS encryption offered by x86 architecture using a TPM device or Network Bound Disk Encryption (NBDE) using Clevis utility in Ignition. The difference is CEX enabled LUKS encryption does not require Clevis utility. The Clevis utility only manages the passphrase that is used to encrypt/decrypt a LUKS device either through TPM device or NBDE.
Protected Key is a data-encrypting key that itself is encrypted by a The resulting encrypted key cannot be shared with another LPAR because the wrapping key is unique. In the case of Linux in a native LPAR, the wrapping key is specific to the LPAR. However, for guests of z/VM or KVM, the wrapping key is specific to the guest.
The IBM Z platform offers cryptographic engines that provide high-speed cryptographic operations. CEX (Crypto Express Adapter) are required to generate the secure keys that are stored in the key repository. They are also required to generate protected keys from secure keys for Linux on Z data at-rest encryption.
Crypto Express adapters are tamper-responding hardware security modules (HSM), which provide high security, high throughput cryptographic functions. The Crypto Express adapter adds a layer of protection for the
Refer the following diagram.
This article explains how to configure LUKS-encrypted root volume for Red Hat OpenShift clusters deployed on z/VM and KVM, with support for both FCP and DASD devices.
-
All installed Crypto Express adapter must be loaded with master key before the installation.
-
For Linux on Z data at-rest encryption, the Crypto Express adapter must be configured as Common Cryptographic Architecture (CCA) coprocessor.
CCA Adapter must be >= CEX6C
The latest Butane utility must be installed on the Linux instance that has administrative access to the OCP cluster.
The OpenShift version must be >= 4.19
Make sure that all the cluster nodes have at least one CEX card configured. For redundancy multiple cex cards can be configured.
In the z/VM based installation assign the crypto adapter to appropriate VM before the installation. The following screenshot explains the cards assigned to VMs.
The assignments can be queried with the command: Refer IBM zVM-command
For configuring the crypto card in KVM on IBM Z or IBM LinuxONE, the following way we can create the vfio_ap pass through device.
-
The video illustrates the process of attaching a vfio_ap passthrough device and configuring it to remain persistent across reboots of the KVM host.
The following video illustrates the steps you must perform on the KVM host and in a virtual server
Follow the IBM documentation VFIO_AP
The example script configures the mediated device for the CEX adapter which does not create a persistent mediated device and assumes the adapter is 0x00.
Update the domain appropriate from the output of lszcrypt –V. If you need additional adapters, add the uuid:domain in the data field, as comma-separated values. Eg data="68cd2d83-3eef-4e45-b22c-534f90b16cb9:0x0035"
echo "Setting vfio_ap and reseting the adapter"
echo 0x0 > /sys/bus/ap/apmask
echo 0x0 > /sys/bus/ap/aqmask
echo "Started configure the adapter"
#UUID can be generated from uuidgen command domain can be obtained from lszcrypt -V command.
#Generate the UUID corresponding to the available CEX domain.
data="68cd2d83-3eef-4e45-b22c-534f90b16cb9:0x0035,ba3f873c-3022-4534-9072-eb0d4530b137:0x0036,610e4724-c8c1-45ed-a498-ccfdadc1f2ca:0x0037,5c84eefb-cb45-4519-86d3-ba23e65e8896:0x0038,60cf6ec4-2741-44e2-84d2-0746f133db16:0x0039"
IFS=',' read -ra pairs <<< "$data"
for pair in "${pairs[@]}"
IFS=':' read -r uuid domain <<< "$pair"
echo ${uuid} > /sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/create
echo 0x00 > /sys/devices/vfio_ap/matrix/"${uuid}"/assign_adapter
echo "${domain}" > /sys/devices/vfio_ap/matrix/"${uuid}"/assign_domain
cat /sys/devices/vfio_ap/matrix/"${uuid}"/matrix
To enable LUKS in OpenShift, an additional manifest must be created and included as part of the installation process.
In OpenShift Container Platform, RHCOS images are initially configured using a feature called Ignition, which runs only during the system’s first boot. After this initial boot, RHCOS nodes are managed by the Machine Config Operator (MCO) within the OpenShift cluster.
Ignition is the utility responsible for manipulating disks during initial setup. It performs common disk-related tasks such as partitioning, formatting, writing files, and configuring users. On first boot, Ignition reads its configuration from the installation media or another specified location and applies it to the machine.
The following procedure describes how to create a Machine Config for preparing LUKS encryption using the Butane utility.
The Machine Config files generated by Butane must be placed in the OCP installation directory.
DASD device butane config.
Following the butane sugar for dasd device 99-master-machineconfig.bu
name: master-luks-storage (1)
machineconfiguration.openshift.io/role: master
- rd.luks.key=/etc/luks/cex.key (3)
-
Update the name for master as well as worker
-
This enables FIPS from ignition.
-
Mandatory kargs for CEX based luks encryption. Omitting the kargs prevents system boot.
-
Layout specifies the architecture, e.g., x86_64, arch64, ppc64 etc.
In s390x we have three device specific sugar a) s390x-eckd (For DASD) s390x-zfcp (For FCP) and s390x-virt (For zKVM)
-
Specify the device name as dasda or dasdb, ....
-
This enables the CEX based Luks encryption.
Convert the above butane config to an ignition- compatible file.
[root@linux ~]# butane --strict 99-master-machineconfig.bu -o 99-master-luks-machineconfig.yaml
The following shows the converted butane config to ignition.
[root@linux ~]# cat 99-master-luks-machineconfig.yaml
# Generated by Butane; do not edit
apiVersion: machineconfiguration.openshift.io/v1
machineconfiguration.openshift.io/role: master
name: master-luks-storage
- device: /dev/mapper/root
- rd.luks.key=/etc/luks/cex.key
Copy this Ignition files to the installation directory before creating the ignition config.
[root@linux ~]# cp 99-master-luks-machineconfig.yaml /root/ocp4_workdir/openshift
FCP device butane config.
Note: There is an issue with butane sugar for `s390x-zfcp` fails on multipath enabled system. An issue is being raised to follow up. Until the issue is fixed we use the manual method to convert to ignition config described in "FCP device butane config".
[root@linux ~] # cat 99-master-luks-machineconfig.bu
name: master-luks-storage
machineconfiguration.openshift.io/role: master
- rd.luks.key=/etc/luks/cex.key
- device: /dev/mapper/root
device: /dev/disk/by-label/root
[root@linux ]# butane --strict 99-master-luks-machineconfig.bu -o 99-master-luks-machineconfig.yaml
[root@linux ]# cat 99-master-luks-machineconfig.yaml
# Generated by Butane; do not edit
apiVersion: machineconfiguration.openshift.io/v1
machineconfiguration.openshift.io/role: master
name: 99-master-s390x-cex-luks-config
- device: /dev/mapper/root
device: /dev/disk/by-label/root
- rd.luks.key=/etc/luks/cex.key
Virtual device butane config.
[root@linux ~]# cat 99-master-luks-machineconfig.bu
name: master-luks-storage
machineconfiguration.openshift.io/role: master
- rd.luks.key=/etc/luks/cex.key
[root@linux ~]# butane --strict 99-master-luks-machineconfig.bu -o 99-master-luks-machineconfig.yaml
[root@linux ~]# cat 99-master-luks-machineconfig.yaml
# Generated by Butane; do not edit
apiVersion: machineconfiguration.openshift.io/v1
machineconfiguration.openshift.io/role: master
name: master-luks-storage
- device: /dev/mapper/root
device: /dev/disk/by-partlabel/root
- rd.luks.key=/etc/luks/cex.key
The screenshot below shows the successful installation of OCP with a LUKS-encrypted root volume using the Crypto Express Card. Notably, the cipher used for this LUKS encryption is paes-xts-plain64, and the Tokens section confirms that the PAES verification pattern was completed.
Verify after the installation in DASD/FCP/Virt
[root@linux ~] # oc debug nodes/<node_name>
[root@linux ~] # chroot /host
[root@linux ~] # lsblk –f # list the devices which shows the LUKS device.
[root@linux ~] # cryptsetup luksDump /dev/dasda2 # It shows the header information of LUKS device.
Verify after the installation in FCP.
This article explained how to leverage the IBM Crypto Express Card for root volume LUKS encryption in OCP. The layer of security it provides. The usage of CEX card on different storage device.
For more information on CEX and OCP.
https://www.ibm.com/docs/en/linux-on-systems?topic=setup-crypto