Guide: Secure Enclave subkeys under an external master key
This is the recommended pattern: keep your OpenPGP master (certification) key offline in software, and use the Secure Enclave only for the working subkeys you touch every day — a signing subkey and an authentication subkey. Because the master stays offline and backed up, losing your Mac only costs you the subkeys: you revoke them and issue new ones, and your identity and web of trust survive.
The alternative — making the Secure Enclave key your primary identity via --export-public-key — roots your whole identity in a non-backupable device and is gated for that reason (see Security Model). This guide needs no environment-variable opt-ins: adding signing and authentication subkeys works with the defaults.
Each Touch ID prompt below names the card and key slot being used, but not the content being signed — approving one confirms a human is present, not that the human reviewed that specific operation. See Security Model.
What happens under the hood
When you attach a Secure Enclave key as a subkey of your external master, gpg produces two signatures:
- A subkey binding signature (type
0x18), made by your master key in software. It says “this subkey belongs to me.” - A primary-key binding signature (type
0x19, the back-signature or cross-certification), made by the subkey itself — the Secure Enclave key. It says “this subkey consents to being bound to that master.”gpg-agentasksscdaemon-seto produce it withPKSIGN, which triggers a Touch ID / passcode prompt.
A back-signature is only required for sign-capable subkeys:
| Subkey | Back-signature needed? | Touch ID during creation? |
|---|---|---|
| Signing | Yes (the Secure Enclave signs it) | Yes |
| Authentication | No | No |
| Encryption | No | No |
Prerequisites
scdaemon-seinstalled and configured (see Installation). Verify withgpg --card-status— it should list threenistp256keys.- GnuPG 2.x. The menu option used below (“Existing key from card”) requires
--expert. - An external OpenPGP master key with the certify capability. The steps below create a fresh offline-style master; skip to Step 3 if you already have one.
Throughout, $MASTER is your master key’s fingerprint or key ID.
Step 1 — Create (or identify) an external master key
gpg --quick-generate-key "Your Name <you@example.com>" ed25519 cert 0
gpg --list-secret-keys --keyid-format long
The primary key shows [C] (certify). Record its key ID as $MASTER. The master can be any algorithm — it does not have to match the Secure Enclave’s P-256 subkeys.
GnuPG eventually auto-assigns ultimate ownertrust to a key you hold the secret key for, but that isn’t guaranteed to have happened yet, and without it Step 5’s verification below can print a spurious WARNING: This key is not certified with a trusted signature!. Set it explicitly:
gpg --edit-key $MASTER
gpg> trust
Choose 5 (I trust ultimately), confirm y at the “Do you really want to set this key to ultimate trust?” prompt, then gpg> quit. (Scriptable equivalent: echo "<fingerprint>:6:" | gpg --import-ownertrust.)
Step 2 — Confirm the Secure Enclave is presented as a card
gpg --card-status
You should see Key attributes ...: nistp256 nistp256 nistp256. If the signing and authentication keys don’t exist yet, scdaemon-se generates them on first access (the encryption key is not auto-created — that’s intentional and irrelevant here).
Step 3 — Add the Secure Enclave signing subkey
gpg --expert --edit-key $MASTER
At the gpg> prompt:
gpg> addkey
- “Please select what kind of key you want” → Existing key from card (option
14on GnuPG 2.4/2.5 with--expert). - “Please select the key to use” → the signature key, slot
1(OPENPGP.1). - Capabilities: the default is already Sign (
scdaemon-sereports the slot’s usage), so just chooseQ(Finished). Confirm the current allowed action is Sign and nothing else. - “Key is valid for?” →
0(or your preferred expiry), confirmy. save.
On save, gpg-agent asks the Secure Enclave to make the back-signature — a Touch ID / passcode prompt appears; approve it.
Step 4 — Add the Secure Enclave authentication subkey
gpg --expert --edit-key $MASTER
gpg> addkey
- Existing key from card (option
14). - Choose the authentication key, slot
3(OPENPGP.3). - Capabilities: toggle to Authenticate only (press
Ato enable it and, if Sign is set,Sto clear it), thenQ. - Expiry →
0, confirmy. save.
This subkey needs no back-signature, so there’s no Touch ID prompt during creation.
Step 5 — Verify
gpg --list-keys $MASTER
Expected — a certify-only primary with two Secure Enclave subkeys:
pub ed25519 2026-07-05 [C]
D3E9F7DF259D35BF607301441668E99974BC23A4
uid [ultimate] Your Name <you@example.com>
sub nistp256 2026-07-05 [S]
sub nistp256 2026-07-05 [A]
Then create the shadow key stubs and make a real signature:
gpg-connect-agent "LEARN --sendinfo --force" /bye
echo "hello from the Secure Enclave" | gpg --clearsign --local-user $MASTER | gpg --verify
A successful run prints Good signature and shows using ECDSA key <signing-subkey-fingerprint>.
Step 6 — Move the master offline (recommended)
gpg --export-secret-keys --armor $MASTER > master-secret.asc # store this offline
gpg --delete-secret-keys $MASTER
--delete-secret-keys doesn’t only remove the master’s own secret key — GnuPG deletes the secret material for every packet in the keyblock it’s given, primary and subkeys alike, which includes the card-backed subkeys’ local shadow stubs. Nothing on the Secure Enclave itself is touched (see Architecture § Key storage and identity), but the local bookkeeping that tells gpg-agent “this keygrip lives on that card” is gone until you re-create it:
gpg-connect-agent "LEARN --sendinfo --force" /bye
Run that once after Step 6. After that, day-to-day signing and authentication keep working via the Secure Enclave; you only need the offline master again to certify identities, add/revoke subkeys, or extend expiry.
Notes and troubleshooting
- Menu numbers vary between GnuPG versions and build options — the key choice is always “Existing key from card.” If you don’t see it, make sure you passed
--expert. Unusable secret keywhen signing — don’t force the primary with a trailing!(e.g.$MASTER!); a certify-only master can’t sign. Use--local-user $MASTERand letgpgpick the signing subkey, or reference the subkey directly with<subkey-fingerprint>!.- Subkey shows
[](no capability) — the Secure Enclave key’s usage wasn’t reported correctly; make sure you’re running a current build ofscdaemon-se, delete the empty subkey, and redo Step 3/4. - Encryption subkeys — you can add
OPENPGP.2the same way (select slot2), but see Use Cases § Bad fits first. Creating that key requiresSCDAEMON_SE_ALLOW_ENCRYPTION=1.