User:Robbat2/Infra GPG keys process steps
From Gentoo Wiki
Jump to:navigation
Jump to:search
Infra-managed GnuPG
Commands
These are commands to help with the Infra-managed GnuPG keys; esp. in an airgap environment.
Ideally the scripts would be baked into a custom verifiable image, but failing that, it should be possible to retype them.
Command args
cat >gpg-helper.sh <<EOF #!/bin/sh gpg \ --cert-policy-url https://www.gentoo.org/glep/glep-0079.html \ --no-ask-cert-level --default-cert-level 3 \ --no-ask-cert-expire --default-cert-expire 2026-07-01 \ --default-keyserver-url hkps://keys.gentoo.org \ --allow-weak-key-signatures \ --expert \ "$@" EOF
Update Expiry
Do this for all keys BEFORE updating signatures.
# primary key gpg-helper --quick-set-expire $FPR 2026-07-01 # subkey gpg-helper --quick-set-expire $FPR 2026-07-01 '*'
Resign from L1 -> L2, from L2 -> other
gpg-helper --local-user $SIGNING_KEY_FPR \ --edit-key $FPR_TO_SIGN
tsign
2 # fully 1 # depth gentoo.org # domain y # YES
Export new signatures
gpg-helper --export-options export-clean --armor --export $FPR >$FPR.asc # and then review the file!
Airgap design notes
- Take some system with *NO* local storage, *NO* networking.
- User:Robbat2 previously used Dell Wyse terminals for this: no WIFI or bluetooth hardware present at all; secure boot enabled on EFI w/ signed firmware (somewhat verifiable)
- RPi might be options as well, but watch out for onboard wireless networking / RF access [1]
- media:
- Boot media
- If the media is implicitly writable by nature, should support cached boot to enable removing the media after boot. If the boot media is physically read-only (e.g. CDROM), the cachable boot is not required.
- Required tooling: `gnupg` plus any extra packages (cryptsetup, lvm2, mdadm, filesystem tools, par2) for the secure key media.
- Secure data media
- This media should be marked to avoid ANY accidental insertion into the non-airgap system (but the disk encryption should also provide defense in depth)
- This needs to be SECURE against compromise by physical access, but also resilient against corruption while in an offline state (e.g. flash degradation)
- Example designs:
- RAID over multiple devices, with dm-crypt layered
- Encrypted files w/ PAR2 added, enabling recovery from block device
- Some failure modes to consider
- Entire device fails to work
- Corruption to part of device, possibly silent
- Direct corruption of data (device "intact", but cosmic ray bit flips etc, NAND decay, magnetic decay etc)
- Corruption of metadata (device "intact", but cosmic ray bit flips etc, NAND decay, magnetic decay etc)
- Loss of media encryption key - don't store them in the same place, but DO ensure you have continuity and backups of the media encryption key!
- Rubber hose attack - cannot be protected against trivially
- Boot media
- Public key export design
- This is oddly one of the hardest design parts: how to enable export of the updated public key portions, while making it really hard to accidental export the private keys.
- For the purposes of the airgap key management system; it should be *easy* to review the exported data as it comes out, and be able to clearly say "this is clean of secret material", before inserting back into the public system
- Possible solutions
- Print & Scan w/ OCR. Most auditable solution, but consider evil in the print/scan path (secret export via tracking dots). Buggy as the data size grows: ~5KiB as of 2024/04/20.
- Onscreen OCR or QR codes: less auditable [e.g. if the generator & scanner have hidden evil code]
- Data diode - more expensive, not cost-effective for a system used once or twice per year
- Overall process
- Validate physical security of airgap system and components
- Boot from trusted boot media - ideally preserved media, not fresh media
- Remove boot media if applicable (see note about cached vs read-only)
- Insert Secret Media
- Load secrets (may required copying)
- Interact w/ Secrets:
- Refresh expiry
- Update certification signatures (tsign)
- Export signed public keys to ephemeral storage
- If secrets were copied, ensure they are backed up again on the secret media
- Remove secret media!
- Wipe secrets from ephemeral storage if required
- Review signed public key export
- gpg --list-packets is good, but how do you ensure that it isn't ALSO hiding data from you?
- Exfiltrate freshly signed public keys
- See possible solution discussion above.