kairos/tests/keys
Dimitris Karakasilis 19919bc581
Test that after-reset is run when in UKI mode (#2331)
* Test that after-reset is run when in UKI mode

Depends on this: https://github.com/kairos-io/kairos-agent/pull/245

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Select recovery boot entry correctly

and add "debug" and "strict" to the uki-install config yaml

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Rename db.* uki keys so that latest enki finds them

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Print debug output (because test fails only in CI)

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Use the correct config for uki tests

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Remove debug output (found the issue)

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

---------

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2024-03-27 14:22:45 +02:00
..
db.auth Test that after-reset is run when in UKI mode (#2331) 2024-03-27 14:22:45 +02:00
db.der Test that after-reset is run when in UKI mode (#2331) 2024-03-27 14:22:45 +02:00
db.esl Test that after-reset is run when in UKI mode (#2331) 2024-03-27 14:22:45 +02:00
db.key Test that after-reset is run when in UKI mode (#2331) 2024-03-27 14:22:45 +02:00
db.pem Test that after-reset is run when in UKI mode (#2331) 2024-03-27 14:22:45 +02:00
KEK.auth [uki] Provide proper artifacts for auto-key-enrollment (#2172) 2024-01-25 14:31:15 +01:00
KEK.der Improve uki iso stuff (#1854) 2023-10-03 22:00:55 +02:00
KEK.esl [uki] Provide proper artifacts for auto-key-enrollment (#2172) 2024-01-25 14:31:15 +01:00
KEK.key Improve uki iso stuff (#1854) 2023-10-03 22:00:55 +02:00
KEK.pem bump enki (#2185) 2024-01-25 20:39:02 +01:00
PK.auth [uki] Provide proper artifacts for auto-key-enrollment (#2172) 2024-01-25 14:31:15 +01:00
PK.der Improve uki iso stuff (#1854) 2023-10-03 22:00:55 +02:00
PK.esl [uki] Provide proper artifacts for auto-key-enrollment (#2172) 2024-01-25 14:31:15 +01:00
PK.key Improve uki iso stuff (#1854) 2023-10-03 22:00:55 +02:00
PK.pem bump enki (#2185) 2024-01-25 20:39:02 +01:00
README.md [uki] Provide proper artifacts for auto-key-enrollment (#2172) 2024-01-25 14:31:15 +01:00
tpm2-pcr-private.pem [UKI] Measure (#2028) 2023-12-20 11:20:10 +01:00

This are TEST keys, used for development purposes.

You can install this keys on a VM EFI and test secureboot.

They are pregenerated so you can iterate building Kairos UKI EFI and use the same signature without generating keys all the time.

They should never be installed anywhere different than a VM.

Sets of keys:

*.key - Private key *.crt - Certificate *.der - Public certificate in DER format. Can be used to manually add the entries to the EFI database. *.esl - EFI Signature List. *.auth - SIGNED EFI Signature List. Can be used by systemd-boot to automatically add the entries to the EFI database.

So for a EFI firmware to trust Kairos UKI EFI, you need to add the following entries to the EFI database depending of its state.

Setup mode (No keys installed, no PK key installed) systemd-boot will auto-add the following keys on the first boot and reset the system to continue booting:

  • PK: PK.auth
  • KEK: KEK.auth
  • DB: DB.auth

Adding secureboot keys manually to edk2 firmware: Adding secureboot keys manually to edk2 firmware

User mode (PK key installed, other certs already in there) you need to manually add the following keys in the firmware:

  • KEK: KEK.der
  • DB: DB.der

Auto secureBoot key enrollment via systemd-boot: Auto secureBoot key enrollment via systemd-boot

Generate keys from scratch (key+pem+der+esl)

uuid=$(uuidgen -N kairos --namespace @dns --sha1)
for key in PK KEK DB; do
  openssl req -new -x509 -subj "/CN=${key}/" -keyout "${key}.key" -out "${key}.pem"
  openssl x509 -outform DER -in "${key}.pem" -out "${key}.der"
  sbsiglist --owner "${uuid}" --type x509 --output "${key}.esl" "${key}.der"
done

Generate auth files for systemd-boot auto-enrollment

## Generate the auth files from the esl files by signing them.
attr=NON_VOLATILE,RUNTIME_ACCESS,BOOTSERVICE_ACCESS,TIME_BASED_AUTHENTICATED_WRITE_ACCESS
sbvarsign --attr "${attr}" --key PK.key --cert PK.crt --output PK.auth PK PK.esl
sbvarsign --attr "${attr}" --key PK.key --cert PK.crt --output KEK.auth KEK KEK.esl
sbvarsign --attr "${attr}" --key KEK.key --cert KEK.crt --output DB.auth DB DB.esl