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

Implement TPM2_Commit #296

Merged
merged 36 commits into from
Aug 23, 2022
Merged

Implement TPM2_Commit #296

merged 36 commits into from
Aug 23, 2022

Conversation

akakou
Copy link
Contributor

@akakou akakou commented Jul 26, 2022

akakou and others added 21 commits July 1, 2022 15:16
Define `TPMS_SCHEME_ECDAA` as TPMSSchemeECDAA.
See definition in Part 2: Structures, section 11.1.18.
section 11.1.10 --> section 11.1.19
Define the TPMS_SIG_SCHEME_ECDAA as the SigSchemeECDAA.
See definition in Part 2: Structures, section 11.2.1.3.
Define the TPM2B_ECC_POINT as the ECCPoint/TPM2BECCPoint.
See definition in Part 2: Structures, section 11.2.5.3.
Update the test of TPM2_Commit to use TPM2_CreateLoaded
instead of TPM2_Create/TPM2_Load.
Note that this commit is a work in progress,
so the test on this commit not work.
Remove the space between the comma-separated type annotations.
tpm2b.Private of CreateLoadedResponse is not a pointer.
Create another key that is not the primary key
when testing the TPM2_Commit.
tpm2.ECPoint => tpm2b.ECCPoint
@akakou akakou requested review from alexmwu, jkl73 and a team as code owners July 26, 2022 08:17
@akakou akakou changed the base branch from master to tpmdirect July 26, 2022 08:17
@akakou akakou mentioned this pull request Jul 26, 2022
direct/tpm2/tpm2.go Outdated Show resolved Hide resolved
direct/tpm2/tpm2.go Outdated Show resolved Hide resolved
@akakou
Copy link
Contributor Author

akakou commented Jul 26, 2022

Thank you for your review!

But I found the bug around parsing the response.
So first I will fix it and then fix some code that is stated in the comments of the review.

@akakou
Copy link
Contributor Author

akakou commented Jul 26, 2022

It was a misunderstanding, the TPM2_Commit on go-tpm has already worked.

But I found the bug around parsing the response.

@akakou
Copy link
Contributor Author

akakou commented Jul 26, 2022

@matt-tsai

I fixed some points which you commented on.
Could you re-review and merge it?

},
}

_, err = commit.Execute(thetpm)
Copy link
Contributor

Choose a reason for hiding this comment

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

Testing the output response with some off-tpm validation would be good here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm...Any good idea to test this output...?

I have just an idea that implements full ECDAA Setup/Join for this, but it's complex and we should avoid it.

Copy link
Contributor

@matt-tsai matt-tsai Jul 27, 2022

Choose a reason for hiding this comment

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

I think @chrisfenner is a better person to discuss this with, however he is out at the moment and will be back next week. In the meantime, I will add him to be a reviewer.

Copy link
Member

Choose a reason for hiding this comment

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

I'm new to ECDAA signing, but I think you should be able to use TPM2_Sign (which is already implemented) to produce an ECDAA signature using the commit value. You'll have to grab the commit counter from the Commit command and use it on the ECDAA scheme structure in the Sign command.

Bonus points: Call Sign again with the same counter value and expect it to fail :)

No need to validate the signature at this point, unless you really want to. I imagine that belongs as part of a larger body of ECDAA sample code that someone might work on (maybe you or someone else) as part of a separate effort.

Copy link
Member

@chrisfenner chrisfenner left a comment

Choose a reason for hiding this comment

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

Thanks for your patience, I was on vacation and then catching up on work after I returned from vacation :)

The functionality looks great, thanks for the change! I have a few notes on the test to make it tighter and leaner but also cover more of an end-to-end scenario.

direct/tpm2/commit_test.go Outdated Show resolved Hide resolved
direct/tpm2/commit_test.go Outdated Show resolved Hide resolved
direct/tpm2/commit_test.go Outdated Show resolved Hide resolved
},
}

_, err = commit.Execute(thetpm)
Copy link
Member

Choose a reason for hiding this comment

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

I'm new to ECDAA signing, but I think you should be able to use TPM2_Sign (which is already implemented) to produce an ECDAA signature using the commit value. You'll have to grab the commit counter from the Commit command and use it on the ECDAA scheme structure in the Sign command.

Bonus points: Call Sign again with the same counter value and expect it to fail :)

No need to validate the signature at this point, unless you really want to. I imagine that belongs as part of a larger body of ECDAA sample code that someone might work on (maybe you or someone else) as part of a separate effort.

direct/tpm2/commit_test.go Outdated Show resolved Hide resolved
@akakou
Copy link
Contributor Author

akakou commented Aug 8, 2022

I will update it as your review told me, on next week... (I'm too busy until next Saturday...)

@akakou
Copy link
Contributor Author

akakou commented Aug 15, 2022

@chrisfenner
Thank you for your review!
I fixed some code you pointed out.

So could you re-review and merge it if it is ok?

@akakou akakou requested review from chrisfenner and removed request for alexmwu and jkl73 August 20, 2022 05:05
@chrisfenner chrisfenner merged commit abec815 into google:tpmdirect Aug 23, 2022
@chrisfenner
Copy link
Member

Thank you for the change!

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