-
Notifications
You must be signed in to change notification settings - Fork 959
SE050 fixes and new simulator tests #10196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: SE050 simulator test | ||
|
|
||
| # START OF COMMON SECTION | ||
| on: | ||
| push: | ||
| branches: [ 'master', 'main', 'release/**' ] | ||
| pull_request: | ||
| branches: [ '*' ] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| # END OF COMMON SECTION | ||
|
|
||
| # Build the SE050 software simulator (https://github.com/LinuxJedi/SE050Sim), | ||
| # build wolfSSL against its NXP Plug&Trust SDK + simulator bridge, and run the | ||
| # wolfCrypt SE050 test binary against the simulator TCP server. | ||
| # | ||
| # The simulator's own Dockerfile (Dockerfile.wolfcrypt) clones wolfSSL master. | ||
| # We patch it to COPY the PR checkout instead so CI reflects the PR's source. | ||
|
|
||
| env: | ||
| # Pin the simulator to a known-good revision. Bump this deliberately after | ||
| # validating upstream changes in a standalone PR. | ||
| SE050SIM_REF: main | ||
|
|
||
| jobs: | ||
| se050_sim: | ||
| name: wolfCrypt against SE050 simulator | ||
| if: github.repository_owner == 'wolfssl' | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Checkout wolfSSL (PR source) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: wolfssl-src | ||
|
|
||
| - name: Clone SE050 simulator | ||
| run: | | ||
| git clone https://github.com/LinuxJedi/SE050Sim se050sim | ||
| cd se050sim && git checkout "$SE050SIM_REF" | ||
|
|
||
| - name: Stage PR wolfSSL into simulator build context | ||
| run: mv wolfssl-src se050sim/wolfssl | ||
|
|
||
| - name: Patch Dockerfile to use PR wolfSSL instead of upstream master | ||
| working-directory: se050sim | ||
| run: | | ||
| sed -i 's|^RUN git clone --depth 1 https://github.com/wolfSSL/wolfssl.git /app/wolfssl$|COPY wolfssl /app/wolfssl|' Dockerfile.wolfcrypt | ||
| # Fail fast if the pattern drifted upstream — better a clear error | ||
| # than a CI run that silently tests master. | ||
| grep -q '^COPY wolfssl /app/wolfssl$' Dockerfile.wolfcrypt | ||
| ! grep -q 'git clone .*wolfssl\.git' Dockerfile.wolfcrypt | ||
|
|
||
| - uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build wolfCrypt-SE050 test image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: se050sim | ||
| file: se050sim/Dockerfile.wolfcrypt | ||
| push: false | ||
| load: true | ||
| tags: wolfssl-se050-sim:ci | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Run wolfCrypt tests against simulator | ||
| run: docker run --rm wolfssl-se050-sim:ci | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1169,6 +1169,12 @@ int wc_ed25519_import_public_ex(const byte* in, word32 inLen, ed25519_key* key, | |||||||||||||||||||||||
| if (inLen < ED25519_PUB_KEY_SIZE) | ||||||||||||||||||||||||
| return BAD_FUNC_ARG; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #ifdef WOLFSSL_SE050 | ||||||||||||||||||||||||
| /* Importing new key material invalidates any prior SE050 object binding. */ | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| /* Importing new key material invalidates any prior SE050 object binding. */ | |
| /* Importing new key material invalidates any prior SE050 object binding. */ | |
| if (key->keyIdSet == 1) { | |
| se050_ed25519_free_key(key); | |
| } |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the SE050 build, clearing key->keyIdSet/key->keyId on private-only import drops the binding but does not erase the previously-uploaded SE050 object. Because se050_ed25519_free_key() only erases when keyIdSet==1, this can leak transient key objects (and leave stale key material) when reusing an ed25519_key for multiple imports. Consider calling se050_ed25519_free_key(key) (or otherwise erasing the old object when keyIdSet==1) before resetting these fields.
| /* Importing new key material invalidates any prior SE050 object binding. */ | |
| /* Importing new key material invalidates any prior SE050 object binding. */ | |
| if (key->keyIdSet) { | |
| se050_ed25519_free_key(key); | |
| } |
Copilot
AI
Apr 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the SE050 build, clearing key->keyIdSet/key->keyId on private+public import drops the binding but does not erase the previously-uploaded SE050 object. Because se050_ed25519_free_key() only erases when keyIdSet==1, this can leak transient key objects (and leave stale key material) when reusing an ed25519_key for multiple imports. Consider calling se050_ed25519_free_key(key) (or otherwise erasing the old object when keyIdSet==1) before resetting these fields.
| /* Importing new key material invalidates any prior SE050 object binding. */ | |
| /* Importing new key material invalidates any prior SE050 object binding. | |
| * If this key was previously uploaded to SE050, erase that object before | |
| * dropping the binding metadata. | |
| */ | |
| if (key->keyIdSet == 1) { | |
| ret = se050_ed25519_free_key(key); | |
| if (ret != 0) { | |
| return ret; | |
| } | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1538,8 +1538,22 @@ int se050_rsa_verify(const byte* in, word32 inLen, byte* out, word32 outLen, | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (status == kStatus_SSS_Success) { | ||||||||||||||||||||||||
| key->keyId = keyId; | ||||||||||||||||||||||||
| key->keyIdSet = 1; | ||||||||||||||||||||||||
| if (keyCreated) { | ||||||||||||||||||||||||
| /* We uploaded only the public part of the key for this verify. | ||||||||||||||||||||||||
| * Don't persist keyIdSet=1 — a later sign on the same RsaKey | ||||||||||||||||||||||||
| * would reuse this binding and fail because the SE050 object has | ||||||||||||||||||||||||
| * no private material. Erase the transient object so the next | ||||||||||||||||||||||||
| * SE050 op (sign or verify) re-uploads from whatever the host | ||||||||||||||||||||||||
| * RsaKey currently holds. */ | ||||||||||||||||||||||||
| sss_key_store_erase_key(&host_keystore, &newKey); | ||||||||||||||||||||||||
| sss_key_object_free(&newKey); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||
| /* Pre-existing keyIdSet=1 binding (e.g. wc_RsaUseKeyId or prior | ||||||||||||||||||||||||
| * sign that uploaded a keypair). Preserve it. */ | ||||||||||||||||||||||||
| key->keyId = keyId; | ||||||||||||||||||||||||
| key->keyIdSet = 1; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||
| if (keyCreated) { | ||||||||||||||||||||||||
|
|
@@ -3039,6 +3053,8 @@ int se050_ed25519_verify_msg(const byte* signature, word32 signatureLen, | |||||||||||||||||||||||
| key, signature, signatureLen, msg, msgLen); | ||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| *res = 0; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
3055
to
+3057
|
||||||||||||||||||||||||
| *res = 0; | |
| if (res == NULL) { | |
| return BAD_FUNC_ARG; | |
| } | |
| *res = 0; | |
| if (signature == NULL || msg == NULL || key == NULL) { | |
| return BAD_FUNC_ARG; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow comment says the simulator is pinned to a "known-good revision", but
SE050SIM_REFis set tomain, which is a moving target and can make CI non-reproducible. Pin this to an immutable ref (tag or commit SHA), and update it intentionally when validating upstream changes.