-
Notifications
You must be signed in to change notification settings - Fork 162
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 some additional hierarchy control and dictionary attack functions for TPM2 #109
base: master
Are you sure you want to change the base?
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. 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 <[email protected]>
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 <[email protected]>
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it one line higher, to keep sorted order
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc comments to all exported funcs
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.
Done.
tpm2/tpm2.go
Outdated
} | ||
|
||
func encodeDisableOwnerClear(password string) ([]byte, error) { | ||
lockout, err := tpmutil.Pack(HandleLockout) |
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.
Pass the handle as argument
tpm2/tpm2.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
param, err := tpmutil.Pack(true) |
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.
Pass this as argument
tpm2/tpm2.go
Outdated
return concat(lockout, auth, param) | ||
} | ||
|
||
func DisableOwnerClear(rw io.ReadWriter, password string) error { |
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.
Change this to ClearControl and take hierarchy and enable/disable as arguments
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've updated this now.
} | ||
defer FlushContext(rw, rootHandle) | ||
|
||
persistentHandle := tpmutil.Handle(0x817FFFFF) |
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.
Add a comment explaining where this value comes from
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://golang.org/doc/effective_go.html#commentary, the comment must start with // ClearControl ...
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.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, start comment with // SetDictionaryAttackParameters ...
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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.