This is a command-by-command account of exactly what scdaemon-se does with each Assuan command it receives, built directly from the dispatch switch in OpenPGPCardHandler.handle(_:) (Sources/SCDaemonLib/OpenPGPCard.swift). Commands are case-insensitive: AssuanRequest uppercases the command name before dispatch.
Error responses use one of four numeric codes:
Code
Meaning here
1
General error (bad/missing arguments, malformed input)
69
Not supported (unknown command/attribute, or a deliberately unimplemented feature)
119
No card / key not available for the requested operation
349
The underlying Secure Enclave operation itself failed
Returns the active card’s serial. --demand=<x> switches the active card (matching by bare serial or full AID) or errors ERR 119 no such card <x> if none matches. --all reports only the active card (see Architecture § Multi-card model for why). Anything else besides openpgp/--/empty errors ERR 119 not an OpenPGP card.
LEARN [--force]
Ensures keys are loaded, then reports SERIALNO, APPTYPE, EXTCAP, DISP-NAME, and KEY-FPR/KEY-TIME/KEY-ATTR/KEYPAIRINFO for the active card’s slot 1, plus slots 2/3 if the active card is the primary. Always succeeds.
Returns the canonical S-expression for the resolved key’s public point (an OPENPGP.n slot on the active card, or a keygrip matching one of the active card’s slots). --info/--info-only also/only emit a KEYPAIRINFO status line. Missing reference: ERR 1. Unresolvable reference: ERR 69 unknown key <ref>. Slot has no key yet: ERR 119 key not found.
SETDATA <hex>
Hex-decodes <hex> into a pending-data buffer used by the next PKSIGN/PKAUTH/PKDECRYPT. Missing argument: ERR 1 missing data.
PKSIGN [keygrip]
Signs the pending data with a signing-role key. No keygrip → the primary signing key. Keygrip matches a signing-role key (primary, or an additional card’s) → that key. Keygrip matches the auth key → refused: ERR 119 keygrip is an authentication key; not usable for PKSIGN (this daemon enforces the sign/auth role separation a real smartcard has). No data staged: ERR 1. No signing key at all: ERR 119. Pending data isn’t a valid 32-byte digest or 51-byte SHA-256 DigestInfo: ERR 1 invalid digest: .... A Secure Enclave failure: ERR 349 signing failed: .... Returns the signature’s raw r‖s (64 bytes for P-256), not DER.
PKAUTH [keygrip]
Mirrors PKSIGN for the authentication role: a keygrip matching a signing key is refused (ERR 119 keygrip is a signing key; not usable for PKAUTH). Same digest validation and raw-signature response shape.
PKDECRYPT
ECDH key agreement using the pending data as the ephemeral public key, against the decryption key. No data staged: ERR 1. No decryption key (absent by default — see Security Model): ERR 119. Failure: ERR 349 decryption failed: .... Returns the raw shared secret.
GETATTR <name>
See the GETATTR sub-reference below. Missing name: ERR 1. Unrecognized name: ERR 69 unknown attribute <NAME>.
GETINFO <what>
version → D 2.5.20; pid → the process ID; socket_name/reader_list → OK with no data; status → D USABLE; deny_admin → OK; card_list → one D <AID> line per card in the registry. Missing argument: ERR 1. Anything else: ERR 69 unknown info <what>.
KEYINFO --list or KEYINFO <keygrip>
--list reports KEYPAIRINFO for the active card’s slot(s), like LEARN. A bare keygrip is looked up across every card (primary’s three slots plus every additional card’s signing key) — broader than READKEY’s active-card-only scope, since a client may ask about a keygrip belonging to a card that isn’t currently active. No match: ERR 119 key not found. Missing argument: ERR 1.
GENKEY <slot>
Regenerates the key at slot 1/OPENPGP.1 (signing), 2/OPENPGP.2 (decryption — only if SCDAEMON_SE_ALLOW_ENCRYPTION is set, else ERR 69), or 3/OPENPGP.3 (auth). Deletes the old key at that slot first, then generates and stores a new one, returning KEY-FPR, KEY-CREATED-AT, and the raw public key bytes. Missing argument: ERR 1. Unsupported slot: ERR 69 unsupported key slot <ref>. Generation failure: ERR 349.
RESTART / RESET
Clears the pending-data buffer and returns OK. Does not reset the active card selection, the SCD nesting depth, or any already-loaded keys — only pending SETDATA state.
BYE
Returns OK closing connection; the server’s read loop then exits and the connection ends.
SCD <command...>
Re-dispatches the wrapped command as if it had been sent directly (this is how gpg-agent nests card commands inside an SCD prefix). Nesting is capped at depth 3 — a 4th nested SCD errors ERR 1 SCD recursion limit. Missing subcommand: ERR 1.
GETATTR sub-reference
Attribute
Behavior
SERIALNO
The active card’s AID.
APPTYPE
Always openpgp.
EXTCAP
A fixed capability string (gc=1+ki=1+fc=1+pd=1+mcl3=2048+aac=1+sm=0+si=5+dec=1+bt=1+kdf=0).
DISP-NAME
Always Secure Enclave Key.
KEY-FPR
Fingerprint(s) for the active card’s available slot(s).
CHV-STATUS
A fixed status line (1 -1 -1 -1 3 3 3) — there is no software PIN; see Security Model.
KEY-ATTR
19 nistp256 for slot 1 always; 18 nistp256/19 nistp256 for slots 2/3 too, but only if the active card is the primary.
$SIGNKEYID / $ENCRKEYID / $AUTHKEYID
The slot reference if that key exists on the active card (and, for the latter two, only if the active card is the primary); otherwise a bare OK with no status line.
KEY-STATUS
OPENPGP.n 1 for each available slot.
$DISPSERIALNO[ <keygrip>]
With a keygrip argument, the serial of the card that owns it (searched across all cards); otherwise the active card’s serial.
Accepted no-ops
These always return OK without doing anything, regardless of their arguments:
Command
Why
SETATTR
Accepted so gpg-agent doesn’t error, but nothing is written anywhere.
OPTION, NOP
Standard Assuan session-negotiation commands; nothing in this daemon needs to react to them.
CHECKPIN, PASSWD
There is no software PIN or passphrase to check — the Secure Enclave enforces user presence (Touch ID / passcode) at the hardware level on every private-key operation instead. See Security Model.
Explicitly unsupported
Command
Response
Why
READCERT
ERR 69 not supported
The card emulation handles keys only; there is no certificate storage.
WRITEKEY
ERR 69 key import not supported
Keys can only be generated inside the Secure Enclave — there is no way to import existing key material into it (this is a hardware limitation, not a missing feature).
Everything else
Any command not listed above falls through to the default case and returns ERR 69 unknown command <name>. This includes standard Assuan/scdaemon commands that real GnuPG smartcard daemons support but this one does not implement at all — for example RANDOM, APDU, LOCK/UNLOCK, and DEVINFO. These are named here as examples of what lands in this bucket, not as a claim that they’ve been tested against this daemon.