Skip to content

Shrink the Secure PSA profiles with direct P-256 and one AEAD option - #93

Merged
dgarske merged 20 commits into
wolfSSL:mainfrom
aidangarske:secure-psa-size-profiles
Nov 30, 2026
Merged

dgarske merged 20 commits into
wolfSSL:mainfrom
aidangarske:secure-psa-size-profiles

Conversation

@aidangarske

@aidangarske aidangarske commented Nov 23, 2026 •

Copy link
Copy Markdown
Member
  • Build levels are now tiny, small, default and extended everywhere (was symmetric, lean, standard, compat/full), WT_TIER is smoke|all, and WT_TEST_PROFILES replaces WT_PROFILE=both
  • The build default is now the default profile (GCM and CCM, CTR, P-256 ECDSA and ECDH, SHA-256, HMAC, HKDF); CBC, ECB, PBKDF2, the TLS 1.2 PRF, SP 800-108, CCM* and deterministic ECDSA move to extended
  • Outside extended, P-256 runs on wolfPSA's direct SP path, so ecc.c and sp_int leave the image; extended keeps them for deterministic ECDSA
  • New WT_AEAD=gcm|ccm replaces WT_VAULT_AEAD and picks both the vault AEAD and the single PSA AEAD of small and tiny (CCM by default)
  • The vault's CCM and GCM run on wolfPSA's streaming AEAD instead of a second wolfCrypt copy, and wolfPSA maps wolfCrypt errors through a table
  • tiny links no ECC: attestation tokens are COSE_Mac0 HMAC 256/256 (WT_ATTEST_KEY=hmac) and the vault refuses P-256 (WT_VAULT_ECC=0). Both flags work on any profile, and ECC drops out of the image only when nothing uses it
  • The HMAC key comes from the port hook wt_port_attest_hmac_key(); reference ports link a public development key and the build warns (WT_ATTEST_DEV_KEY=0 makes the port supply its own). The Instance ID follows the RFC 9783 Appendix A.2 example, which is also the known-answer test
  • The crypto partition stack is 6 KiB in extended and 5 KiB in the other profiles, sized from measured peaks, and the crypto data band shrinks to the wolfPSA pool plus 1,536 B
  • Migration: a device that sealed with GCM under lean or symmetric with Secure PSA must build with WT_AEAD=gcm; a build that relied on compat as the default must now set WT_PROFILE=extended
  • CI builds tiny on every port and checks that no ECC symbol links, builds each new flag on its own, rejects bad values and WT_ATTEST_DEV_KEY=0 without a port key, and checks each small WT_AEAD value links only the chosen AEAD, and that small and tiny keep GCM with WT_SECURE_PSA=0
  • New host suites attestation_hmac (token layout, independent HMAC verify, RFC vector) and attest_restore (key reload after a partition restart), plus no-ECC variants of native_wire, attestation_service and psa_secure_crypto
  • An HMAC key answers the IAK public-key query with PSA_ERROR_NOT_SUPPORTED, so the client is not panicked as it would be for an unknown operation
  • The PSA guest expects P-256 to be refused only under the tiny Secure PSA profile, which is what the Secure image refuses, not under WT_VAULT_ECC=0
  • Rebased on main 04a2eed with lib/wolfPSA pinned to the wolfPSA Reduce TPM2 and PKCS11 size and cover both crypto engines #81 merge 58f92697
  • Tested on this tree: every host suite on gcc and clang (101 of 101 each), conformance, qcbor, the manifest render check, and all five cross-compile legs in the CI image; earlier commits also ran ASAN, valgrind, both C99 jobs, all 12 mergecheck builds, and M33MU H563 positive, devcrypto, devcryptolocal, nativewire and tinyattest
  • New M33MU scenario tinyattest on all 4 ports builds tiny with Secure PSA, faults the attestation partition so it restarts on a reset band, then has the guest verify the COSE_Mac0 under the development key (Instance ID included), reject a tampered token and see P-256 refused, and checks no P-256 symbol is linked
  • With an HMAC attestation key the manifest drops the attestation partition's SERVICE_HSM dependency (new generator --drop-dependency), so that partition can no longer connect to the crypto service
  • Sizes below and in the docs are measured in the CI image (Arm GNU 15.2.1, LTO) on this tree and on main 04a2eed; the docs cover every port, including the in-tree STM32L562
  • needs Trim the Secure PSA build with shared AEAD paths and narrower gates wolfPSA#81 merged first
  • repin to 81 main when done
