1039 Commits
Author SHA1 Message Date
Thierry Laurion 0152068517 fix tpmr.sh: use tpm_owner_passphrase from prompt function
The prompt_tpm_owner_password() function sets tpm_owner_passphrase variable,
but tpm2_seal was using an unset tpm_owner_password variable instead.
This caused evictcontrol to fail with auth error (0x9A2) since no passphrase
was being passed to the TPM command.

Also standardizes all user-facing strings and variables to use 'passphrase'
instead of 'password' for TPM owner auth, including the cache file path.

Fixes regression introduced in commit 16648ca4b9.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 21:13:23 -04:00
Thierry Laurion e567b1282b mount-usb: auto-select LUKS partition when passphrase is provided
When a passphrase is supplied (--pass) and multiple USB partitions are
present, scan for the one LUKS partition and mount it automatically.
This removes the need for the user to manually pick the correct partition
when using the GPG key-material backup thumb drive, which always has two
partitions: a LUKS-encrypted private partition and an exFAT public one.

If exactly one LUKS partition is found it is selected silently; if zero
or more than one LUKS partition is found the existing interactive menu
is shown as before, so the behavior is unchanged for all other cases.

Remove the now-redundant WARN in cache_gpg_signing_pin that instructed
the user to select the encrypted LUKS partition manually.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:43:18 -04:00
Thierry Laurion c8ed01270d recovery: clear secrets inside while loop to force PIN re-prompt on shell respawn
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:43:12 -04:00
Thierry Laurion 3ca84e5ce8 oem-factory-reset: improve dongle-aware UX, fix GPG operations, label NK3 Secrets app PIN
- Auto-adjust RSA key size based on dongle type; show firmware version
  before reset; add firmware-aware RSA keygen timing guidance
- Fix GPG signing failure by clearing scdaemon CCID lock before signing
- Fix keytocard 'Invalid command': remove spurious echo arguments from
  RSA subkey generation and keytocard operations (scdaemon caches card
  admin PIN after first keytocard; stale ADMIN_PIN_DEF was landing at
  keyedit.prompt causing 'No user ID with index 12345678')
- Fix set_card_identity sending ADMIN_PIN_DEF to cardedit.prompt after
  name/login commands (scdaemon caches admin PIN; no re-prompt needed)
- Fix ECC P-256 encryption subkey generation: remove invalid 'echo Q'
  (option 12 skips capabilities menu, goes straight to curve selection)
- Use DONGLE_BRAND variable in GPG User PIN prompt for consistent branding
- Label ADMIN_PIN as 'NK3 Secrets app PIN / GPG Admin PIN' when Nitrokey 3
  is detected, in all user-facing prompts and status messages

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:43:06 -04:00
Thierry Laurion 9046036524 gui/init: skip integrity report for OEM reset path and improve boot messaging
- Skip integrity report when OEM factory reset is called from TPM error menu
- Improve boot messaging and fix console output

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:42:54 -04:00
Thierry Laurion a21ce5f6d7 functions: add Canokey QEMU USB and Nitrokey 3 detection
- Add Canokey QEMU USB (20a0:42d4) to detect_usb_security_dongle_branding()
  with debug logging
- Display Nitrokey 3 firmware version in hotpkey_fw_display(); warn when
  firmware is below the minimum supported version
- Re-detect DONGLE_BRAND in cache_gpg_signing_pin() after GPG card is
  confirmed present; fixes generic 'USB security dongle' label when dongle
  enumerates after the initial detection in gui-init.sh
- Combine DONGLE_BRAND assignment and export into a single line

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:42:43 -04:00
Thierry Laurion eb84f1b52f gui-init: add integrity gate for reseal/reset paths; add dongle branding
This is the core commit of PR #2068. It introduces:

Integrity gating (gui-init.sh):
- gate_reseal_with_integrity_report(): blocks reseal/reset unless /boot
  integrity is confirmed; set INTEGRITY_GATE_REQUIRED=y on TOTP/HOTP
  failure to trigger the gate before any signing or secret-sealing
- report_integrity_measurements(): shows /boot hash state (OK/CHANGED/UNKNOWN)
- investigate_integrity_discrepancies(): guided flow when hashes mismatch,
  letting the user inspect changed files before deciding to re-sign
- tpm_reset_required() guard in update_checksums() and gate_reseal_with_integrity_report():
  forces TPM reset before signing if the rollback counter is broken/absent
- LUKS_PARTITION_DETECTED reuse to distinguish "no /boot" from "no OS"
  and route user to the correct recovery path

Dongle branding (gui-init.sh, oem-factory-reset.sh, gpg-gui.sh):
- DONGLE_BRAND set from detect_usb_security_dongle_branding() (VID:PID);
  displayed in menu headers, HOTP prompts and error messages
- hotpkey_fw_display() called for firmware version in HOTP prompts
- oem-factory-reset.sh: STATUS messages use DONGLE_BRAND; adds Nitrokey 3
  Secrets app reset

GPG / kexec signing:
- gpg-gui.sh: refactored to use shared gpg_functions.sh
- kexec-seal-key.sh: LUKS DUK setup with per-device unlock validation,
  partial-device handling, and 3-attempt recovery
- kexec-unseal-key.sh: STATUS/WARN output for unlock flow

General:
- config-gui.sh, flash-gui.sh: improved prompts and error handling
- All scripts: tabs indentation, die() -> DIE()

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:42:30 -04:00
Thierry Laurion be86fd0210 initrd: update function libraries and runtime files
- functions.sh: Add detect_usb_security_dongle_branding() to identify
  dongle type by USB VID:PID. Add hotpkey_fw_display() for firmware
  version display. Add whiptail wrapper functions (whiptail_error,
  whiptail_info, whiptail_yesno).

- gui_functions.sh: Add whiptail wrapper functions for consistent UI.

- luks-functions.sh: Add luks_tpm_reseal_prompt() to guide users to
  reseal TPM after LUKS modifications.

- init: Add CBMEM console capture before PCR extensions for
  measuring_trace.log. Add STATUS messages for boot progress.
  Add boot script respawn loop. Improve quiet mode messaging.

- mount-boot.sh, sbin/*: Various consistency updates.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:32:05 -04:00
Thierry Laurion a41bdcc54b initrd: add dongle firmware version constants and shared GPG functions
Add initrd/etc/dongle-versions with USB security dongle firmware version
constants (firmware versions, VID:PID) used by OEM reset and firmware display.

Add initrd/etc/gpg_functions.sh with shared GPG functions factored out of
gpg-gui.sh for reusability across scripts.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:20:18 -04:00
Thierry Laurion fafb2e8c98 initrd: rename scripts to add .sh extension
Use git mv for all script renames for proper tracking.

Renamed files:
- initrd/bin: cbfs-init, generic-init, gpgv, gui-init, gui-init-basic,
  kexec-boot, kexec-insert-key, kexec-iso-init, kexec-parse-bls,
  kexec-parse-boot, kexec-save-default, kexec-save-key, kexec-seal-key,
  kexec-select-boot, kexec-sign-config, kexec-unseal-key, key-init,
  lock_chip, media-scan, mount-usb, network-init-recovery,
  oem-factory-reset, oem-system-info-xx30, poweroff, qubes-measure-luks,
  reboot, seal-hotpkey, seal-totp, tpm-reset, tpmr, uefi-init,
  unseal-hotp, unseal-totp, usb-init, wipe-totp
- initrd/etc: functions, gui_functions, luks-functions
- initrd: mount-boot
- initrd/sbin: insmod

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-04-06 20:20:10 -04:00
Thierry Laurion 19e4358cbf Merge pull request #2078 from tlaurion/distro_keys_updater-keep_only_primary_signing_key-remove_expired_ones
Distro keys updater keep only primary signing key remove expired ones : reduces size of archilinx.key and tails.key
2026-03-27 10:13:51 -04:00
Thierry Laurion 348a30634f distro/keys: minimize archlinux and tails signing keys
Re-export both keys through the new update_distro_signing_key scripts
to strip non-signing subkeys (encryption, authentication) and expired
subkeys that had accumulated in the in-tree copies.  Only the primary
key and currently-valid signing subkeys are retained.

  archlinux.key: 1168B -> 673B  (495B saved,   auth+encrypt subkeys removed)
  tails.key:     21282B -> 7376B (13906B saved, expired+non-signing subkeys removed)

Qubes OS keys (4.2, 4.3, weekly builds) were already minimal -- no change.

Fixes linuxboot/heads#2066.

This class of manual update has been needed repeatedly in the past and
was caught late each time, causing distro ISO verification failures in
the field for Tails and other supported distros:
  linuxboot/heads#1808 (issue: Tails key expired, ISOs unbootable)
  linuxboot/heads#1631 (PR: update tails.key, replay of manual steps)
  linuxboot/heads#1809 (PR: replay of #1631 for next Tails rotation)
  linuxboot/heads#2000 (PR: Tails 7.0 key, same manual process again)
  linuxboot/heads#1457 (PR: Arch Linux key update)
  linuxboot/heads#2033 (PR: Qubes OS 4.3 key addition)

TODO: wire bin/update_distro_signing_keys.sh into CI (e.g. a scheduled
      workflow) so upstream key rotations are detected automatically
      before they break users.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-03-27 10:08:37 -04:00
Thierry Laurion 9d03303fd9 root-hashes: simplify root detection and unsupported-layout UX
Compared to HEAD^, this commit updates initrd root-hash probing in:
- initrd/bin/root-hashes-gui.sh
- initrd/etc/functions

Behavior expected to work:
- Root-hash create/verify flow on latest Ubuntu, Debian, and PureOS under KVM.
- LUKS/LVM root probing based on mountability + expected root directory checks.
- Clear unsupported-layout whiptail guidance for unsupported filesystem/layout combinations.

Current status and non-goals:
- Fedora and QubesOS are untested in this change set.
- QubesOS on coreboot q35 with Heads still does not support qemu/kvm; no regression is implied.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-03-06 16:09:08 -05:00
Thierry Laurion c37f96db42 functions: add full track tracing when doing TRACE_FUNC when DEBUG is enabled
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-03-06 16:09:02 -05:00
Thierry Laurion b3cb32565e Replace size reporting with sysfs helper; keep fdisk for partition tables
fdisk -l can’t be trusted inside Heads’ initrd: busybox limits it to
2 TiB and parsing its output is fragile.

Changes relative to origin/master:

  * add new function disk_info_sysfs() in initrd/etc/functions
    – walks /sys/block, skips partition entries, and computes a byte
      count (preferring blockdev --getsize64, otherwise size*512)
    – converts to decimal GB, switching to TB for ≥1000 GB
  * update show_system_info() (gui_functions & oem‑system‑info‑xx30) to call the
    helper and no longer invoke `fdisk -l` for size output
  * add TRACE_FUNC/DEBUG logging around the helper invocation

Tested in qemu/debian‑13/PureOS; only the size line differs, other behaviour
is identical to master.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-03-06 12:35:49 -05:00
Thierry Laurion a16afdbcd7 initrd/*functions : add logic to show ec version under System Information and recovery shell, populated in init
repro from within Heads:
source /etc/functions
ec_version

v540tu:
2024-07-17_4ae73b9

v4x_adl:
1.07.02

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-27 14:20:28 -05:00
Thierry Laurion fa3c24f7bb initrd: fix TOTP loop by flushing input before ESC wait
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-23 15:52:50 -05:00
Thierry Laurion bed0ed063e oem-factory-reset: improve firmware read UX and error logging
* show progress hint when flashprog --progress is used
* don't silence command output; capture stderr for diagnostics

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-23 15:37:01 -05:00
Thierry Laurion b5719a6203 tpmr: change TPM DUK from policypassword for policyauthvalue
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-22 19:25:26 -05:00
Thierry Laurion 864465066a Merge pull request #2052 from tlaurion/tpmr_add_clearcontrol
tpmr: added helper and enhanced reset routines with clearcontrol and error checks
2026-02-22 19:21:50 -05:00
Thierry Laurion d5f4bb7e0b oem-factory-reset : fix HOTP counter being set at 0 when factory reset/re-owning device
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-22 19:11:25 -05:00
Thierry Laurion 9aed7cad95 tpmr: added helper and enhanced reset routines with clearcontrol and error checks
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-22 19:04:47 -05:00
Thierry Laurion 699a1a7ed7 Remove DO_WITH_DEBUG from increment_tpm_counter calls
DO_WITH_DEBUG redirects stdout/stderr through tee for logging, which
breaks interactive password prompts by interfering with TTY access.

Both increment_tpm_counter calls already redirect output to /dev/null,
so DO_WITH_DEBUG provided no logging benefit while breaking prompts.

This allows TPM owner password prompts to display correctly on console
when TPM counters need to be created or incremented.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-08 18:17:06 -05:00
Thierry Laurion de7e630f63 etc/functions: add wait_for_usb_devices helper to fix gpg --card-status failing because race condition without sleep
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-08 17:50:42 -05:00
Thierry Laurion 0d3ad84e94 Refine Docker workflows and reproducibility tooling
- Add shared Docker helpers and wrapper-specific help while keeping full env reference in common.sh

- Introduce digest tooling (get_digest, pin-and-run, fetch_nix_installer) and pin DOCKER_REPRO_DIGEST

- Rework reproducibility checks (config digest comparison, remote resolution) and improve docker load/Xauthority handling

- Update README and QEMU docs; tighten initrd kexec-seal-key parsing

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
2026-02-08 16:38:43 -05:00