Installation

1. Build from source

swift build -c release

Or use the setup script, which builds the binary, writes a wrapper script, and configures gpg-agent.conf for you:

./scripts/setup.sh

setup.sh:

  1. Runs swift build -c release.
  2. Verifies $GNUPGHOME (default ~/.gnupg) is owned by you and has 0700 permissions, fixing the mode if it’s wrong (and refusing to continue if the directory is owned by someone else).
  3. Writes a plain wrapper to $GNUPGHOME/scdaemon-se-wrapper.sh that just execs the built binary (no debug logging — see Troubleshooting if you want a logging wrapper instead).
  4. Appends scdaemon-program <path-to-wrapper> to gpg-agent.conf — or, if that file already has an scdaemon-program line, prints the line to add manually instead of overwriting your existing configuration.

2. Homebrew

Not live yet: the formula’s url/homepage point at github.com/gmarcusm/scdaemon-se, which does not exist as a public repository yet. brew install will fail with “repository not found” until it does. This section describes how installation will work once that repo is published.

brew tap gmarcusm/scdaemon-se https://github.com/gmarcusm/scdaemon-se
brew install scdaemon-se

The formula builds via swift build --disable-sandbox -c release and installs:

  • scdaemon-se — the daemon/CLI binary
  • scdaemon-se-inspect — read-only card/Keychain inspection (see CLI Reference)
  • scdaemon-se-clear-enclave — removes scdaemon-se’s Keychain entries and (optionally) GPG shadow key stubs

It prints the exact gpg-agent.conf line to add as part of brew install’s caveats output.

3. Configure gpg-agent

If you didn’t use setup.sh or Homebrew, add the binary path to gpg-agent.conf yourself:

BINARY="$(swift build -c release --show-bin-path)/scdaemon-se"
echo "scdaemon-program $BINARY" >> ~/.gnupg/gpg-agent.conf

4. Restart gpg-agent

gpgconf --kill gpg-agent

The agent restarts automatically the next time GPG needs it.

5. Verify

gpg --card-status

You should see Secure Enclave Key as the display name and nistp256 as the key attributes for all three slots. Or, at the protocol level:

gpg-connect-agent "SCD SERIALNO" /bye
S SERIALNO D276000124010304<hex-serial>0000
OK

Uninstallation

  1. Remove the scdaemon-program line from ~/.gnupg/gpg-agent.conf.
  2. Remove Secure Enclave keys and metadata from the Keychain:
    ./scripts/clear-secure-enclave.sh          # dry run: lists what it would remove
    ./scripts/clear-secure-enclave.sh --yes    # actually remove it
    

    By default this only prints the plan (every specific Keychain item it found, by name) and deletes nothing; --yes is required to act. Add --shadow-stubs to also remove scdaemon-se’s own GPG shadow stubs from ~/.gnupg/private-keys-v1.d/ — off by default. Stubs are matched by keygrip against the key-pin store, so another card’s stubs (e.g. a YubiKey’s) are identified and never touched. It also restarts gpg-agent. To remove one additional signing card instead of everything, use scdaemon-se --remove-card <serial> --yes (see CLI Reference).

  3. Remove the public key from your keyring if you no longer want it:
    gpg --delete-keys <email-or-fingerprint>
    
  4. Restart gpg-agent: gpgconf --kill gpg-agent

scdaemon-se is licensed under the MIT License.

This site uses Just the Docs, a documentation theme for Jekyll.