Skip to content

Add support for DICE attestation + PSA attestation#668

Open
danielinux wants to merge 26 commits intowolfSSL:masterfrom
danielinux:dice
Open

Add support for DICE attestation + PSA attestation#668
danielinux wants to merge 26 commits intowolfSSL:masterfrom
danielinux:dice

Conversation

@danielinux
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a DICE-based PSA Initial Attestation implementation (COSE_Sign1 token builder) and extends the TrustZone PSA plumbing so non-secure code can exercise PSA Crypto + Initial Attestation (plus new hash clone / cipher service IDs).

Changes:

  • Implement DICE token construction and expose it via the ARM TEE PSA attestation service path.
  • Extend the ARM TEE crypto shim with hash clone and basic cipher operations (setup/iv/update/finish/abort).
  • Update STM32H5 test app + build system/docs to enable and exercise PSA crypto + attestation from non-secure.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
zephyr/src/arm_tee_crypto_api.c Switches operation handle storage to opaque, adds hash clone and cipher PSA wrappers.
zephyr/include/arm_tee_crypto_defs.h Adds new service IDs for hash clone and cipher operations.
tools/keytools/otp/Makefile Adds wolfSSL path/config defines and optional hash objects for OTP primer.
tools/config.mk Introduces new config toggles for attestation IAK/test.
test-app/wcs/user_settings.h Gates PKCS11 settings on WOLFBOOT_TZ_PKCS11, enables AES-CBC and key export/PKCS formats.
test-app/hal_trng_psa.c Adds PSA-backed TRNG implementation for bare-metal test app.
test-app/arm_tee_ns_interface_stub.c Adds minimal non-Zephyr dispatcher stub for bare-metal PSA calls.
test-app/app_stm32h5.c Adds PSA init, PSA random, and PSA Initial Attestation test/printing flow.
test-app/Makefile Adds PSA/TZ build wiring, local wolfSSL object directory build rule, and attestation test toggle.
test-app/ARM-stm32h5.ld Exposes end symbol for linker compatibility.
test-app/ARM-stm32h5-ns.ld Exposes end symbol for linker compatibility (non-secure).
src/dice/dice.c New DICE claim collection + CBOR/COSE_Sign1 encoding and signing implementation.
src/arm_tee_psa_ipc.c Wires DICE token service into PSA attestation calls; adds hash clone + cipher slot dispatch.
options.mk Adds WOLFBOOT_ATTESTATION_IAK build flag and extra wolfCrypt objects for PSA TZ mode.
include/wolfboot/dice.h Public header for DICE token size/token generation APIs.
include/hal.h Adds attestation-related HAL hook declarations.
hal/stm32l5.c Implements basic UDS derivation and lifecycle for STM32L5.
hal/stm32h5.c Implements basic UDS derivation and lifecycle for STM32H5.
hal/hal.c Adds weak stub implementations for new attestation HAL hooks.
docs/Targets.md Documents STM32H5 WOLFBOOT_TZ_PSA behavior and points to DICE docs.
docs/STM32-TZ.md Adds PSA Initial Attestation section referencing DICE implementation.
docs/DICE.md New documentation describing DICE attestation protocol, HAL hooks, and usage.
Makefile Adds dice object to build when PSA/TZ is enabled (via new flag).
CMakeLists.txt Adds dice source to build when PSA/TZ is enabled (via new flag).

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

@danielinux
Copy link
Member Author

Addressed robot reviewer comments (all valid points), rebased on latest master, re-tested.

In particular, to fix the objection on the demo using UID as UDS, I've implemented three possible UDS mechanisms:

  • Stored in OTP alongwith the keystore (default if no extra option is specified)
  • OBKey UDS / iRoT on HDPL1 area (STM32H5 only) when WOLFBOOT_UDS_OBKEYS=1 is selected
  • Test-only fallback with WOLFBOOT_UDS_UID_FALLBACK_FORTEST=1, uses UID as before in this PR (as noted in the review, should not be used for attestation in production)

@dgarske dgarske removed their assignment Jan 27, 2026
@danielinux
Copy link
Member Author

Depends on wolfPSA/#3

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

Copilot has a few things that need fixed still too.

hal/stm32l5.c Outdated
wc_Sha256Update(&hash, uid, sizeof(uid));
wc_Sha256Final(&hash, digest);
copy_len = sizeof(digest);
#else
Copy link
Contributor

Choose a reason for hiding this comment

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

What about SHA3?

Copy link
Member Author

Choose a reason for hiding this comment

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

adding sha3 case

Address rewiewer's comment:

Sensitive key material (cdi, seed, priv) is derived and stored on-stack. Consider explicitly zeroizing these buffers on all return paths once the ECC key has been imported, to reduce the lifetime of UDS/CDI-derived material in memory (especially since this is long-term attestation key material).

Renaming for alignment with existing config parameters:
WOLFBOOT_TZ_PSA -> WOLFCRYPT_TZ_PSA
@danielinux danielinux requested a review from dgarske February 6, 2026 06:58
@danielinux danielinux assigned dgarske and unassigned danielinux Feb 6, 2026
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.

3 participants