Implement some additional hierarchy control and dictionary attack functions for TPM2#109
Implement some additional hierarchy control and dictionary attack functions for TPM2#109chrisccoulson wants to merge 10 commits intogoogle:masterfrom
Conversation
This adds an API for calling TPM2_Clear with password authentication
This adds a simple API that wraps the TPM2_DictionaryAttackParameters command.
This adds an API that wraps around the TPM2_HierarchyChangeAuth command so that authorization values for the various hierarchies can be set.
This adds an API that wraps around TPM2_ClearControl to disable the ability to clear the TPM with owner authorization. As re-enabling owner clear requires platform authorization, the API only supports disabling owner clear (ie, TPM2_ClearControl called with disable=YES")
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Execute TPM provisioning on install using Chris Coulson's FDE utils code from https://github.com/chrisccoulson/ubuntu-core-fde-utils. This also requires google/go-tpm#109 which has been added to vendored packages. Try to provision the TPM as late as possible to prevent a situation where the installation fails after the TPM is provisioned. Provisioning happens just before sealing the LUKS device keyfile and the lockout authorization value is stored inside the encrypted partition. Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
awly
left a comment
There was a problem hiding this comment.
Thanks for the PR.
Please also sign the CLA per the above comment
| cmdIncrementNVCounter tpmutil.Command = 0x00000134 | ||
| cmdWriteNV tpmutil.Command = 0x00000137 | ||
| cmdPCREvent tpmutil.Command = 0x0000013C | ||
| cmdDictionaryAttackParameters tpmutil.Command = 0x0000013A |
There was a problem hiding this comment.
Move it one line higher, to keep sorted order
There was a problem hiding this comment.
Thanks, I've done that now.
| return concat(ha, auth) | ||
| } | ||
|
|
||
| func Clear(rw io.ReadWriter, hierarchy tpmutil.Handle, password string) error { |
There was a problem hiding this comment.
Add doc comments to all exported funcs
tpm2/tpm2.go
Outdated
| } | ||
|
|
||
| func encodeDisableOwnerClear(password string) ([]byte, error) { | ||
| lockout, err := tpmutil.Pack(HandleLockout) |
tpm2/tpm2.go
Outdated
| if err != nil { | ||
| return nil, err | ||
| } | ||
| param, err := tpmutil.Pack(true) |
tpm2/tpm2.go
Outdated
| return concat(lockout, auth, param) | ||
| } | ||
|
|
||
| func DisableOwnerClear(rw io.ReadWriter, password string) error { |
There was a problem hiding this comment.
Change this to ClearControl and take hierarchy and enable/disable as arguments
| } | ||
| defer FlushContext(rw, rootHandle) | ||
|
|
||
| persistentHandle := tpmutil.Handle(0x817FFFFF) |
There was a problem hiding this comment.
Add a comment explaining where this value comes from
There was a problem hiding this comment.
I just copied this value from other tests in tpm2_test.go.
I've hit this issue in the past, but I should be part of Canonical's corporate CLA with Google now. |
Did you add your Canonical email address to the GitHub account? You can check it under https://github.com/settings/emails. It doesn't need to be primary, but needs to be added there. |
tpm2/tpm2.go
Outdated
| return concat(handle, auth, param) | ||
| } | ||
|
|
||
| // Control whether the TPM can be cleared with the Clear() API. Calling this with the third parameter set to |
There was a problem hiding this comment.
Per https://golang.org/doc/effective_go.html#commentary, the comment must start with // ClearControl ...
tpm2/tpm2.go
Outdated
| return concat(lockout, auth, params) | ||
| } | ||
|
|
||
| // Change the dictionary attack lockout parameters. The first parameter is the number of authorization failures |
There was a problem hiding this comment.
Same as above, start comment with // SetDictionaryAttackParameters ...
There was a problem hiding this comment.
Thanks for the PR.
Please also sign the CLA per the above commentI've hit this issue in the past, but I should be part of Canonical's corporate CLA with Google now.
Did you add your Canonical email address to the GitHub account? You can check it under https://github.com/settings/emails. It doesn't need to be primary, but needs to be added there.
My Canonical email address is registered with my github account. Note that I was only added to the CCLA after submitting this PR.
There was a problem hiding this comment.
Hmm, I don't see anything wrong.
One last thing to check - did you change your github username since getting added to the CLA? Or perhaps there was a typo in it?
I've emailed our internal team responsible for this CLA github bot, will let you know when we figure out the problem.
josephlr
left a comment
There was a problem hiding this comment.
LGTM from the perspective of properly encoding the auth areas and decoding the responses (fairly easy as none of these commands return anything).
My only concern is that all of these commands use passwords for their authentication. We're trying to avoid having two methods for each command (Foo and FooWithAuth). However, I think this is actually fine, because these commands only use the Hierarchy handles, and those handles can only use password-based authorization.
@awly, do you know if this is actually true? It shouldn't be possible/necessary to do policy auth with things like HandleEndorsement or HandlePlatform.
|
@chrisccoulson I know we have a CLA on file w/ Cannonical, so if you can resolve the merge conflicts, I can just override the CLA check. |
Sorry, I don't know.
I have a few email threads going about this, with @chrisccoulson and our internal CLA team. |
|
Just poking here, 'cause I had hacked in some of the same functionality, and it would be nice to have these officially supported! EDIT: Looks like it's partially implemented in #163 |
|
@awly and @josephlr, do you have any updates on this CLA issue? |
|
The CLA stuff shouldn't be a problem, as Cannonical has singed a new CLA w/ Google since the last update here. If there's still an issue, I'll manually override the CI if a rebase doesn't get the check to work correctly. If @chrisccoulson is willing to rebase this on latest master (see #163 which implemented some of this functionality), I'd merge it. |
This adds API's for clearing the TPM, disabling the ability to clear the TPM with owner authorization, changing the hierarchy authorization values and configuring dictionary attack parameters.