SE050Sim: always enforce symmetric key read policy - #11
Merged
LinuxJedi merged 2 commits intoJul 30, 2026
Conversation
Testing on real SE050C hardware (applet 3.1.1, JCOP4) showed ReadObject on a symmetric key object created without POLICY_OBJ_ALLOW_READ is refused with SW 0x6986 on every applet generation, not only applet 7.2. Enforcing it only in SE050_SIM_STRICT_ECDH mode let a real regression through plain CI runs: an ECDH derive target switched to an HMACKey object without an attached read policy passed the lenient simulator but fails on applet 3.x silicon, where the middleware cannot grant such a policy at all. Enforce the read policy on HMACKey objects unconditionally and drop the strict parameter from the read path; SE050_SIM_STRICT_ECDH now gates only the applet 7.2 ECDH InObject target contract. Binary objects stay readable with no policy attached, which the pre-7.2 derive flow relies on (also confirmed on hardware).
There was a problem hiding this comment.
Pull request overview
This PR updates the SE050 simulator to match observed SE050C hardware behavior by enforcing the symmetric-key (HMACKey) ReadObject policy check unconditionally (not only under SE050_SIM_STRICT_ECDH), while keeping strict mode focused on the ECDH InObject target contract.
Changes:
- Make
ReadObjectdeny HMACKey reads unlessPOLICY_OBJ_ALLOW_READis present, regardless of strict mode. - Simplify
handle_readby removing thestrictparameter and updating dispatch accordingly. - Update and extend tests to reflect the new always-enforced behavior and to pin Binary object readability.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| SE050Sim/se050-sim/src/handlers/object_mgmt.rs | Removes strict-mode gating for HMACKey ReadObject policy enforcement and updates tests. |
| SE050Sim/se050-sim/src/handlers/ec.rs | Clarifies that SE050_SIM_STRICT_ECDH only controls the ECDH InObject target contract, not read policy. |
| SE050Sim/se050-sim/src/dispatch.rs | Updates dispatch to call the new handle_read signature without a strict flag. |
Comments suppressed due to low confidence (1)
SE050Sim/se050-sim/src/handlers/object_mgmt.rs:244
- This comment says the applet refuses to export a “symmetric key object”, but the check below is specific to HMACKey. Tightening the wording avoids implying that AESKey reads are also guarded here.
// The applet refuses to export a symmetric key object
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The always-on HMACKey read policy enforcement caught the sdk-test suite doing what real hardware refuses: deriving into an HMACKey object created with no policy and reading the shared secret back. Create the P-256 and X25519 derive targets with a common policy granting read, write and delete, the same recipe wolfSSL's port uses. Also narrow the read-policy doc comments to HMACKey (AESKey objects are not policy-tracked by the simulator yet, though real applets guard them the same way) and assert the Binary no-policy read test returns the stored payload, both from review.
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.
Motivation
Testing on real SE050C hardware (applet 3.1.1, JCOP4) showed that ReadObject on a symmetric key object created without
POLICY_OBJ_ALLOW_READis refused with SW 0x6986 on every applet generation, not just applet >= 7.2 as PR #10 assumed. The simulator only enforced this inSE050_SIM_STRICT_ECDH=1mode, so plain CI runs missed a real regression: the wolfSSLse050_applet72_ecdhbranch switched its ECDH derive target to an HMACKey object unconditionally, which passed the lenient simulator but fails with 0x6986 on applet 3.x silicon (pre-7.2 middleware cannot grant a read policy on symmetric objects at all).Changes
handle_readloses itsstrictparameter again;SE050_SIM_STRICT_ECDHnow gates only the ECDH InObject target contract, and its doc comment says so explicitly.Validation
cargo test: 36 lib + 14 integration tests pass.SE050_SIM_STRICT_ECDH:se050_applet72_ecdhtip (HMACKey + read policy on >= 7.2 builds, Binary flow otherwise): full suite passes.The wolfSSL branch CI pin (
SIMULATORS_REF) should be bumped to this PR's head once merged.