-
Notifications
You must be signed in to change notification settings - Fork 166
Implement TCP TPM protocol #387
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
74770b9
to
c6153e6
Compare
This change implements the basic TCP TPM protocol, which is useful for connecting to a running TPM simulator. It also introduces some tests which are skipped if the --cmd_addr or --plat_addr flags aren't provided. A number of TCP commands aren't implemented and left for a future change. Tested against a recent build of the TCG TPM simulator from https://github.com/trustedcomputinggroup/tpm use the closeTPM helper, caught by linter Co-authored-by: anamendes23 <anamendes@google.com>
"github.com/google/go-tpm/tpm2" | ||
) | ||
|
||
var ( |
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.
It would be helpful for future contributors to give some clear instructions on testing
# get TGC ref impl
# build sim
./TPMCmd/Simulator/src/tpm2-simulator
go test blah
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.
Great suggestion, added this.
} else if n != len(rsp) { | ||
return nil, fmt.Errorf("%w: could not read full TPM response: only got %v out of %v bytes", ErrTransport, n, len(rsp)) | ||
} | ||
// The server also provides a TCP error code at the end. |
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.
Where is this in the implementation? I couldn't find it.
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.
// The de-facto TPM-over-TCP protocol is defined by the Reference Implementation. | ||
// See https://github.com/TrustedComputingGroup/TPM/blob/main/TPMCmd/Simulator/include/TpmTcpProtocol.h | ||
|
||
type regularCommand uint32 |
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 assume there's no other way to differentiate regular and plat commands other than reading https://github.com/TrustedComputingGroup/TPM/blob/main/TPMCmd/Simulator/src/TcpServer.c?
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.
That's right, they are in the same namespace together in the C code.
tpm2/transport/tcp/tcp_test.go
Outdated
} | ||
if clock2.CurrentTime.ClockInfo.ResetCount != clock1.CurrentTime.ClockInfo.ResetCount { | ||
t.Errorf("resetCount after Restart was %v, want %v", | ||
clock1.CurrentTime.ClockInfo.ResetCount, |
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.
t.Errorf("resetCount after Restart was %v, want %v",
clock2.CurrentTime.ClockInfo.ResetCount, clock1.CurrentTime.ClockInfo.ResetCount)
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.
Good catch, fixed. Thanks!
This change implements the basic TCP TPM protocol, which is useful for connecting to a running TPM simulator. It also introduces some tests which are skipped if the --cmd_addr or --plat_addr flags aren't provided.
To aid in testing, this change also implements ReadClock.
A number of TCP commands aren't implemented and left for a future change.
Tested against a recent build of the TCG TPM simulator from https://github.com/trustedcomputinggroup/tpm