nixos: add a lanzaboote module
- Wire up things with Bootspec & External bootloaders - Introduce SecureBoot keys
This commit is contained in:
parent
c53477fbf5
commit
ccdd02bf1c
24
flake.lock
24
flake.lock
|
@ -35,11 +35,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1669001258,
|
||||
"narHash": "sha256-fi0hCUCalMwd+RUi6zUBzNb0ShowaJk+o+p8qtF/Iv4=",
|
||||
"lastModified": 1669207345,
|
||||
"narHash": "sha256-KwfRW0f70Y19EkbB6D9wy7AoYqCYPuIL/2taiJPvuxg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c6e5939c8fa2ab2230baf1378a34746e8db1aed7",
|
||||
"rev": "3ea5616c21dd186129f90a86c66352359a45cb07",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -49,11 +49,11 @@
|
|||
},
|
||||
"nixpkgs-test": {
|
||||
"locked": {
|
||||
"lastModified": 1669200924,
|
||||
"narHash": "sha256-NUPT9VMQHnFRqqd/ILcfMSbOvPTLbVBXGO7SWj0N7Dg=",
|
||||
"lastModified": 1669288333,
|
||||
"narHash": "sha256-PMP3JiUBIYu40gmWAIw+DG2UVsx7m5exGaGxdSQE3ew=",
|
||||
"owner": "RaitoBezarius",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "542f657a93ae903e07d6274de413142c4b99d6ed",
|
||||
"rev": "308e09c57da1df2abeccc236431a2675a2b38555",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -65,11 +65,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1669001258,
|
||||
"narHash": "sha256-fi0hCUCalMwd+RUi6zUBzNb0ShowaJk+o+p8qtF/Iv4=",
|
||||
"lastModified": 1669207345,
|
||||
"narHash": "sha256-KwfRW0f70Y19EkbB6D9wy7AoYqCYPuIL/2taiJPvuxg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c6e5939c8fa2ab2230baf1378a34746e8db1aed7",
|
||||
"rev": "3ea5616c21dd186129f90a86c66352359a45cb07",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -109,11 +109,11 @@
|
|||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1668998422,
|
||||
"narHash": "sha256-G/BklIplCHZEeDIabaaxqgITdIXtMolRGlwxn9jG2/Q=",
|
||||
"lastModified": 1669257187,
|
||||
"narHash": "sha256-NURtNyepbHLrJs2kwsQ9u2SUKhuGU1T9mPkXasG9hpk=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "68ab029c93f8f8eed4cf3ce9a89a9fd4504b2d6e",
|
||||
"rev": "018df6d3f900fc53d567045bd86208f5c00d8956",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
31
flake.nix
31
flake.nix
|
@ -90,8 +90,10 @@
|
|||
# tell lanzatool where to find our UEFI binaries.
|
||||
makeWrapper ${lanzatoolBin}/bin/lanzatool $out/bin/lanzatool \
|
||||
--set PATH ${lib.makeBinPath [ pkgs.binutils-unwrapped ]} \
|
||||
--set RUST_BACKTRACE full \
|
||||
--set LANZABOOTE_STUB ${lanzaboote}/bin/lanzaboote.efi \
|
||||
--set LANZABOOTE_INITRD_STUB ${initrd-stub}/bin/initrd-stub.efi
|
||||
--set LANZABOOTE_INITRD_STUB ${initrd-stub}/bin/initrd-stub.efi \
|
||||
--set SBSIGNTOOL "${pkgs.sbsigntool}/bin/sbsign"
|
||||
'';
|
||||
|
||||
# A script that takes an initrd and turns it into a PE image.
|
||||
|
@ -129,7 +131,8 @@
|
|||
'';
|
||||
in {
|
||||
overlays.default = final: prev: {
|
||||
inherit lanzaboote lanzatool;
|
||||
inherit lanzaboote;
|
||||
lanzatool = lanzatoolBin;
|
||||
};
|
||||
|
||||
nixosModules.lanzaboote = import ./nix/lanzaboote.nix;
|
||||
|
@ -146,6 +149,10 @@
|
|||
lanzatool
|
||||
pkgs.openssl
|
||||
wrapInitrd
|
||||
(pkgs.sbctl.override {
|
||||
databasePath = "pki";
|
||||
})
|
||||
pkgs.sbsigntool
|
||||
];
|
||||
|
||||
inputsFrom = [
|
||||
|
@ -165,10 +172,26 @@
|
|||
imports = [ self.nixosModules.lanzaboote ];
|
||||
nixpkgs.overlays = [ self.overlays.default ];
|
||||
|
||||
boot.lanzaboote.enable = true;
|
||||
virtualisation = {
|
||||
useBootLoader = true;
|
||||
useEFIBoot = true;
|
||||
# useSecureBoot = true;
|
||||
};
|
||||
|
||||
boot.loader.efi = {
|
||||
enable = true;
|
||||
canTouchEfiVariables = true;
|
||||
};
|
||||
boot.lanzaboote = {
|
||||
enable = true;
|
||||
enrollKeys = true;
|
||||
pkiBundle = ./pki/keys;
|
||||
package = lanzatool;
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.start()
|
||||
machine.shutdown()
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, config, ... }:
|
||||
{ lib, config, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.boot.lanzaboote;
|
||||
|
@ -6,12 +6,36 @@ in
|
|||
{
|
||||
options.boot.lanzaboote = {
|
||||
enable = mkEnableOption "Enable the LANZABOOTE";
|
||||
enrollKeys = mkEnableOption "Automatic enrollment of the keys";
|
||||
pkiBundle = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = "PKI bundle containg db, PK, KEK";
|
||||
};
|
||||
publicKeyFile = mkOption {
|
||||
type = types.path;
|
||||
default = if cfg.pkiBundle != null then "${cfg.pkiBundle}/db/db.pem" else null;
|
||||
description = "Public key to sign your boot files";
|
||||
};
|
||||
privateKeyFile = mkOption {
|
||||
type = types.path;
|
||||
default = if cfg.pkiBundle != null then "${cfg.pkiBundle}/db/db.key" else null;
|
||||
description = "Private key to sign your boot files";
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.lanzatool;
|
||||
description = "Lanzatool package";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
boot.loader.external = {
|
||||
enable = true;
|
||||
installHook = "${pkgs.lanzatool}/bin/lanzatool install";
|
||||
passBootspec = true;
|
||||
installHook = if cfg.pkiBundle != null
|
||||
then "${cfg.package}/bin/lanzatool install ${optionalString cfg.enrollKeys "--autoenroll"} --pki-bundle ${cfg.pkiBundle}"
|
||||
else "${cfg.package}/bin/lanzatool install --public-key ${cfg.publicKeyFile} --private-key ${cfg.privateKeyFile}";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDadlSw2a35+y4k
|
||||
oQHp2Un/DUM6e/hIT37jIchplGzlVAPQMGJ2IPW+b9OAn/dRc7D5/w57fYvB02d9
|
||||
J+0K0jc5Po3WMaYnptVtJ03ks/qmlgQm52uZszSeIBiPIdUNQaPxrOPAckR6z6hN
|
||||
gnvB2V3ornI6cpWSZ6LR7cJoNWcPTaVDqWq0mC5XstKt17rnQkkLGfx/4qIb/eUA
|
||||
QXVJx+UJ7zyAN58hAy+Altz41Mn9DMf40B3O3sQJosbXOsiSojUkD5GMQKT0NG0o
|
||||
YRHnGVwZvCHZRRMlw8zMj/lA+tuU4+lBjPIdFhwFu9iBXNSLcJRvvLVF1W0idvYR
|
||||
S+GNce/3PAvkjU+a1LWpfTs0UNyfFoBxry8JbJACNJt8EVY6io2EsoY5upppJWIw
|
||||
x+LsRmx+g+67cVZ5OZuuoI3EXhduBbPxQ3VutygpwrBV7uMABE1Y529CLnbS13yy
|
||||
QR+8k1hUjmJaEyH/Yrqr62P/m4cXqVjvVwXbRVPiVl7DOBUGkwPptzuwHWGUThUB
|
||||
jis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ibRgI74YK+NRD1CYIIf8bh9uROzgjnXUTa4s
|
||||
38GxrwhEF2v5dOyEjohuLdD/yO5e6m424JWytEFB4dldpgH0DNVcsOe7Xj6I6I1c
|
||||
oh+WCgwWqoAXTBNdPMYHWZybQXqhBBIVVtRddzo1ViLsaaDxmaijNKac6JsutNQN
|
||||
f0Zm/uw67lLMfMUtf/jwU9SCWgWSF4S66pohmGfONbGytjk8Str9p+lN0B+rL7IE
|
||||
xM5i9883HpZkFJ1LXvyfz/qJ5KrFOTixgXE/P5+iH7/4PyiAXlCbXpDbwd/ycEGm
|
||||
W5DVThwPtvaXB7g1/WMXgLIlH0/p2yBYqtEAUDpKpFq11uu/D6DctzvzgamTsvND
|
||||
CCDGNK58N6Cfp2IjjzM1sjpJQSDKJvQWnb+bt0MO5zqqi8L7ejEbeSF3imS3JfzY
|
||||
RqA7XR+T8SwdiPqMxR5mXL0Mfk2z95G6znH8DOf2CGxc3X/MLfAW0jvUaPZa
|
||||
-----END CERTIFICATE-----
|
|
@ -0,0 +1,52 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDI6Sqb8P5wucXp
|
||||
LkUKXGkA8liEUeMvlHf9HRBuAp/WumQvLMFYgt2JT+D9za9qr999NdN8r6YXI93e
|
||||
3W4cavcdtIGmcTdE5ACTij7G0KxCZk1C22dfX8pa7iNjuXzOBq0m9XQoLoSsgl/r
|
||||
DHQP4wMC8sUiNqZT9OtRVumXnApvpZO2yVh8xG294nV4mGAAjCPaeYgdYTCPtrtU
|
||||
VWp98/w6luX58QUEId7WU1r9G8aDqlkOG6sLg0+5AQqbKU2V4hzmisyEaSFdPqzx
|
||||
8x4fR02NJIvAIE5Sn0+xfQjC1n9XIhldiXytSiEjtV/fG+c5q3sLIgYzEgEtxP9N
|
||||
357SXApcBPXZB7fjOYveXT36mDPurg7M/86qt0z+Lc7ZlgCpHgkqtl2vSgjP6J4I
|
||||
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BG/orDJrOClvt8qABL60ojnilLh4J5BwGDwBcXE/wETvXb+o3GsjTqqHdXYCQx0
|
||||
e3SpR/xQCfKzuaE4ysaszKFcNbhaezLmo/pzD2v0UA6Jr56re/jkYMtLQL4+LAUP
|
||||
kCH66vc6qETQwtAzV3CYQ5TirwLLD6z3luPhm2FzyXTU9eydbsRp7FuSKq8mVXKP
|
||||
cskrVJSjWD7fOsy/sZq3S+xmA3w1C8XRAgz+xlfIQkuu0mAa3jJ3JGjDyu1lAZ6N
|
||||
oUc897npQ2tpYyGRQ/zOmKSE9oUlcEqXLPk2nDgenhG0oAdM/jJ54rnuR2x3zhBx
|
||||
gyPEvWVzjzX8E//9Kc6VocisnI/tckibUPHlMJFHFBXiU8m6vO28cCRl4tRsH/K9
|
||||
jOnm+ztraiXI7mqBfTchR7Ga0EmnWFf38y3/YkrbVYbjK6o/+/T72Sje0MfCAvTl
|
||||
KLOtvaQWQm36KP/2PH3DZ/k/v8+U76oeUBoI/DDH8E4rR1cUORvUYH8MZyPIKM4e
|
||||
GN3+/zjr5gw70iLC/p8C+8rCzxwoernIMcFlL+SaeybnzXvH3VqO/XAFA/lxMu4V
|
||||
K7Gzrtr5n+FiSTXytdIu18o6Av65XN5hzwQvVeWIx/E5Jry/JlSQgho8CnqLK8g5
|
||||
USdRgvRJN7xJM3szP93f7aNgIYSys2cCxtZxunU=
|
||||
-----END CERTIFICATE-----
|
|
@ -70,6 +70,7 @@ fn install(
|
|||
) -> Result<()> {
|
||||
let lanzaboote_stub = std::env::var("LANZABOOTE_STUB")?;
|
||||
let initrd_stub = std::env::var("LANZABOOTE_INITRD_STUB")?;
|
||||
let sbsigntool = std::env::var("SBSIGNTOOL")?;
|
||||
|
||||
install::install(
|
||||
public_key,
|
||||
|
@ -77,7 +78,8 @@ fn install(
|
|||
pki_bundle,
|
||||
auto_enroll,
|
||||
bootspec,
|
||||
Path::new(&sbsigntool),
|
||||
Path::new(&lanzaboote_stub),
|
||||
Path::new(&initrd_stub),
|
||||
Path::new(&initrd_stub)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use std::fs;
|
||||
use std::str::from_utf8;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
@ -7,12 +9,15 @@ use crate::bootspec::Bootspec;
|
|||
use crate::esp::EspPaths;
|
||||
use crate::pe;
|
||||
|
||||
use crate::signer::Signer;
|
||||
|
||||
pub fn install(
|
||||
_public_key: &Path,
|
||||
_private_key: &Path,
|
||||
public_key: &Path,
|
||||
private_key: &Path,
|
||||
_pki_bundle: &Path,
|
||||
_auto_enroll: bool,
|
||||
bootspec: &Path,
|
||||
sbsigntool: &Path,
|
||||
lanzaboote_stub: &Path,
|
||||
initrd_stub: &Path,
|
||||
) -> Result<()> {
|
||||
|
@ -23,6 +28,7 @@ pub fn install(
|
|||
.context("Failed to parse bootspec json")?;
|
||||
|
||||
let esp_paths = EspPaths::new(&bootspec_doc.extension.esp);
|
||||
let signer = Signer::new(&sbsigntool, &public_key, &private_key);
|
||||
|
||||
println!("Assembling lanzaboote image...");
|
||||
let mut kernel_cmdline: Vec<String> = vec![bootspec_doc
|
||||
|
@ -38,6 +44,7 @@ pub fn install(
|
|||
&kernel_cmdline,
|
||||
&esp_paths.kernel,
|
||||
&esp_paths.initrd,
|
||||
&esp_paths.esp
|
||||
)
|
||||
.context("Failed to assemble stub")?;
|
||||
|
||||
|
@ -54,17 +61,28 @@ pub fn install(
|
|||
.join("lib/systemd/boot/efi/systemd-bootx64.efi");
|
||||
|
||||
let files_to_copy = [
|
||||
(bootspec_doc.kernel, esp_paths.kernel),
|
||||
(wrapped_initrd, esp_paths.initrd),
|
||||
(lanzaboote_image, esp_paths.lanzaboote_image),
|
||||
(systemd_boot.clone(), esp_paths.efi_fallback),
|
||||
(systemd_boot, esp_paths.systemd_boot),
|
||||
(bootspec_doc.kernel, &esp_paths.kernel),
|
||||
(wrapped_initrd, &esp_paths.initrd),
|
||||
(lanzaboote_image, &esp_paths.lanzaboote_image),
|
||||
(systemd_boot.clone(), &esp_paths.efi_fallback),
|
||||
(systemd_boot, &esp_paths.systemd_boot),
|
||||
];
|
||||
|
||||
for (source, target) in files_to_copy {
|
||||
copy(&source, &target)?;
|
||||
}
|
||||
|
||||
// Sign:
|
||||
// - systemd-boot & fallback EFI
|
||||
// - stub
|
||||
// - kernel
|
||||
// - initrd
|
||||
signer.sign_file(&esp_paths.efi_fallback)?;
|
||||
signer.sign_file(&esp_paths.systemd_boot)?;
|
||||
signer.sign_file(&esp_paths.lanzaboote_image)?;
|
||||
signer.sign_file(&esp_paths.kernel)?;
|
||||
signer.sign_file(&esp_paths.initrd)?;
|
||||
|
||||
println!(
|
||||
"Succesfully installed lanzaboote to '{}'",
|
||||
esp_paths.esp.display()
|
||||
|
|
|
@ -3,6 +3,7 @@ mod cli;
|
|||
mod esp;
|
||||
mod install;
|
||||
mod pe;
|
||||
mod signer;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
|
|
|
@ -12,6 +12,7 @@ pub fn assemble_image(
|
|||
kernel_cmdline: &[String],
|
||||
kernel_path: &Path,
|
||||
initrd_path: &Path,
|
||||
esp_mountpoint: &Path
|
||||
) -> Result<PathBuf> {
|
||||
// objcopy copies files into the PE binary. That's why we have to write the contents
|
||||
// of some bootspec properties to disk
|
||||
|
@ -20,8 +21,8 @@ pub fn assemble_image(
|
|||
let initrd_path_file = Path::new("/tmp/initrd_path");
|
||||
|
||||
fs::write(kernel_cmdline_file, kernel_cmdline.join(" "))?;
|
||||
fs::write(kernel_path_file, efi_relative_path_string(kernel_path))?;
|
||||
fs::write(initrd_path_file, efi_relative_path_string(initrd_path))?;
|
||||
fs::write(kernel_path_file, efi_relative_path_string(esp_mountpoint, kernel_path))?;
|
||||
fs::write(initrd_path_file, efi_relative_path_string(esp_mountpoint, initrd_path))?;
|
||||
|
||||
let os_release_offs = stub_offset(lanzaboote_stub)?;
|
||||
|
||||
|
@ -63,9 +64,9 @@ pub fn assemble_image(
|
|||
Ok(lanzaboote_image)
|
||||
}
|
||||
|
||||
fn efi_relative_path_string(path: &Path) -> String {
|
||||
fn efi_relative_path_string(esp_mountpoint: &Path, path: &Path) -> String {
|
||||
let relative_path = path
|
||||
.strip_prefix("esp")
|
||||
.strip_prefix(esp_mountpoint)
|
||||
.expect("Failed to make path relative to esp")
|
||||
.to_owned();
|
||||
let relative_path_string = relative_path
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use std::process::Command;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub struct Signer<'a> {
|
||||
pub sbsigntool: PathBuf,
|
||||
pub private_key: &'a Path,
|
||||
pub public_key: &'a Path
|
||||
}
|
||||
|
||||
impl<'a> Signer<'a> {
|
||||
pub fn new(signer: &Path, public_key: &'a Path, private_key: &'a Path) -> Self {
|
||||
Self {
|
||||
sbsigntool: signer.to_path_buf(),
|
||||
public_key: public_key,
|
||||
private_key: private_key
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sign_file(&self, filepath: &Path) -> Result<()> {
|
||||
let args = vec![
|
||||
String::from("--key"),
|
||||
String::from(self.private_key.to_str().unwrap()),
|
||||
String::from("--cert"),
|
||||
String::from(self.public_key.to_str().unwrap()),
|
||||
String::from(filepath.to_str().unwrap())
|
||||
];
|
||||
|
||||
let status = Command::new(&self.sbsigntool)
|
||||
.args(&args)
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Failed success run `{}` with args `{:?}`",
|
||||
&self.sbsigntool.display(),
|
||||
&args
|
||||
).into());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue