SE050: create ECDH derive target object for applet 7.2 middleware - #10971
Draft
LinuxJedi wants to merge 10 commits into
Draft
SE050: create ECDH derive target object for applet 7.2 middleware#10971LinuxJedi wants to merge 10 commits into
LinuxJedi wants to merge 10 commits into
Conversation
Middleware built for SE05x applet >= 07_02 (required for SE052) derives the ECDH shared secret with Se05x_API_ECDHGenerateSharedSecret_InObject, which requires TLV[TAG_7] to reference an existing HMACKey object sized exactly to the shared secret; otherwise the applet returns SW 0x6985 (conditions not satisfied). The port never created this object, so ECDH offload failed with WC_HW_E on such builds. Create the derive target as an HMACKey object of the exact secret size before the derive, for both ECC and Curve25519 shared secrets. Read the result back as AES type since sss_se05x_key_store_get_key has no HMAC read case.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes SE050 ECDH offload failures against SE05x applet >= 7.2 middleware by ensuring a correctly-sized derive-target object exists before calling the shared-secret derive APIs.
Changes:
- Allocate the ECDH derive target as an
HMACKeyobject (instead ofBinary) so applet 7.2+ can store the shared secret into an existing object. - Pre-create the derive-target object with the exact shared-secret size (ECC and Curve25519) prior to derivation.
- Read the derived secret back by temporarily treating the object as AES since
sss_key_store_get_key()lacks an HMAC read case.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Align se050_curve25519_shared_secret with the ECC path: set deriveKeyCreated only after sss_key_store_set_key succeeds, so the cleanup path cannot erase or free a derive key object whose handle was never allocated.
Bump SIMULATORS_REF to the simulator commit that supports HMACKey WriteSymmKey and the applet 7.2 ECDH InObject contract, and run the test container with SE050_SIM_STRICT_ECDH=1 so the simulator refuses an ECDH derive whose Tag7 target object was not pre-created. This is the failure mode seen on SE05x applet >= 7.2 hardware and reproduces it in CI against the unfixed port. The pinned simulator commit also consumes the WOLFSSL_EXTRA_CFLAGS build ARG, so the only-key-id matrix leg now really builds with -DWOLFSSL_SE050_ONLY_KEY_ID (previously the ARG was not consumed and the leg silently built the default configuration), and it fixes the simulator to derive the EC public key on private-only key pair import so wc_ecc_use_key_id can read the public part back. Raise the job timeout for cold image rebuilds until the weekend cron refreshes the registry cache for the new ref.
The previous pin abbreviated to the right commit but the full hash was invalid, so the simulator checkout step could never resolve it. Pin the full commit id of the merged simulator change.
Member
Author
|
Also fixes ZD#22212 |
Applet 7.2 denies ReadObject on a symmetric key object that was created with no policy attached, so the shared secret written into the derive target by Se05x_API_ECDHGenerateSharedSecret_InObject could not be exported: sss_key_store_get_key failed with SW 0x6986 (command not allowed) on SE05x applet >= 7.2 hardware. Create the derive target with an attached common policy granting read, write and delete. An attached policy replaces the applet default entirely, so write (the ECDH engine storing the result) and delete (the cleanup path) must be granted explicitly alongside read. Guarded by SSS_HAVE_SE05X_VER_GTE_07_02 so builds against older middleware keep creating the object with no policy attached.
Bump SIMULATORS_REF to the simulator commit that, in strict mode, refuses ReadObject on an HMACKey object unless the policy attached at creation grants POLICY_OBJ_ALLOW_READ. This reproduces the SW 0x6986 derive-target readback failure seen on SE05x applet >= 7.2 hardware (ZD 22212) and verifies the attached-policy fix in the previous commit. The pinned commit is wolfSSL/simulators PR wolfSSL#10 and becomes fetchable from the upstream clone once that PR is merged.
Member
Author
|
Updated PR with some missing policy pieces. |
Frauschi
requested changes
Jul 30, 2026
Frauschi
left a comment
Contributor
There was a problem hiding this comment.
@LinuxJedi PRB-master-job fails, as SSS_HAVE_SE05X_VER_GTE_07_02 is missing from .wolfssl_known_macro_extras. Otherwise LGTM.
LinuxJedi
marked this pull request as draft
July 30, 2026 12:39
Member
Author
|
I need to do further testing before I'm ready to call this good. |
Real SE050 hardware (applet 3.1.1, JCOP4) refuses ReadObject on a symmetric key object created without a read policy just like applet 7.2 does, and pre-7.2 middleware has no way to grant that policy: sss_policy_common_u can_Read maps to POLICY_OBJ_ALLOW_READ only for SSS_HAVE_SE05X_VER_GTE_07_02 builds and the symmetric key policy union has no read flag at all. Switching the derive target to an HMACKey object unconditionally therefore broke ECDH offload on applet 3.x parts with SW 0x6986 at the shared secret export. Restrict the HMACKey target and its attached read policy to SSS_HAVE_SE05X_VER_GTE_07_02 builds and restore the original Binary object flow otherwise: no pre-created target, erase before derive, and the middleware creates the object when storing the derived secret. Binary objects are readable without an attached policy. Verified on SE050C (applet 3.1.1) hardware: the ECC and CURVE25519 wolfCrypt tests fail with SW 0x6986 without this change and pass with it, matching master behavior on the same part. The applet 7.2 path is unchanged.
Bump SIMULATORS_REF to the simulator commit that refuses ReadObject on an HMACKey object without POLICY_OBJ_ALLOW_READ in all modes, matching real hardware on every applet generation as verified on SE050C applet 3.1.1 silicon. With this pin a plain (non-strict) CI run reproduces the SW 0x6986 readback failure that previously only appeared on hardware, covering the pre-7.2 Binary derive target fix in the previous commit. The pinned commit is wolfSSL/simulators PR wolfSSL#11 and becomes fetchable from the upstream clone once that PR is merged.
The SE050 port now keys the ECDH derive target type and read policy off the middleware's SSS_HAVE_SE05X_VER_GTE_07_02 feature macro.
The pinned simulator gained an sdk-test fix and review changes; move SIMULATORS_REF to the final wolfSSL/simulators PR wolfSSL#11 head. Becomes fetchable from the upstream clone once that PR is merged.
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.
Middleware built for SE05x applet >= 07_02 (required for SE052) derives the ECDH shared secret with Se05x_API_ECDHGenerateSharedSecret_InObject, which requires TLV[TAG_7] to reference an existing HMACKey object sized exactly to the shared secret; otherwise the applet returns SW 0x6985 (conditions not satisfied). The port never created this object, so ECDH offload failed with WC_HW_E on such builds.
Create the derive target as an HMACKey object of the exact secret size before the derive, for both ECC and Curve25519 shared secrets. Read the result back as AES type since sss_se05x_key_store_get_key has no HMAC read case.
Fixes zd#22069
Testing
wolfSSL/simulators#9