SE050Sim: enforce applet 7.2 ECDH InObject target contract - #9
Merged
Conversation
Per the SE05x IoT applet spec (Se05x_API_ECDHGenerateSharedSecret in the Plug & Trust middleware), the TAG_7 shared-secret target must be an existing HMACKey object sized exactly to the shared secret; otherwise the applet returns SW 0x6985. The simulator previously created the target implicitly, which masked a wolfSSL port bug that fails on real hardware (SE052, or any middleware build for applet >= 07_02). - handle_ecdh now requires a pre-existing HMACKey object of exact size and overwrites its value on success - add the WriteSymmKey P1_HMAC dispatch route and handler so callers can create the target object - update sdk-test ECDH/X25519 tests to the documented pre-create sequence, reading the result back as AES type (the middleware get_key has no HMAC read case) - add unit tests covering the strict contract and the HMAC key write
Member
Author
|
Draft because this requires wolfSSL/wolfssl#10971 to be merged (chicken / egg scenario) |
There was a problem hiding this comment.
Pull request overview
This PR updates the SE050 simulator to match the SE05x IoT applet 7.2+ ECDH “InObject” contract by requiring Tag7 to reference a pre-existing, correctly-sized HMACKey object (rather than implicitly creating a binary output), and updates simulator/SDK tests accordingly.
Changes:
- Enforce Tag7 target existence/type/size for ECDH shared-secret generation and overwrite the existing HMACKey value on success.
- Add WriteSymmKey P1=HMAC dispatch + handler to allow creating/writing HMACKey objects via the simulator APDU interface.
- Update SDK-test ECDH and X25519 flows to pre-create the HMACKey target and read the result back via AES read path; add unit tests for the strict Tag7 contract and HMAC write.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| SE050Sim/se050-sim/src/handlers/ec.rs | Enforces pre-existing HMACKey Tag7 target for ECDH InObject and adds unit tests for missing/wrong-type/wrong-size/success cases. |
| SE050Sim/se050-sim/src/handlers/aes.rs | Adds a WriteSymmKey(P1=HMAC) handler to store HMACKey objects; includes dispatch-level tests. |
| SE050Sim/se050-sim/src/dispatch.rs | Routes INS_WRITE + P1_HMAC to the new HMAC write handler. |
| SE050Sim/sdk-test/test_se050.c | Updates ECDH and X25519 tests to pre-create an HMAC target object and read the derived secret back as AES. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Three changes to keep wolfSSL and simulators CI green while the applet 7.2 ECDH InObject fix lands in wolfSSL: - Make the strict ECDH InObject target contract opt-in via the SE050_SIM_STRICT_ECDH=1 environment variable. By default a missing Tag7 target falls back to the legacy implicit-create Binary behavior so wolfSSL builds that predate the fix keep passing. A pre-existing HMACKey target gets the exact-size contract in both modes. - Derive the EC public key when a private-only key pair is imported (NIST P-224/P-256/P-384 and Curve25519, matching Ed25519). ReadObject returns the public part of an asymmetric object and hosts parse it: wc_ecc_use_key_id failed with ASN_PARSE_E on the empty public key. - Consume WOLFSSL_EXTRA_CFLAGS as a build ARG in Dockerfile.wolfcrypt (Pass-B configure and the test binary compiles). wolfSSL CI passes it for the WOLFSSL_SE050_ONLY_KEY_ID matrix leg but nothing consumed it, so that leg silently built the default configuration.
LinuxJedi
marked this pull request as ready for review
July 23, 2026 11:20
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.
Per the SE05x IoT applet spec (Se05x_API_ECDHGenerateSharedSecret in the Plug & Trust middleware), the TAG_7 shared-secret target must be an existing HMACKey object sized exactly to the shared secret; otherwise the applet returns SW 0x6985. The simulator previously created the target implicitly, which masked a wolfSSL port bug that fails on real hardware (SE052, or any middleware build for applet >= 07_02).