Skip to content

Add OP-TEE heap, RNG and time platform support under WOLFSSL_OPTEE - #11927

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:optee_platform
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:optee_platform

Conversation

@dgarske

@dgarske dgarske commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Description

Extending the new WOLFSSL_OPTEE build option added in #11919 making a trusted OP-TEE application work without a per-project platform file.

  • types.h - a WOLFSSL_OPTEE branch in the allocator chain, mapping XMALLOC, XFREE and XREALLOC onto TEE_Malloc, TEE_Free and TEE_Realloc. A trusted application links libutee rather than a C library and has no std heap. TEE_MALLOC_FILL_ZERO, so an allocation never carries another one's bytes. Placed after XMALLOC_OVERRIDE so an explicit override still wins, and shaped like the WOLFSSL_TELIT_M2MB branch beside it, including the WOLFSSL_XFREE_NO_NULLNESS_CHECK variant.
  • random.c - a wc_GenerateSeed for WOLFSSL_OPTEE on TEE_GenerateRandom, plus the matching entry in the platform include chain. It seeds the DRBG rather than replacing it, so a build that would rather use the TEE RNG directly can still set CUSTOM_RAND_GENERATE_BLOCK.
  • internal.c, tls13.c, benchmark.c - LowResTimer, both TimeNowInMilliseconds variants and current_time from TEE_GetSystemTime, which is monotonic for the life of the trusted application and is not the normal world's clock, so it cannot be steered from outside. settings.h no longer forces USER_TICKS, which existed only because nothing supplied these; a project can still define it to override.
  • wc_port.h, wc_port.c - XTIME from TEE_GetREETime. That is the only wall clock a trusted application can reach and the normal world owns it, so it is fit for freshness and logging, not for deciding certificate validity. The WOLFSSL_OPTEE block keeps NO_ASN_TIME for that reason, and a port that turns it off is choosing to trust the rich OS clock.

Testing

Validated on an NVIDIA Jetson Orin Nano (L4T R36.4.4), building the wolfTPM firmware TPM into an OP-TEE trusted application. With these changes the trusted application drops its platform file and its allocator and RNG overrides entirely, and still passes RSA, ECC, AES-CFB, NV, SHA-256, HMAC, PCR and ML-DSA / ML-KEM sign, verify, encapsulate and decapsulate, including the tampered-signature and tampered-ciphertext negative cases.

The time arms sit inside #ifndef NO_ASN_TIME, which the WOLFSSL_OPTEE block sets, so a default OP-TEE build does not reach them. They were compiled against the OP-TEE headers with the trusted application toolchain to confirm the TEE API use. TLS has not been run inside a trusted application.

--enable-all builds clean on Linux with WOLFSSL_OPTEE undefined, which is where all of this is inert.

@dgarske dgarske changed the title Add OP-TEE heap and RNG platform support under WOLFSSL_OPTEE Add OP-TEE heap, RNG and time platform support under WOLFSSL_OPTEE Oct 29, 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.

2 participants