Skip to content

tpm2: Add WithLockoutAuthValue and WithLockoutAuthData options for EnsureProvisioned#533

Open
chrisccoulson wants to merge 3 commits intocanonical:masterfrom
chrisccoulson:tpm2-add-with-lockout-auth-options
Open

tpm2: Add WithLockoutAuthValue and WithLockoutAuthData options for EnsureProvisioned#533
chrisccoulson wants to merge 3 commits intocanonical:masterfrom
chrisccoulson:tpm2-add-with-lockout-auth-options

Conversation

@chrisccoulson
Copy link
Copy Markdown
Collaborator

This adds new WithLockoutAuthValue and WithLockoutAuthData options for
Connection.EnsureProvisioned. These are used to supply the current
authorization parameters for the lockout hierarchy.

WithLockoutAuthValue is used to supply the raw authorization value,
supplied to current (but soon to be older) versions of
Connection.EnsureProvisioned.

WithLockoutAuthData will be used to supply authorization data that will
be created by newer versions of Connection.EnsureProvisioned.

These options replace the ProvisionModeWithoutLockout option. To prevent
Connection.EnsureProvisioned from using the lockout hierarchy, just omit
both of the new options.

…sureProvisioned

This adds new WithLockoutAuthValue and WithLockoutAuthData options for
Connection.EnsureProvisioned. These are used to supply the current
authorization parameters for the lockout hierarchy.

WithLockoutAuthValue is used to supply the raw authorization value,
supplied to current (but soon to be older) versions of
Connection.EnsureProvisioned.

WithLockoutAuthData will be used to supply authorization data that will
be created by newer versions of Connection.EnsureProvisioned.

These options replace the ProvisionModeWithoutLockout option. To prevent
Connection.EnsureProvisioned from using the lockout hierarchy, just omit
both of the new options.
@chrisccoulson chrisccoulson requested a review from pedronis April 2, 2026 13:34
@pedronis pedronis requested a review from valentindavid April 2, 2026 13:49
Copy link
Copy Markdown
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

did a first pass, some comments/questions

if err == nil {
return
}
t.FlushContext(sessionInternal)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we flush only on error now, does this need a comment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The session needs to live past the end of the function, so it returns a callback to flush the session in the non-error case.

func (t *Connection) resetDictionaryAttackLockImpl(params *lockoutAuthParams) error {
if len(params.NewAuthValue) > 0 || params.NewAuthPolicy != nil {
return errors.New("lockout hierarchy auth value change not supported yet")
func (t *Connection) authorizeLockout(authParams *lockoutAuthParams, command tpm2.CommandCode) (session tpm2.SessionContext, lockoutAuthSet bool, done func(), err error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this probably needs a doc comment now to explain what done is for


return session, lockoutAuthSet, func() {
if authParams.AuthPolicy != nil {
t.FlushContext(session)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is the positive case flush now?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is.

switch {
case authSession.Handle().Type() == tpm2.HandleTypePolicySession:
// We're using policy auth so need to supply the HMAC session as an extra
// session for parameter encryption.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is session below the HMAC session?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is

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.

2 participants