You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(apple): handle errSecInteractionNotAllowed and change keychain protection class (#158)
* fix(apple): handle errSecInteractionNotAllowed (-25308) in keychain load
The Swift bridge checked only errSecInteractionRequired (-25315, CSSM
layer) but SecItemCopyMatching returns errSecInteractionNotAllowed
(-25308) after sleep/wake. The mismatch caused all post-sleep keychain
errors to fall through to the generic SE_ERR_KEYCHAIN_LOAD (code 10),
bypassing the dedicated recovery paths for codes 14/15.
Add errSecInteractionNotAllowed to the status check so the correct
error code propagates to Rust. Also expose cache_evict_for() and add
evict_wrapping_key_cache() to EnclaveSigner so callers can force a
fresh keychain load with a new LAContext on transient failures.
* fix(apple): use AfterFirstUnlockThisDeviceOnly for keychain protection class
WhenUnlockedThisDeviceOnly purges the keybag class key from memory on
device lock/sleep, making wrapping keys inaccessible to background
agents after sleep/wake. AfterFirstUnlockThisDeviceOnly keeps the class
key in memory from first unlock until reboot, which is the correct
behavior for an SSH agent that must sign in the background.
Changes:
- keychain_store: all protection class references changed from
WhenUnlockedThisDeviceOnly to AfterFirstUnlockThisDeviceOnly
(userPresence path, non-userPresence path, and both fallback paths)
- makeAccessControl: same protection class change for SE key generation
with auth_policy, plus proper error capture via CFError
- decrypt_with_cached_key: on non-cached keychain load, re-stores the
wrapping key to transparently migrate existing items to the new
protection class
- Swift bridge: add last-error detail mechanism (setLastError /
enclaveapp_se_last_error FFI) so Rust callers get CryptoKit and
SecAccessControl error descriptions instead of bare error codes
- ffi.rs: declare enclaveapp_se_last_error extern
- keychain.rs: read and surface bridge error details in GenerateFailed
---------
Co-authored-by: Jay Gowdy <jay@gowdy.me>
0 commit comments