Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial source import for fTPM #1

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

jenswi-linaro
Copy link
Contributor

This pull request replaces OP-TEE/optee_os#7054 now that we have decided to keep the fTPM TA in a separate git. The fTPM commits are moved into this PR.

Import initial fTPM source from
https://github.com/microsoft/ms-tpm-20-ref

Copy initial source code from Samples/ARM32-FirmwareTPM/optee_ta/fTPM
commit e9fc7b89d865 ("Fix conflicting types for `ReadVarBytes`. (#102)")

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Import TEE crypto API wrappers from
https://github.com/zeschg/ms-tpm-20-ref/ from commit ea7f4b3c3f82
("feat: exchange wolfcrypt backend with op-tee crypto api") with the
exception of src/crypt/tee/TpmToTEEHash.c and
include/TEE/TpmToTEEHash.h.

Samples/ARM32-FirmwareTPM/optee_ta/fTPM/reference/include/TpmProfile.h to
reference/include/TpmProfile.h

Source directory TPMCmd/tpm to the root of this git
src/crypt/tee/TpmToTEEMath.c    -> tee/TpmToTEEMath.c
src/crypt/tee/TpmToTEESupport.c -> tee/TpmToTEESupport.c
src/crypt/tee/TpmToTEESym.c     -> tee/TpmToTEESym.c
include/TEE/TpmToTEEMath.h      -> include/TEE/TpmToTEEMath.h
include/TEE/TpmToTEESym.h       -> include/TEE/TpmToTEESym.h

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Refactors the imported TEE crypto API wrappers to better follow the
OP-TEE coding style.

On touched files, set Microsoft copyright year to 2018 based on git
history in the reference source. Add Linaro copyright.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Add and use hashlib wrappers for MbedTLS. Disabling ALG_SM3_256 since
it's not supported by MbedTLS.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Add TA_FLAG_DEVICE_ENUM_TEE_STORAGE_PRIVATE to TA_FLAGS to enumerate the
TA once secure storage is available.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Removes the redundant or invalid s_NV* declarations

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
_plat__Fail() is declared with a __noreturn since it's guaranteed to not
return, but it only calls TEE_Panic() which doesn't have the same
attribute. TEE_Panic() does indeed never return so add a while(true)
after the TEE_Panic() so silence the warning.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Fix conflicting types for _plat__NvMemoryWrite() by adding the return
type used in the declaration. _plat__NvMemoryWrite() is updated to
always return TRUE since that's the expectation of success in NvWrite in
TPMCmd/tpm/src/subsystem/NvReserved.c in the reference implementation
(ms-tpm-20-ref).

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove the mismatching _plat__Signal_PowerOn() prototype from fTPM.h.
The real prototype is in ta/ftpm/platform/include/Platform_fp.h.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove the redefinition of TA_ALL_PARAM_TYPE() from fTPM.c, it's
originally defined in ta/ftpm/include/fTPM.h.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Move user_ta_header_defines.h to the common include directory for fTPM.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
lib/libutils/isoc/include/ctype.h already declares toupper() and
tolower() so remove the redundant declarations from RuntimeSupport.h.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Separate TA_FTPM_UUID and the command IDs into ftpm_ta.h. Update
user_ta_header_defines.h to include ftpm_ta.h instead of the old fTPM.h
to minimize the include file dependencies.

Set Microsoft copyright year to 2018 based on git history in the
reference source. Add missing SPDX-License-Identifier and Linaro
copyright.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Surround the BYTE_ARRAY_TO_UINT32 with ifdefs to avoid conflicting
define with the one in ms-tpm-20-ref/TPMCmd/tpm/include/swap.h.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove a conflicting define.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Include stdlib.h and string.h to make it compile.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove TpmProfile.h overriding the version in the reference source.

The old TpmProfile.h included a few .h files not included in the
reference TpmProfile.h, so add the missing includes the affected source
files.

Add SPDX-License-Identifier and add Linaro copyright for all modified
files. Set Microsoft copyright year based on git history in the
reference source.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Updates Makefile and sub.mk files to make it compile the source files.
Many warnings are disabled.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove the unused file RuntimeSupport.c.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove the now unused wolfssl crypto wrapper.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Remove the now unused sub.mk files.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Add the configuration variable CFG_FTPM_EMULATE_PPI, default disabled,
to control whether PPI emulation is enabled.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
@jan-kiszka
Copy link

I think this needs a short README which should also the describe the compilation.

Add instructions how to build this TA.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
@jenswi-linaro
Copy link
Contributor Author

Updated

Add a check in the Makefile for CFG_MS_TPM_20_REF with an error message
if the variable isn't set or obviously invalid.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
@jbech-linaro
Copy link

I think this needs a short README which should also the describe the compilation.

Fine for now, but "documentation" should be at https://optee.readthedocs.io. We intentionally removed most content from almost all git README's a long time ago. But for now in this initial state, I think it's perfectly fine to have some information in the readme.

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