Repository navigation
soc: apple: sep: T8103 key store in the macOS 13.5 shapes (fixes provisioning on M1) - #37
Closed
chriskearney wants to merge 5 commits into
Closed
chriskearney wants to merge 5 commits into
chriskearney wants to merge 5 commits into
Conversation
…does
The T8103 stub boots macOS 13.5 (22G74)'s sepOS, whose key-store protocol
is the one the 13.5 AppleSEPKeyStore speaks, not the newer one the T6020
enclave answers. Name that per profile (profile::KeyStore: Sepos13 for
T8103, Variant5 for T6020) so the following changes can select the 13.5
request shapes without touching the T6020 encoding.
On the 13.5 key store, AppleKeyStore::init_sep_endpoint
(0xfffffe0009946cdc) runs before any other request:
- 0x4d GET_CAPABILITIES; the IPC header version becomes min(word, 2)
(0x...6dc0-6dd0). Version 2 is laid out as version 1 but
__payload_hash (0xfffffe000996b970) digests the header through the
trailer (0x...ba68-ba80), so image::Version gains V2.
- set_env(false) (0xfffffe000994a168): op 0x2a, struct version 0, u64 1,
and a 0x40c-byte environment {1, cpx-encryption-mode, 4, 0x400 zero
bytes} (0x...a1a0-a1e0, __ipc_set_env 0x...9ddc, _code_ipc_set_env
0x...4b64). The reply is the struct-version word alone.
Do the same at bring-up on T8103, before provisioning and before
/dev/sep-bio is published. The mode comes from the profile: the j293 and
j313 ADTs carry /defaults cpx-encryption-mode = 2, and the Linux device
tree does not mirror /defaults. Where Apple would go on after a failed
0x4d with header version 1, this keeps the key store closed for the boot.
macOS sends 0x4d once, at endpoint init, so the lock-state health check no
longer re-sends it on T8103; it requires the init to have completed.
T6020 sends nothing new: sks_init_endpoint returns at once, the header
version stays 1 and the health check is unchanged.
Hardware-verified on a MacBook Air (j313) with the 13.5 SEP: 0x4d answered
status 0, struct version 0, capability word 2, empty blob (header version
2), and set_env with cpx-encryption-mode 2 was accepted.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AJd8eEwJ4TGRSHnbKcWBmw
The T8103 CREATE_KEYBAG matched no 13.5 call. Its first word is the codec's struct version, not a bag type, and _code_ipc_create_keybag (0xfffffe000995de6c) takes versions 0-2 only and decodes exact-length. The request sent version 0 with the variant-5 tail, type 0x20000 (no immediate in the 13.5 AppleSEPKeyStore) and parent 0 (which identity_create refuses), and the reply parser required at least 12 bytes where a 13.5 success is 8. Send what AppleKeyStore::identity_create (0xfffffe000994b2d8) sends through __ipc_create_keybag_v2 (0xfffffe0009955ce0), the shape of userspace AKSIdentityCreateFirst: version 2, the client, type 0x400000 (mov w3, #0x400000 at 0x...b4e8), parent -1, blob A = the bag secret, an empty blob B, and the 16-byte identity UUID. The reply is exactly the version word and a handle (0x...e11c-e12c). Follow identity_create after the reply as well: copy (0x02, identity_save 0xfffffe000994b1cc), then unload (0x05). No 0x06 UUID read-back is sent; the 13.5 enclave keeps the identity bag and names it by the UUID it was created with (identity_open loads it by that UUID, 0x...b11c), so the record now stores that host-generated UUID (keybag state 1, "as generated") next to the copied blob and the secret. The T6020 request, reply check and provisioning order are unchanged. Hardware-verified on a MacBook Air (j313) with the 13.5 SEP: CREATE (164- byte image) answered status 0 with handle 1, COPY returned 32 bytes, and UNLOAD answered status 0; the SEP committed the new identity to xART and accepted that store at the next boot. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AJd8eEwJ4TGRSHnbKcWBmw
On macOS 13.5 an identity session is opened by AppleKeyStore::identity_load (0xfffffe000994b888), which sends exactly three key-store requests: - 0x03 LOAD_KEYBAG through identity_open (0xfffffe000994b0e4), whose blob is the 16-byte identity UUID (mov w4, #0x10 at 0x...b11c): the enclave keeps the identity bag and the host never holds a wrapped one; - 0x0d make-system-keybag, binding the loaded handle to the session handle (0x...ba48-ba5c) with an empty blob. The codec (_code_ipc_make_system_keybag 0xfffffe000995fd8c) takes struct version 0 only (0x...fe78) and the reply is that version word alone; - 0x05 UNLOAD of the source handle (0x...bad4). On T8103 the driver loaded the wrapped blob, read the UUID back with 0x06, designated with version 1, the bag secret and a trailing u64, then made a machine ref-key (0x04 unlock of the source and 0x22 'oc'), listed SBIO identities and read the session UUID back before the unload. None of that has a 13.5 counterpart. On T8103, load by the recorded identity UUID, send no 0x06, designate with version 0 and an empty blob (checking the version-0 reply), and unload the source straight after. The ref-key flow, which no 13.5 code performs with an identity bag, is refused on that profile before anything is sent, both at activation and for trusted-key and attest callers. T6020 requests, their order and the ref-key flow are unchanged. Hardware-verified on a MacBook Air (j313) with the 13.5 SEP, on every activation after provisioning: LOAD_KEYBAG by UUID status 0 with a handle, DESIGNATE_KEYBAG (source, -1000, empty blob) status 0, UNLOAD_KEYBAG status 0. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AJd8eEwJ4TGRSHnbKcWBmw
macOS 13.5 unlocks an identity session with AKSIdentityUnlockSession
(userspace 0x1ed92da2c), user-client selector 0x7b. The kext passes the
secret unchanged to unlock_the_device(client, h, secret, 5)
(0xfffffe000993cee0, called at 0x...15a4), which calls
device_state_transition with state 0 and, for mode 5, flags 0
(0xfffffe000993cf04-cf0c). That is SEP op 0x18,
__ipc_device_state_transition (0xfffffe0009958204): struct version 0
only (_code_ipc_device_state_transition 0xfffffe0009961f20, 0x...200c),
u64 client, u32 handle, u32 state, u64 flags, blob secret; the reply is
the version word and two u64. No 13.5 identity path uses 0x04
change-lock-state, whose codec takes version 0 only as well, not the
version 1 with a trailing u64 the driver sends.
On T8103, unlock the designated session with that 0x18 request.
The unlock also ran only when the template restore succeeded. On macOS the
session is unlocked whenever it is opened, and a T8103 machine that has not
enrolled yet has no template to restore, so its session was never unlocked.
On T8103 the unlock now follows the restore whatever its result; the match
context set-up that needs templates still runs only after a successful
restore.
T6020 keeps 0x04 and its restore-gated order.
Hardware-verified on a MacBook Air (j313) with the 13.5 SEP: on every
activation after LOAD, DESIGNATE and UNLOAD, DEVICE_STATE_TRANSITION
{v0, client, -1000, state 0, flags 0, secret} answered status 0 with the
20-byte reply, and the enrol credential's VERIFY_SECRET (0x21) against
-1000 then answered status 0.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AJd8eEwJ4TGRSHnbKcWBmw
The 13.5 kext waits 6000 ms per key-store request (sep_deliver_msg_gated: getAdjustedTimeout(0x1770), 0xfffffe0009945a14). feat/sep waits 2000 ms for a small image. On a MacBook Air (j313) a 13.5 CREATE took 1.6 s and a COPY 1.66 s, both of which write xART, so a slightly slower one would be abandoned while its writes are in flight. Use a 6000 ms floor on the 13.5 key-store profile. T6020 is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AJd8eEwJ4TGRSHnbKcWBmw
Contributor
Author
|
Closing: superseded. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closed: superseded; not pursuing this approach.