Skip to content

PCR policy authmodel, continuation of #833 - #916

Open
glance- wants to merge 12 commits into
tpm2-software:masterfrom
glance-:fixup-pull-833
Open

PCR policy authmodel, continuation of #833#916
glance- wants to merge 12 commits into
tpm2-software:masterfrom
glance-:fixup-pull-833

Conversation

@glance-

@glance- glance- commented Feb 27, 2026

Copy link
Copy Markdown

This is work based upon #833 , and those commits are just rebased on top of current master.

I've tested this a bit and it looks like the policy is actually in effect now.

SergiiDmytruk and others added 12 commits February 25, 2026 13:12
This makes it easier to add new vendor attributes without accidentally
reusing the same constant value and making implementations incompatible.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
To be used as a storage of TPM policy in JSON formed understood by
tpm2-tss libpolicy library.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Policies are expected to be specified in JSON format.  The command
allows reading, writing or deleting policy set on an object.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
To specify the policy right on creation.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
It was added in tpm2-tss v4.0 and functionality that requires it will be
no-op when it's not there or --without-policy is specified during
configuration step.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
If tpm2-pkcs11 was built without tss2-policy, policy is ignored (a
warning is logged about it).

This might work for other kinds of policies if they don't require any
callbacks for calculation or execution of a policy.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
It said "add" instead of "export".

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
It's --with/without-fapi (or --with-fapi=yes/no).

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
It's a calculation callback, but not yet calculated policy is
automatically calculated before execution.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Anton Lundin <glance@ac2.se>
This reworks the policy code into something that actually validates the
policy, and adds a test for it.

Signed-off-by: Anton Lundin <glance@ac2.se>
Assisted-by: gemini-cli:gemini-3-flash-preview
@glance-

glance- commented Feb 27, 2026

Copy link
Copy Markdown
Author

I now see that the quite complicated github actions tests looks to not have libtss2-policy . If you'd like to see the test run, I can probably add that.

I've run the tests locally on my debian trixie machine, against the system libtss2-* and it works just fine. That's my indented target to run this on to, so I'm quite happy that I don't need to locally build the whole tpm2-software stack and can just build tpm2-pkcs11 for now.

@glance-

glance- commented Mar 2, 2026

Copy link
Copy Markdown
Author

I've written a patch, replacing the shellout to tpm2_createpolicy in calculate_policy_digest with calls to tpm2_pytss TPM2_policy , but I'm uncertain in how to treat the tpm2_pytss interactions in tpm2-pkcs11. Is tpm2_pytss a optional dependency for tpm2_ptool or not?
If not, fine, we can port lots of the shellouts to tpm2-tools to tpm2_pytss calls and simplify things.

tools/tpm2_pkcs11/tpm2.py just does shellouts.
tools/tpm2_pkcs11/commandlets_keys.py and tools/tpm2_pkcs11/utils.py got tpm2_pytss added as a dependency in 042e56b

Now when thinking about it, calculate_policy_digest should probably be moved to tools/tpm2_pkcs11/tpm2.py anyhow.

@pothos

pothos commented Mar 9, 2026

Copy link
Copy Markdown

Interesting, I need to test whether this addresses my needs for policyCommandCode(TPM2_CC_Sign) + policyAuthValue in a more generic way than what I did in #915

@glance-

glance- commented Mar 10, 2026

Copy link
Copy Markdown
Author

Feel free to. This code needs testing. glance-@4ecc139 contains code for more generic policy stuff rather than the current shellout to tpm2_createpolicy . I'm still thinking about replacing some/most/most of the shellouts to tpm2-tools with tpm2_pytss FFI calls, of which that is a first step.

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