Skip to content

Update to TPM 2.0 Reference Implementation v184#25

Open
svenbauer-work wants to merge 2 commits into
OP-TEE:masterfrom
svenbauer-work:feat/support-tpm-v184
Open

Update to TPM 2.0 Reference Implementation v184#25
svenbauer-work wants to merge 2 commits into
OP-TEE:masterfrom
svenbauer-work:feat/support-tpm-v184

Conversation

@svenbauer-work

Copy link
Copy Markdown

This PR contains changes to base optee_ftpm on the TPM 2.0 Reference Implementation v184. This is the most recent version tag at the time of writing.
It depends on the following fix for the TPM reference implementation: https://github.com/svenbauer-work/TPM/tree/a9665960ddfb92b8a140cd8d37d29342ddb05b3b

Also, note that The Official TPM 2.0 Reference Implementation seems to have moved from Microsoft to the TCG and can now be found here: https://github.com/TrustedComputingGroup/TPM

@jan-kiszka

Copy link
Copy Markdown

You likely want to massage my "WIP" commit, either to by just dropping the "WIP" while stating if it has limitations (it used to have back then due to the bug) or by folding everything thing into one commit that jumps to "V184" directly.

@jenswikl

jenswikl commented May 5, 2026

Copy link
Copy Markdown
Contributor

If there's a new upstream, then we should switch.
I haven't looked at the patch closely, but it seems some fixing up might be needed.
New code should follow https://optee.readthedocs.io/en/latest/general/coding_standards.html
Commits should be prepared as described at https://optee.readthedocs.io/en/latest/general/contribute.html
Dependencies on patches without a plan for how to make them available upstream don't work. If you need to update the manifest, please do that in a PR in that git and note the dependency with a link to the PR here.

@jan-kiszka

Copy link
Copy Markdown

@jenswi-linaro We are in contact with the TCG regarding upstreaming the TPM patches. However, they need to clarify/resolve some process challenges first. Will keep you posted.

// While all of the TPM reference implementation is provided "AS IS" without any
// warranty, the current design and implementation of CertifyX509 are considered
// to be especially unsuitable for product use.
#define CC_CertifyX509 CC_YES

@bniedermayr bniedermayr May 28, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it makes sense to disable this command, since it has been announced deprecated since V184 [1].

[1] https://trustedcomputinggroup.org/wp-content/uploads/Trusted-Platform-Module-2.0-Library-Part-3-Commands_Version-185_pub.pdf

relates to #18

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed. Thanks for digging this out!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks. I have added a corresponding commit to this PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Here, to be precise.

@svenbauer-work svenbauer-work force-pushed the feat/support-tpm-v184 branch from 29edf0c to 53a9155 Compare June 11, 2026 13:02
@svenbauer-work

Copy link
Copy Markdown
Author

I have just amended this PR such that it does not require upstream changes in the TCG's reference implementation of TPM 2.0 anymore. Cloning https://github.com/TrustedComputingGroup/TPM and checking out tag V184 will now work. I hope this has removed the main obstacle for accepting this PR.

Comment thread tee/BnToTEEMath.c
Error:
return 0;
}
# endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How does this correlate with microsoft/ms-tpm-20-ref@fcccc82? Please leave an explanation of that only temporarily or even permanently obsoletes the upstream tpm patch (because it was incorrect or so)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The #if / #endif here is analogous to BnToOsslMath.c and BnToWolfMath.c in the TPM 2.0 reference implementation. I believe the patch you cite is correct. I decided to be consistent with the other BnTo...Math.c files in the TPM 2.0 reference implementation. This forced me to define LIBRARY_COMPATIBILITY_CHECK - exactly because the patch you cite is missing upstream.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Then please leave a comment that this code becomes obsolete once upstream is fixed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done here.

Comment thread tee/BnToTEEMath.c
#define BN_WORD_INITIALIZED(name, initial) \
BN_STRUCT(name, RADIX_BITS) name##_; \
bigNum name = BnInitializeWord( \
(bigNum) & name##_, BN_STRUCT_ALLOCATION(RADIX_BITS), initial)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Won't this give us duplicate definition warnings? Or how to you prevent that the incorrect upstream definition is (also) processed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, you are right. I have added an #undef to suppress this warning and also fixed other warnings introduced by earlier commits in this PR in this commit. Remaining warnings seem to have nothing to do with the changes in this PR.

@jan-kiszka

Copy link
Copy Markdown

Again, please check if patches 3 and 4 are actually logically separate or rather fix-ups that should go into patch 2 directly. Or, if they touch code that existed before the version update, you could move bits into a separate patch between 1 and 2.

jan-kiszka and others added 2 commits June 12, 2026 17:55
The TPM 2.0 Reference Implementation has apparently moved to a new home at
https://github.com/TrustedComputingGroup/TPM
This commit contains changes to enable building optee_ftpm with the
TPM 2.0 Reference Implementation v184. This is the most recent version
tag at the time of writing.

Co-authored-by: Sven Bauer <svenbauer@siemens.com>
Signed-off-by: Sven Bauer <svenbauer@siemens.com>
Command TPM2_CertifyX509 has been declared "deprecated" in TPM spec v184.
Hence, the switch to enable it is now set to "CC_NO".

Signed-off-by: Sven Bauer <svenbauer@siemens.com>
@svenbauer-work svenbauer-work force-pushed the feat/support-tpm-v184 branch from 4ab6c10 to 5f6f753 Compare June 12, 2026 16:18
@svenbauer-work

Copy link
Copy Markdown
Author

Done.

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.

4 participants