Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The fwTPM as an OP-TEE trusted application: TPM 2.0 command processing in the secure world, client in the normal world. Needs only the TEE Internal Core API and OP-TEE secure storage, so nothing in it is specific to an SoC.
Builds on two wolfSSL changes: wolfSSL/wolfssl#11919 added the
WOLFSSL_OPTEEbuild environment, and wolfSSL/wolfssl#11927 maps the wolfCrypt heap, RNG and time onto the TEE. That is why this port carries no platform shims of its own.FWTPM_ProcessCommandhas the shape ofTA_InvokeCommandEntryPoint, so one invocation carries one whole TPM command and no IO HAL or TIS layer is involved. Both server loops block, which a trusted application cannot do, sofwtpm_io.c,fwtpm_tis.c,fwtpm_tis_shm.candfwtpm_main.care left out of a TA build.Adds
src/fwtpm/ports/optee/- theTA_*EntryPointfunctions and an NV journal on OP-TEE secure storage, keyed from the hardware unique key through the system PTAwolftpm/fwtpm/fwtpm_optee.h- the trusted application's UUID and the command IDs the client sharessrc/tpm2_optee.c,wolftpm/tpm2_optee.h- theWOLFTPM_OPTEElibteec client transport, following theWOLFTPM_SWTPMwhole-command pattern rather than emulating TIS registers--enable-optee, with thesrc/include.amand CMake entriesTouches shared code
src/tpm2.c,hal/tpm_io.c,hal/tpm_io.h,wolftpm/tpm2_types.h,src/tpm2_wrap.c,src/tpm2_spdm.c- addWOLFTPM_OPTEEto the existing "no bus, so no TIS" gates besideWOLFTPM_LINUX_DEVandWOLFTPM_SWTPMwolftpm/tpm2_types.h- aWOLFSSL_OPTEEarm forXTPM_GET_TIMEMSonTEE_GetSystemTime. A trusted application has noCLOCK_MONOTONIC, so the POSIX branch leftWOLFTPM_HAVE_MONOTONIC_MSunset and command timeouts fell back to a counter. NotTEE_GetREETime, because the normal world owns that clock and can move it backwards. Applies with or without wolfCryptwolftpm/tpm2_types.h- and where wolfCrypt is not compiled in, map that path's ownXMALLOCandXFREEontoTEE_MallocandTEE_Free.WOLFTPM2_NO_HEAPstill wins and leaves both undefinedsrc/fwtpm/fwtpm_nv.c- print the NV version mismatch withprintfunderWOLFSSL_OPTEEonly, since a trusted application cannot linkfprintf. Every other build keepsstderrsrc/fwtpm/ports/optee/fwtpm_optee_ta.c- acceptTEE_PARAM_TYPE_MEMREF_INOUTfor the response buffer as well asMEMREF_OUTPUT. Linux'stpm_ftpm_teecarries both memrefs in one registered shared memory and so passes the response as INOUT; without this it getsTEE_ERROR_NOT_SUPPORTED. Nothing is read out of that buffer either way, and it is what lets an in-kernel TPM driver bind to this trusted application and present a/dev/tpmdeviceTesting
Validated on an NVIDIA Jetson Orin Nano (L4T R36.4.4): unmodified
caps,getrandom,native_test,wrap_testand the fourpqc/examples pass against the trusted application, and NV persists across separate client processes.Multi-config build sweep green with
WOLFTPM_OPTEEundefined, including the--enable-st33and--enable-advioTIS paths the gate changes affect,--disable-wrapper,--enable-devtpm,--enable-autodetectand--enable-fwtpm --enable-v185.make checkgreen against both the fwTPM server and ibmswtpm2.