STM32H563 (bytes) main flash This PR flash Change main Secure RAM This PR Secure RAM Change
Build default (compat on main, default here) 109,845 94,343 −15,502 48,880 47,344 −1,536
compat crypto set / WT_SECURE_PSA_PROFILE=extended 109,845 106,069 −3,776 48,880 48,368 −512
standard / default 103,095 94,343 −8,752 48,880 47,344 −1,536
lean / small 101,399 91,207 −10,192 48,880 47,344 −1,536
symmetric / tiny (no ECC) 96,663 75,727 −20,936 48,880 47,268 −1,612
full / extended with add-ons 119,284 115,828 −3,456 64,420 63,908 −512
WT_SECURE_PSA=0 70,780 70,780 0 45,296 45,296 0

@aidangarske aidangarske self-assigned this Nov 23, 2026
@aidangarske aidangarske added the ci:all Run every M33MU scenario of every port on the PR (core change) label Nov 23, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #93

Scan targets checked: wolftrust-src, wolftrust-bugs
Not reviewed (no scan target covers them): .github/workflows/cross-compile.yml, docs/Crypto-Engines.md, docs/Macros.md, docs/Security-Model.md, docs/Services.md, docs/TF-M-Compatibility.md, docs/Threat-Model.md, mk/common.mk, tests/host/Makefile, tests/host/keystore_ipc/Makefile, tests/host/keystore_ipc/user_settings.h, tests/host/native_wire/Makefile, tests/host/native_wire/user_settings.h, tests/host/negatives/Makefile, tests/host/negatives/user_settings.h, tests/host/nvm_boot/Makefile, tests/host/ps_service/Makefile, tests/host/ps_service/user_settings.h, tests/host/psa_secure_crypto/Makefile, tests/host/psa_secure_crypto/user_settings.h and 3 more
Coverage: 12 of 14 in-scope changed file(s) opened by the reviewer; not opened: src/services/wolfhsm/wt_hsm_aead.c, tests/host/psa_storage_client/main.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #93

Scan targets checked: none
Unchanged since last review (not re-run): wolftrust-src, wolftrust-bugs
Not reviewed (no scan target covers them): .github/workflows/cross-compile.yml, docs/Crypto-Engines.md, docs/Macros.md, docs/Security-Model.md, docs/Services.md, docs/TF-M-Compatibility.md, docs/Testing.md, docs/Threat-Model.md, mk/common.mk, mk/layout.mk, port/mcxn947/port.json, port/mimxrt700/port.json, port/stm32h563/port.json, port/stm32l562/port.json, tests/host/Makefile, tests/host/keystore_ipc/Makefile, tests/host/keystore_ipc/user_settings.h, tests/host/manifest_render/test_manifest_render.py, tests/host/native_wire/Makefile, tests/host/native_wire/user_settings.h and 12 more

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@aidangarske
aidangarske force-pushed the secure-psa-size-profiles branch 2 times, most recently from 18ca33d to e5dcfcd Compare November 24, 2026 20:22
@aidangarske
aidangarske marked this pull request as draft November 25, 2026 21:50
@aidangarske
aidangarske force-pushed the secure-psa-size-profiles branch from 62f6b99 to 720ee1b Compare November 30, 2026 20:07
@aidangarske
aidangarske marked this pull request as ready for review November 30, 2026 20:12

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #93

Scan targets checked: wolftrust-src, wolftrust-bugs
Not reviewed (no scan target covers them): .github/workflows/README.md, .github/workflows/cross-compile.yml, AGENTS.md, Makefile, README.md, docs/Architecture.md, docs/Building.md, docs/Crypto-Engines.md, docs/Footprint.md, docs/Interface-Profiles.md, docs/MCXN947-Guide.md, docs/MIMXRT700-Guide.md, docs/Macros.md, docs/PKCS11.md, docs/Porting.md, docs/Ports.md, docs/STM32H5-Guide.md, docs/STM32L562-Guide.md, docs/Security-Model.md, docs/Services.md and 54 more
Coverage: 9 of 25 in-scope changed file(s) opened by the reviewer; not opened: include/wolftrust/services/hsm.h, include/wolftrust/services/hsm_relay.h, include/wolftrust/services/initial_attestation.h, port/common/attest_dev_key.c, src/services/attestation_service.c, src/services/hsm_relay_service.c, src/services/native/crypto_native.c, tests/firmware/interface-guest/tpm_tests.c, tests/firmware/psa-guest/main.c, tests/firmware/zephyr-stm32h5/apps/guest0_psa/src/attestation_verify.c and 6 more

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@dgarske
dgarske merged commit badb7dc into wolfSSL:main Nov 30, 2026
434 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:all Run every M33MU scenario of every port on the PR (core change)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants