feat: measure pcr 15

This commit is contained in:
Patrick 2025-01-14 22:20:08 +01:00
parent b56559ce21
commit 244e930b21
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
4 changed files with 56 additions and 1 deletions

View file

@ -20,6 +20,7 @@
../../modules/deterministic-ids.nix ../../modules/deterministic-ids.nix
../../modules/distributed-config.nix ../../modules/distributed-config.nix
../../modules/ensure-pcr.nix
../../modules/globals.nix ../../modules/globals.nix
../../modules/meta.nix ../../modules/meta.nix
../../modules/iwd.nix ../../modules/iwd.nix

View file

@ -65,4 +65,12 @@
}; };
}; };
}; };
boot.initrd.luks.devices.rpool_m2-ssd.crypttabExtraOpts = [
"tpm2-device=auto"
"tpm2-measure-pcr=yes"
];
boot.initrd.luks.devices.panzer_sata-hdd.crypttabExtraOpts = [
"tpm2-device=auto"
"tpm2-measure-pcr=yes"
];
} }

View file

@ -1,5 +1,11 @@
{ config, lib, ... }:
{ {
config,
lib,
pkgs,
...
}:
{
disko.devices = { disko.devices = {
disk = { disk = {
m2-ssd = rec { m2-ssd = rec {
@ -27,4 +33,31 @@
}; };
fileSystems."/state".neededForBoot = true; fileSystems."/state".neededForBoot = true;
fileSystems."/persist".neededForBoot = true; fileSystems."/persist".neededForBoot = true;
boot.initrd.systemd.extraBin = {
jq = lib.getExe pkgs.jq;
};
# In ermergency shell type:
# ´systemctl disable check-pcrs´
# ´systemctl default´
# to continue booting
boot.initrd.systemd.services.check-pcrs = {
script = ''
echo "Checking PCRS tag: ctiectie"
if [[ $(systemd-analyze pcrs 15 --json=short | jq -r ".[0].sha256") != "a8cfdc8ec869f9edf4635129ba6bb19a076a5d234655cf4684286dc57e325a38" ]] ; then
echo "PCR 15 contains invalid hash"
exit 1
else
echo "PCR 15 checked"
fi
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
unitConfig.DefaultDependencies = "no";
after = [ "cryptsetup.target" ];
before = [ "sysroot.mount" ];
requiredBy = [ "sysroot.mount" ];
};
} }

13
modules/ensure-pcr.nix Normal file
View file

@ -0,0 +1,13 @@
{ lib, ... }:
{
options.boot.initrd.luks.devices = lib.mkOption {
type =
with lib.types;
attrsOf (submodule {
config.crypttabExtraOpts = [
"tpm2-device=auto"
"tpm2-measure-pcr=yes"
];
});
};
}