Skip to content

SE050Sim: add SE050E applet personality, fix GetFreeMemory reply width - #14

Merged
LinuxJedi merged 2 commits into
wolfSSL:mainfrom
LinuxJedi:se050e-personality
Aug 7, 2026
Merged

SE050Sim: add SE050E applet personality, fix GetFreeMemory reply width#14
LinuxJedi merged 2 commits into
wolfSSL:mainfrom
LinuxJedi:se050e-personality

Conversation

@LinuxJedi

Copy link
Copy Markdown
Member

Summary

Follow-up to #13: an SE050E was probed on the same hardware rig with the same raw Se05x_API_* probe set, plus a new RSA-surface probe and a full wolfCrypt-suite run on the silicon. Two outcomes: a third applet personality, and a hardware-verified fix to the existing 7.2.0 personality.

SE050E personality (new)

SE050_SIM_APPLET=e / se050e (any value ending in e) selects an SE050E: IoT applet 7.2.0 with the RSA feature bits disabled. On the bench it matched the SE051 on the entire existing probe matrix (GetRandom cap 1018, curve-specific ReadType codes, duplicate CreateECCurve refused 0x6985 with the curve intact, ECDSA digest-length enforcement, identical NIST/RFC cipher and MAC vectors, stateful curves with parameterized P-521/P-192 fully working; even the ATR historical bytes read "eSE051"). The modelled differences:

Behavior SE051 7.2.0 SE050E 7.2.0
SELECT / GetVersion blob 07 02 00 3f ff ff ff 07 02 00 3f 9f ff ff
GetFreeMemory values 21000/605/592 32767/796/784 (PERSISTENT clamped at 0x7FFF)
RSA keygen (any size/format) works 0x6985
RSA key import works 0x6A80

The appletConfig delta (0x3f9f vs 0x3fff) clears exactly kSE05x_AppletConfig_RSA_PLAIN (0x0020) and kSE05x_AppletConfig_RSA_CRT (0x0040): the SE050E has no RSA at all. Running the full wolfCrypt suite (--with-se050 Pass-B build) against the real part passes every test up to and including AES-GCM, then fails the RSA test with WC_HW_E (-248) and aborts - there is no software fallback. wolfSSL builds targeting SE050E parts must disable RSA offload; the simulator now reproduces that failure mode faithfully (keygen 0x6985, import 0x6A80, ops on the never-created objects 0x6985).

GetFreeMemory reply width fix (7.2.0 personality)

The 7.2.0 personality previously replied with a 4-byte value, from a misreading of the v04.07.01 middleware. The middleware's U32 parse path is gated on SE05X_CHECK_52F_VERSION (applet minor 0x10-0x1F, the SE052F family) and never runs for these applets; its tlvGet_U16 rejects TLV values longer than 2 bytes and succeeded against all three bench parts, proving they all reply U16. The 4-byte reply would make Se05x_API_GetFreeMemory fail host-side against the simulator. All personalities now reply with 2-byte values.

Test plan

  • cargo test -- --test-threads=1: 76 lib + 14 driver integration tests pass.
  • New tests pin the SE050E version blob, the RSA keygen/import refusal SWs (and that the SE051 personality keeps RSA), the per-part free-memory values and 2-byte width, the 1018 GetRandom cap, and the SE050_SIM_APPLET token parsing.
  • CI tiers run the default SE051 personality and are unaffected; pointing the sdk-test tier at the E personality would fail its RSA leg, which is the faithful-to-silicon behavior.

Bench-probed an SE050E on the hardware rig. The part runs IoT applet
7.2.0 and matches the SE051 on the entire probe matrix (GetRandom cap
1018, curve-specific ReadType codes, duplicate CreateECCurve refused
0x6985, ECDSA digest-length enforcement, identical cipher/MAC vectors,
stateful curves) except for three differences, now modelled as a third
applet personality selected with SE050_SIM_APPLET=e / se050e:

- Version blob 07 02 00 3f 9f ff ff: the appletConfig word clears
  exactly RSA_PLAIN (0x0020) and RSA_CRT (0x0040).
- No RSA at all: keygen refused 0x6985 for every size and format,
  key import refused 0x6a80. The wolfCrypt suite against real SE050E
  silicon passes through AES-GCM then fails RSA with WC_HW_E and
  aborts; there is no software fallback.
- GetFreeMemory values 32767/796/784, PERSISTENT clamped at 0x7fff.

Also fixes the 7.2.0 personality's GetFreeMemory reply width: all
bench applets reply with a 2-byte value. The earlier 4-byte encoding
came from misreading the v04.07.01 middleware, whose U32 parse path is
gated on SE05X_CHECK_52F_VERSION (applet minor 0x10-0x1f, the SE052F
family) and never runs for these applets; tlvGet_U16 rejects TLV
values longer than 2 bytes, so the U32 reply would make
Se05x_API_GetFreeMemory fail host-side.
Copilot AI lite review requested due to automatic review settings August 7, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the SE050Sim personality model to cover SE050E (applet 7.2.0 with RSA feature bits disabled) and corrects the GetFreeMemory response encoding to match bench-verified behavior across all supported parts.

Changes:

  • Add an SE050E applet personality (SE050_SIM_APPLET tokens ending in e) and model RSA refusal semantics for keygen/import.
  • Fix GetFreeMemory replies to always return 2-byte values (U16) for all personalities, and update tests to pin per-personality values.
  • Update per-version behavior tables/tests (GetVersion blob, GetRandom cap, duplicate curve create behavior).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
SE050Sim/se050-sim/src/handlers/rsa.rs Add personality-gated RSA key write behavior and tests for SE050E refusal vs SE051 support.
SE050Sim/se050-sim/src/handlers/management.rs Update GetFreeMemory documentation/tests to assert U16 width and SE050E-specific values; extend GetRandom tests for SE050E.
SE050Sim/se050-sim/src/handlers/curve.rs Treat SE050E like SE051 for duplicate curve creation refusal behavior.
SE050Sim/se050-sim/src/dispatch.rs Pass applet version into RSA write handler (and should treat SE050E as “v7” for read semantics).
SE050Sim/se050-sim/src/applet.rs Add SE050E personality, version bytes, GetRandom cap mapping, RSA support trait, and updated GetFreeMemory width/value modeling + tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SE050Sim/se050-sim/src/applet.rs
Comment thread SE050Sim/se050-sim/src/applet.rs
Comment thread SE050Sim/se050-sim/src/dispatch.rs
The dispatch v7 flag was computed as version == V7_2_0, so the SE050E
personality would have received the 3.1.1 generic ReadType codes.
Bench runs show the SE050E reports the same curve-specific codes as
the SE051 (P-256 pair 0x29, P-521 pair 0x31); add is_v7() covering
both 7.2 parts and use it in dispatch.

Split token parsing out of from_env into from_token with the
ending-in-e rule taking precedence over the leading-3 rule, matching
the documented behavior for tokens like 3e, and rewrite the parsing
test against from_token so it no longer mutates the process
environment.
@LinuxJedi
LinuxJedi merged commit 6cd9dee into wolfSSL:main Aug 7, 2026
21 checks passed
@LinuxJedi
LinuxJedi deleted the se050e-personality branch August 7, 2026 15:33
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.

2 participants