Skip to content

soc: apple: sep: sep-key: cancel, and secrets released only with a touch - #1506

Merged
RyanTheTide merged 5 commits into
integration/aurorafrom
fidohw/sep-key-v3
Nov 11, 2026
Merged

RyanTheTide merged 5 commits into
integration/aurorafrom
fidohw/sep-key-v3

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

/dev/sep-key interface version 3.

  • SEP_KEY_CANCEL ends a touch-gated SIGN/UNSEAL that is waiting for a finger; that call returns ECANCELED. The verify and capture loops stop as soon as the flag is set.
  • SEP_KEY_SEAL encrypts up to 64 bytes to a biometric key's public point (the ECIES scheme the trusted-key source uses; no private key, no touch).
  • SEP_KEY_UNSEAL has the enclave decrypt (op oecd) such a blob with the key under the same fresh, touch-satisfied credential context a SIGN uses, opened, matched and deleted inside the one call. Both refuse keys without a biometric policy.
  • INFO.reserved becomes features (SEP_KEY_FEATURE_CANCEL, SEP_KEY_FEATURE_SEAL).
  • Self-tests (key_selftest=1): 20 one touch, two signatures in the same open context; 21 one touch, sign then unseal in the same context; 22 no finger, unseal with no context and with an unsatisfied one (both must be refused).

Userspace: aurora-sep-userspace fido/ uses UNSEAL for FIDO hmac-secret (CredRandom released only after a match) and CANCEL for client cancels and timeouts.

Tests

  • KUnit apple_sep* (sep.kunitconfig, arm64 QEMU): 471 passed, 2 skipped.
  • Hardware: pending (no-finger rows for self-tests 1-4/22, CANCEL and ETIMEDOUT; finger rows for 20/21 and UNSEAL).

Interface version 3 of /dev/sep-key. INFO's reserved word becomes
'features' (SEP_KEY_FEATURE_CANCEL, SEP_KEY_FEATURE_SEAL).

SEP_KEY_CANCEL ends a touch-gated call that is waiting for a finger; that
call returns ECANCELED. The wait checks the flag before each capture and
the verify and capture loops stop as soon as it is set, so a client that
gives up (a browser cancel, a security key daemon's own timeout) no longer
leaves the sensor armed for the rest of the minute.

SEP_KEY_SEAL encrypts up to 64 bytes to a biometric key's public point
with the ECIES scheme the trusted-key source already uses
(refkey_seal::ecies_seal); it needs no private key and no touch.
SEP_KEY_UNSEAL has the enclave decrypt such a blob with the key (op oecd)
under the same fresh, touch-satisfied credential context a SIGN uses: the
kernel opens the context, runs the match, decrypts and deletes the context
inside the one call. The key's access-control list constrains the decrypt
as it constrains the signature, so the secret is released only after a
match the enclave saw. Both refuse keys made without a biometric policy.
A FIDO authenticator uses this for hmac-secret, whose CredRandom must not
be computable on the host without the user.

The touch-gated job now carries the operation (sign or unseal) instead of
always signing. Self-test modes, all behind key_selftest=1:
 20  one touch: sign, then sign again in the same, still open context
     (does one match let the enclave do more than one operation?)
 21  one touch: sign, then unseal in the same context
 22  no finger: unseal with no context and with an unsatisfied one; both
     must be refused, or the access-control list does not cover the decrypt

KUnit: the version 3 INFO and ioctl numbers, secret and seal bounds.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware, M1 Pro (J316s), 7.3.0-aurora-fidohw1 = fleet59 + this branch, one-shot, no finger, Enforcing, 0 AVC:

  • INFO: version 3, flags_supported 0x3, features 0x3.
  • SEAL refuses a key without a biometric list (EINVAL); SEAL to a biometry-any key: 113 B, no touch.
  • Self-tests 1-4 (SIGN with no / unsatisfied / key-bag-secret / deleted context): refused, enclave status -8.
  • Self-test 22 (UNSEAL with no context, with an unsatisfied context): refused, enclave status -8. The record's access-control list constrains oecd as it does osgn.
  • Biometry-current-set key, SIGN with no context: refused (-8).
  • Touch-gated SIGN before any password since boot: refused at once (EACCES), as for /dev/sep-bio. CANCEL and ETIMEDOUT rows need a password-unlocked boot (pending), as do the finger rows (20, 21, UNSEAL after a touch).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Second Mac: Neo (J700, variant-5 key store), same kernel build, one-shot, no finger, Enforcing, 0 AVC: INFO v3 / features 0x3; SEAL refuses a non-biometric key; self-tests 1-4 refused (-8); self-test 22 UNSEAL with no / unsatisfied context refused (-8); biometry-current-set SIGN with no context refused. Identical to the M1 Pro.

RyanTheTide and others added 4 commits November 11, 2026 17:19
…he decrypt ACL

The sep-key character device ran every ioctl under the shim's device
lock. A touch-gated SIGN or UNSEAL sleeps in its ioctl for up to a minute
waiting for a finger, so SEP_KEY_CANCEL from another file (and even a
second open()) waited for that minute to end and never cancelled
anything; every other /dev/sep-key caller stalled with it.

Register /dev/sep-key with a concurrent mode of the shim: its ioctls run
without the device lock, under a read hold of a lifetime rwsem that
unregister takes for writing, so the context stays valid for a running
ioctl and none starts after it is cleared. /dev/sep-bio and
/dev/sep-bio-rearm keep the serialised mode. In the driver, touch-gated
calls already serialise on catacomb_writer and CANCEL only sets a flag;
a new key_bag_lock keeps one caller from unloading the identity bag
under another caller's create, sign or decrypt.

UNSEAL was refused by the enclave (status -8) even after a satisfied
match: the biometric key's access-control list named sign, key agreement,
derivation, attest and delete, but no entry for the ECIES decrypt, and
the pre-match constraint evaluation always named the sign operation.
Constrain the decrypt operation (UNSEAL_ACL_OP) with the same biometric
credential and evaluate the constraint for the operation the job runs.

Self-test 23 (no finger, key_selftest=1 only) makes throwaway keys whose
lists leave one candidate operation free and unseals with no context, to
show on hardware which list entry governs the decrypt.

KUnit: apple_sep_bio_shim checks that a cancel from a second file reaches
the driver while an ioctl sleeps, and that unregister waits for a running
ioctl and later ioctls get -ENODEV.

Assisted-by: LLM
…and context

Self-test 24 makes five throwaway keys (no list, oecd free, no decrypt
entry free, ock free, the plain list ock/odel/osgn/oa/okd) and runs a
signature, a decrypt and a key exchange on each with no context, an
unsatisfied context and a key-bag-secret context, logging every enclave
status. It tells which entry governs the decrypt SEP_KEY_UNSEAL uses and
whether a list-bearing key needs a credential context at all.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sep-key-v3

# Conflicts:
#	drivers/soc/apple/key.rs
#	include/uapi/linux/apple-sep.h
The enclave refuses its ECIES decrypt (oecd) for every ref-key that
carries an access-control list, even when the list leaves oecd free; it
decrypts only for keys with no list (self-test 24 on the M1 Pro: sign
works with no or an unsatisfied context on every listed key, oecd only
on the unlisted one). A biometric key's secret therefore never came back.

Do what macOS does for Secure Enclave keys: the enclave computes the ECDH
shared X of the blob's ephemeral point and the key (op ock, peer point
under 'pub'), which the biometric list already constrains exactly as
macOS writes it, and the kernel runs the X9.63 KDF and AES-256-GCM
decrypt. The list goes back to macOS's shape (no oecd entry), the
pre-match constraint check names ock for an unseal, and self-test 23 is
replaced by self-test 24's rows for oecd, ock (no, unsatisfied and
key-bag-secret contexts) and the SEP_KEY_UNSEAL path itself. KUnit
apple_sep_ecies_open checks the open path with the generator as the
recipient (the shared X is then the ephemeral's own X).

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

a7968d3: merged integration/aurora (per-user key bag), UNSEAL now uses the enclave key exchange.

  • Self-test 24 (M1 Pro, 13.x key store): the enclave decrypt (oecd) works only for ref-keys with no access-control list; every listed key refuses it (-8), even with oecd, od, ock or oe free. Signing with a free osgn needs no context.
  • The key exchange is {o "ock", pub , rk} and returns the 32-byte shared X. UNSEAL = ock under the touch-satisfied context (the biometric list already constrains ock) + X9.63-SHA256 KDF and AES-256-GCM in the kernel. The list is back to the plain .biometryAny / .biometryCurrentSet shape.
  • fidohw5 on the M1 Pro, no finger: biometric UNSEAL refused with no or an unsatisfied context; a key with ock free unseals end to end; a list without ock refuses ock and UNSEAL; a second file's ioctl returns in 0.00 s during a touch wait; 0 AVC.
  • KUnit apple_sep: 500 tests, 498 pass, 2 skip (new apple_sep_ecies_open).
  • Still to do: the finger rows (SIGN + UNSEAL after a match, uhid).

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 11, 2026 09:32
@RyanTheTide
RyanTheTide merged commit 943eb66 into integration/aurora Nov 11, 2026
4 checks passed
@RyanTheTide
RyanTheTide deleted the fidohw/sep-key-v3 branch November 11, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant