-
Notifications
You must be signed in to change notification settings - Fork 166
Create individual packages for Windows and Linux TPM transport #369
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
Conversation
google#364 called to attention some long-standing technical debt around TPM transport. In particular, the stack looks like: (Linux or Windows) `OpenTPM` function calls the legacy `OpenTPM` function calls the tpmutil `OpenTPM` function At the bottom of the stack, tpmutil does some runtime introspection to see what type of TPM it wants to open (e.g., on Linux, the device could be either a device file or a socket). This runtime support is convenient, but also breaks dead-code elimination (for example, tinygo will fail to compile the UDS support code, and users have no way of leaving that out without patches). In principle, we've found within Google that "open my TPM" should be as un-smart as possible, to avoid awkward edge cases (for example, what happens if the logic finds two different TPMs on the system; which should it prefer; should it invisibly succeed and surprise the user?). Instead, the preferred pattern is to require the user to explicitly say which TPM they are trying to open. This change introduces 3 packages as a replacement for `transport.OpenTPM` (which this change marks as now Deprecated): `transport/linuxtpm.Open(path)` opens Linux device TPMs (e.g., /dev/tpm0 or /dev/tpmrm0) `transport/linuxudstpm.Open(path)` opens Linux Unix Domain Socket TPMs `transport/windowstpm.Open()` opens the TPM from TBS.dll Intentionally, the now-deprecated `transport.OpenTPM` is not touched. This would create an import cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice clean up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it out in said u-root commands from PR #364 with tinygo and the prior issues seem to be resolved. Thanks a lot for taking care of the improved implementation. This will help us a lot!
042968f
to
23aabd5
Compare
#364 called to attention some long-standing technical debt around TPM transport. In particular, the stack looks like:
(Linux or Windows)
OpenTPM
functioncalls the legacy
OpenTPM
functioncalls the tpmutil
OpenTPM
functionAt the bottom of the stack, tpmutil does some runtime introspection to see what type of TPM it wants to open (e.g., on Linux, the device could be either a device file or a socket). This runtime support is convenient, but also breaks dead-code elimination (for example, tinygo will fail to compile the UDS support code, and users have no way of leaving that out without patches).
In principle, we've found within Google that "open my TPM" should be as un-smart as possible, to avoid awkward edge cases (for example, what happens if the logic finds two different TPMs on the system; which should it prefer; should it invisibly succeed and surprise the user?). Instead, the preferred pattern is to require the user to explicitly say which TPM they are trying to open.
This change introduces 3 packages as a replacement for
transport.OpenTPM
(which this change marks as now Deprecated):transport/linuxtpm.Open(path)
opens Linux device TPMs (e.g., /dev/tpm0 or /dev/tpmrm0)transport/windowstpm.Open()
opens the TPM from TBS.dllI reverted the proposed
transport/linuxudstpm.Open()
because upon testing it against IBM's swtpm project (very helpful notes: https://ejaaskel.dev/yocto-emulation-setting-up-qemu-with-tpm/), I got the following errors which imply that the UDS protocol is not simply "send TPM commands the same as you would to the device file":Test failure:
Simulator logs:
The legacy
transport.OpenTPM
function failed with the same issue.Intentionally, the now-deprecated
transport.OpenTPM
is not touched. This would create an import cycle.TESTED:
windowstpm.Open
on a Windows system with a TPM.linuxtpm.Open
with both /dev/tpm0 and /dev/tpmrm0 on a Linux system with a TPMlinuxudstpm.Open
with the IBM simulator running with