diff options
author | Dan Streetman <ddstreet@ieee.org> | 2022-12-09 20:49:52 +0100 |
---|---|---|
committer | Dan Streetman <ddstreet@ieee.org> | 2023-05-26 17:12:12 +0200 |
commit | 5c7852f78c0c2b44be60651430876165a37eea95 (patch) | |
tree | 39ad2e704018db573518a78482995e29c62f80e5 /src/test/test-tpm2.c | |
parent | tpm2: add tpm2_policy_auth_value() (diff) | |
download | systemd-5c7852f78c0c2b44be60651430876165a37eea95.tar.xz systemd-5c7852f78c0c2b44be60651430876165a37eea95.zip |
tpm2: add tpm2_policy_authorize()
This adds functions to get the digest for a PolicyAuthorize operation. For
building a policy hash, this provides a function to calculate the hash; and for
building a policy hash to satisfy the authPolicy for an existing object, this
provides a function to perform PolicyAuthorize with an existing session.
Diffstat (limited to '')
-rw-r--r-- | src/test/test-tpm2.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/test-tpm2.c b/src/test/test-tpm2.c index 8fd027ced5..e878ab33f2 100644 --- a/src/test/test-tpm2.c +++ b/src/test/test-tpm2.c @@ -700,6 +700,18 @@ TEST(calculate_policy_auth_value) { assert_se(digest_check(&d, "759ebd5ed65100e0b4aa2d04b4b789c2672d92ecc9cdda4b5fa16a303132e008")); } +TEST(calculate_policy_authorize) { + TPM2B_PUBLIC public; + TPM2B_DIGEST d; + + tpm2b_public_init(&public); + digest_init_sha256(&d, "0000000000000000000000000000000000000000000000000000000000000000"); + assert_se(tpm2_calculate_policy_authorize(&public, NULL, &d) == 0); + assert_se(digest_check(&d, "95213a3784eaab04f427bc7e8851c2f1df0903be8e42428ec25dcefd907baff1")); + assert_se(tpm2_calculate_policy_authorize(&public, NULL, &d) == 0); + assert_se(digest_check(&d, "95213a3784eaab04f427bc7e8851c2f1df0903be8e42428ec25dcefd907baff1")); +} + TEST(calculate_policy_pcr) { TPML_PCR_SELECTION pcr_selection; TPM2B_DIGEST pcr_values[16]; |