feat(apple): surface CryptoKit error details through FFI bridge#159
Merged
Conversation
The Swift bridge previously swallowed CryptoKit exception details in catch blocks, returning only numeric error codes (e.g. SE_ERR_GENERATE=1). This made it impossible to diagnose why SE key operations failed on managed devices. Add enclaveapp_se_last_error() FFI function that exposes the last CryptoKit/Security error string. Update all 7 catch blocks to call setLastError() before returning, and update all Rust FFI error sites (keychain.rs, sign.rs, encrypt.rs) to query and include the detail.
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.
Summary
enclaveapp_se_last_error()FFI function to the Swift bridge that exposes the last CryptoKit/Security error stringbridge.swiftto callsetLastError()with the exception detail before returning numeric error codeskeychain.rs,sign.rs,encrypt.rs) to querylast_bridge_error()and include the detail in error messagesExample
Before:
FFI returned error code 1After:
FFI returned error code 1: key generation failed: A required entitlement isn't present.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --all-targets(all 269+ tests pass)