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

Use Microsoft Reference Implementation for the Simulator #20

Merged
merged 6 commits into from
Jul 3, 2019
Merged

Conversation

josephlr
Copy link
Member

@josephlr josephlr commented Jul 2, 2019

The change:

  • Deletes all the IBM code
  • Adds the MSFT code as a submodule
  • Fixes up the flags to work with MSFT's simulator
  • Adds simulator.c which textually includes all the .c files to get around the terrible CGO build system.

This gives us:

  • Flexibility by using a git sub-module to hold their code, instead of copying it into the repo
  • Easier debugging as the code is better documented and of general higher quality
  • More up-to-date features

Edit: Note that the remote is actually my fork. To make everything clean, I had to start addressing microsoft/ms-tpm-20-ref#33 with the following PRs:

@twitchy-jsonp
Copy link

Adds precompiled libtpm.a and libplatform.a

What architecture? Why can't we build this from source rather than having precompiled blobs?

@twitchy-jsonp
Copy link

twitchy-jsonp commented Jul 2, 2019

Also, how will this affect consumers of go-tpm-tools/simulator? It is already used extensively in integration tests for go-attestation and I has a citc with WIP tests for go-tpm.

Copy link

@twitchy-jsonp twitchy-jsonp left a comment

Choose a reason for hiding this comment

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

If keeping the .a files is absolutely essential, would you consider keeping both simulators as part of the repo, with different import paths (but hopefully identical/similar APIs?)

@josephlr
Copy link
Member Author

josephlr commented Jul 3, 2019

Also, how will this affect consumers of go-tpm-tools/simulator? It is already used extensively in integration tests for go-attestation and I has a citc with WIP tests for go-tpm.

I managed to get everything working normally. go build and go test now work out of the box, without having any .a files pregenerated. This requires a few hacks to work with the external golang build system, but should work fine with Blaze internally.

Also note that the remote is currently my fork (see the upstream PRs in the description).

@twitchy-jsonp PTAL. Due to the large git diff, it might be easier to look at each commit individually. We should also make sure to keep the git history when merging this CL.

@twitchy-jsonp
Copy link

Wheres Tpm.h? is that a library I should have?

[jsonp@jsonp-glaptop]:~> mkdir /tmp/kek
[jsonp@jsonp-glaptop]:~> cd /tmp/kek/
[jsonp@jsonp-glaptop]:/tmp/kek> git clone https://github.com/google/go-tpm-toolsCloning into 'go-tpm-tools'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 550 (delta 8), reused 17 (delta 6), pack-reused 527
Receiving objects: 100% (550/550), 675.16 KiB | 4.56 MiB/s, done.
Resolving deltas: 100% (352/352), done.
[jsonp@jsonp-glaptop]:/tmp/kek> cd go-tpm-tools/
[jsonp@jsonp-glaptop]:/tmp/kek/go-tpm-tools> git checkout msft 
Branch 'msft' set up to track remote branch 'msft' from 'origin'.
Switched to a new branch 'msft'
[jsonp@jsonp-glaptop]:/tmp/kek/go-tpm-tools> export PATH=$PATH:/usr/local/go/bin[jsonp@jsonp-
[jsonp@jsonp-glaptop]:/tmp/kek/go-tpm-tools> go get github.com/google/go-tpm/tpm2
[jsonp@jsonp-glaptop]:/tmp/kek/go-tpm-tools> go build ./simulator
# _/tmp/kek/go-tpm-tools/simulator
simulator/simulator.go:39:11: fatal error: Tpm.h: No such file or directory
 // #include "Tpm.h"
           ^~~~~~~
compilation terminated.

@josephlr
Copy link
Member Author

josephlr commented Jul 3, 2019

Wheres Tpm.h? is that a library I should have?

As the C code is in a submodule, you have to use git clone --recurse-submodules

@twitchy-jsonp
Copy link

LGTM.

[jsonp@jsonp-glaptop]:/tmp/kek> rm -rf go-tpm-tools/
[jsonp@jsonp-glaptop]:/tmp/kek> git clone --recurse-submodules https://github.com/google/go-tpm-tools
Cloning into 'go-tpm-tools'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 550 (delta 8), reused 17 (delta 6), pack-reused 527
Receiving objects: 100% (550/550), 675.16 KiB | 1.67 MiB/s, done.
Resolving deltas: 100% (352/352), done.
[jsonp@jsonp-glaptop]:/tmp/kek> go get github.com/google/go-tpm-tools/tpm2tools
[jsonp@jsonp-glaptop]:/tmp/kek> cd go-tpm-tools/
[jsonp@jsonp-glaptop]:/tmp/kek/go-tpm-tools> go test -count=1 -v ./simulator
=== RUN   TestResetDoesntChangeEK
--- PASS: TestResetDoesntChangeEK (0.07s)
=== RUN   TestManufactureResetChangesEK
--- PASS: TestManufactureResetChangesEK (0.06s)
=== RUN   TestGetRandom
--- PASS: TestGetRandom (0.00s)
    simulator_test.go:85: [91 39 110 200 145 109 126 62 178 132]
=== RUN   TestFixedSeedExpectedModulus
--- PASS: TestFixedSeedExpectedModulus (0.03s)
=== RUN   TestDifferentSeedDifferentModulus
--- PASS: TestDifferentSeedDifferentModulus (0.03s)
PASS
ok  	_/tmp/kek/go-tpm-tools/simulator	0.213s

@josephlr josephlr merged commit b027ecc into master Jul 3, 2019
@josephlr josephlr deleted the msft branch July 3, 2019 20:42
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.

None yet

2 participants