Skip to content

tpm2: Add initial Connection.ResetDictionaryAttackLock APIs#512

Open
chrisccoulson wants to merge 1 commit intocanonical:masterfrom
chrisccoulson:tpm2-add-initial-da-reset-api
Open

tpm2: Add initial Connection.ResetDictionaryAttackLock APIs#512
chrisccoulson wants to merge 1 commit intocanonical:masterfrom
chrisccoulson:tpm2-add-initial-da-reset-api

Conversation

@chrisccoulson
Copy link
Collaborator

This adds initial APIs for resetting the TPM's dictionary attack counter
to replace the direct use of go-tpm2's
TPMContext.DictionaryAttackLockReset API.

This doesn't yet include the changes to Connection.EnsureProvisioned
which will create the authorization data that will be persisted by
snapd and passed to this new API - this is coming in a follow-up PR.

This is split into 2 APIs:

  • Connection.ResetDictionaryAttackLock which will be supplied with data
    that will be provided by an updated EnsureProvisioned API.
  • Connection.ResetDictionaryAttackLockWithAuthValue which will be
    supplied with a plain authorization value, previously chosen by snapd
    and provided to the current EnsureProvisioned API.

I did think about having this as 1 API, and handling the case where
decoding of the authorization data fails and treating it as an
authorization value if the length is 32 bytes. But as this value is
chosen by snapd and nothing in secboot enforces a size of 32 bytes, I
thought it was safer to have this as 2 APIs so that snapd can be
explicit about the format of the supplied data.

Fixes: FR-10809

This adds initial APIs for resetting the TPM's dictionary attack counter
to replace the direct use of go-tpm2's
TPMContext.DictionaryAttackLockReset API.

This doesn't yet include the changes to Connection.EnsureProvisioned
which will create the authorization data that will be persisted by
snapd and passed to this new API - this is coming in a follow-up PR.

This is split into 2 APIs:
- Connection.ResetDictionaryAttackLock which will be supplied with data
  that will be provided by an updated EnsureProvisioned API.
- Connection.ResetDictionaryAttackLockWithAuthValue which will be
  supplied with a plain authorization value, previously chosen by snapd
  and provided to the current EnsureProvisioned API.

I did think about having this as 1 API, and handling the case where
decoding of the authorization data fails and treating it as an
authorization value if the length is 32 bytes. But as this value is
chosen by snapd and nothing in secboot enforces a size of 32 bytes, I
thought it was safer to have this as 2 APIs so that snapd can be
explicit about the format of the supplied data.

Fixes: FR-10809
@chrisccoulson chrisccoulson force-pushed the tpm2-add-initial-da-reset-api branch from 8b57362 to b03116f Compare March 2, 2026 11:18
@chrisccoulson chrisccoulson marked this pull request as ready for review March 2, 2026 11:18
@chrisccoulson chrisccoulson requested a review from pedronis March 3, 2026 16:37
Copy link
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.

one comment


_, err := params.AuthPolicy.Execute(
policyutil.NewPolicyExecuteSession(t.TPMContext, session),
policyutil.WithSessionUsageCommandConstraint(tpm2.CommandDictionaryAttackLockReset, []policyutil.NamedHandle{t.LockoutHandleContext()}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you comment on this bit of setup?

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