Skip to content

Add host tests for the fwTPM OP-TEE port against a mock TEE - #674

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

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

Conversation

@dgarske

@dgarske dgarske commented Nov 13, 2026

Copy link
Copy Markdown
Member

Description

The OP-TEE trusted application port from #659 was only exercised on a Jetson Orin. This adds a mock TEE so the port is tested on the host in make check and CI. Everything lives under tests/optee.

What it adds

  • tests/optee/tee_internal_api.h, pta_system.h, mock_tee.c - RAM-backed stand-in for the TEE Internal Core API subset the port and wolfCrypt's WOLFSSL_OPTEE support use, with injectable failures (system PTA missing, key object unreadable, storage unavailable)
  • tests/optee/fwtpm_optee_port_tests.c - tests/fwtpm_optee_port.test in make check for every fwTPM configuration; stubs the fwTPM core and covers NV integrity key selection, secure storage access, session to client mapping and command/response buffer handling
  • tests/optee/optee_core_tests.c, optee_core.mk, user_settings.h - the port with the real fwTPM core and wolfCrypt compiled from source as WOLFSSL_OPTEE, driven through the TA entry points; covers per-session ownership of transient objects and the NV journal in secure storage across TA instances, including a missing PTA and a journal that fails its MAC
  • .github/workflows/optee-mock.yml - runs the core tests, plain and under ASan/UBSan, against a pinned wolfSSL commit on pushes and pull requests that touch the fwTPM, and against wolfSSL master on the nightly trigger
  • tests/optee/README.md - how the two suites are built and run

Testing

Both suites pass locally, under ASan/UBSan and with clang. Each was checked against deliberate faults in the port and core (no flush on session close, flush of every client, fallback key created over an existing journal, response staging buffer not cleared, short-buffer check after the command runs, gap filled with zeroes, uncached integrity key), and every fault fails at least one test.

@dgarske dgarske self-assigned this Nov 13, 2026
Copilot AI balanced review requested due to automatic review settings November 13, 2026 23:54

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.

🟢 Approval recommended

The host-based OP-TEE test additions have no active review issues.

No open issues 🎉

What changed in this PR

Adds host-based tests for the fwTPM OP-TEE trusted application port introduced in #659, extending coverage beyond hardware testing with a mock TEE.

Changes:

  • Adds RAM-backed secure storage and injectable TEE failures.
  • Integrates stubbed-core port tests into make check and adds real-core tests for session ownership and NV persistence.
  • Adds standard and sanitizer CI runs against pinned wolfSSL, with nightly runs against master.
File Description
tests/​optee/​user_settings.h Configures wolfCrypt and fwTPM for host core tests.
tests/​optee/​tee_internal_api.h Declares the mocked TEE API subset.
tests/​optee/​tee_internal_api_extensions.h Provides the port-compatible extension header.
tests/​optee/​README.md Documents both suites and build commands.
tests/​optee/​pta_system.h Defines the mock system PTA interface.
tests/​optee/​optee_core.mk Builds the port with real fwTPM and wolfCrypt sources.
tests/​optee/​optee_core_tests.c Tests ownership, persistence, MAC rejection and INOUT responses.
tests/​optee/​mock_tee.h Exposes mock storage controls and fault injection.
tests/​optee/​mock_tee.c Implements the RAM-backed TEE stand-in.
tests/​optee/​fwtpm_optee_port_tests.c Tests key selection, storage, sessions and buffer handling.
tests/​include.am Registers port tests and distributes supporting files.
.gitignore Ignores generated test binaries and logs.
.github/​workflows/​optee-mock.yml Runs real-core tests in standard and sanitizer configurations.

Review effort: Balanced

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