Skip to content

SE050: create ECDH derive target object for applet 7.2 middleware#10971

Open
LinuxJedi wants to merge 4 commits into
wolfSSL:masterfrom
LinuxJedi:se050_applet72_ecdh
Open

SE050: create ECDH derive target object for applet 7.2 middleware#10971
LinuxJedi wants to merge 4 commits into
wolfSSL:masterfrom
LinuxJedi:se050_applet72_ecdh

Conversation

@LinuxJedi

Copy link
Copy Markdown
Member

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

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HMACKey object (instead of Binary) 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.

Comment thread wolfcrypt/src/port/nxp/se050_port.c Outdated
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +80 B, .text -2,752 B (-0.3%, 769,212 B / 1,048,576 B, total: 73% used)
  • RAM: .bss +192 B (+0.1%, 136,936 B / 262,144 B, total: 52% used)

linuxkm-standard

  • Data: __patchable_function_entries +8 B (+0.0%, 48,616 B)

stm32-sim-stm32h753

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.

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants