Skip to content

eBPF-based security platform

chain: report a hash that fails instead of a zero digest

Daniel Borkmann522c8cb750c5
diff --git a/builtin-attest.c b/builtin-attest.c
index 0f0cb048..2df4ba04 100644
--- a/builtin-attest.c
+++ b/builtin-attest.c
@@ -246,8 +246,8 @@ static int cert_digest(const char *path, __u8 out[32])
}
got = read(fd, buf, (size_t)st.st_size);
close(fd);
- if (got == st.st_size)
- shirudo_sha256(buf, (size_t)got, out);
+ if (got == st.st_size && shirudo_sha256(buf, (size_t)got, out))
+ got = -1;
xfree(buf, (size_t)st.st_size);
return got == st.st_size ? 0 : -EIO;
}
@@ -370,9 +370,12 @@ static int cmd_attest_predict(int argc, const char **argv)
pr_err("attest predict: --cert is required");
goto out;
}
- keys_anchor_digest(cert_shas, n_certs, cert_sha);
- chain_init_event(cert_sha, m.set, m.n, tree_root, set_digest,
- init);
+ if (keys_anchor_digest(cert_shas, n_certs, cert_sha) ||
+ chain_init_event(cert_sha, m.set, m.n, tree_root, set_digest,
+ init)) {
+ pr_err("attest predict: cannot hash the init event");
+ goto out;
+ }
hex_encode(set_digest, 32, hex);
printf("set_digest: %s\n", hex);
hex_encode(init, 32, hex);
@@ -415,7 +418,10 @@ static int cmd_attest_predict(int argc, const char **argv)
goto out;
}
printf("anchor: %s\n", anchor);
- shirudo_sha256(anchor, strlen(anchor), anchor_digest);
+ if (shirudo_sha256(anchor, strlen(anchor), anchor_digest)) {
+ pr_err("attest predict: cannot hash the anchor");
+ goto out;
+ }
chain_fold(bind[0], anchor_digest);
hex_encode(bind[0], 32, hex);
printf("pcr%u_after_anchor: %s\n", SHIRUDO_CHAIN_PCR, hex);
@@ -628,9 +634,12 @@ static int cmd_attest_verify(int argc, const char **argv)
x.nonce = nonce;
x.nonce_len = nonce_len;
if (have_cert) {
- keys_anchor_digest(cert_shas, n_certs, cert_sha);
- chain_init_event(cert_sha, m.set, m.n, tree_root,
- set_digest, x.init_event);
+ if (keys_anchor_digest(cert_shas, n_certs, cert_sha) ||
+ chain_init_event(cert_sha, m.set, m.n, tree_root,
+ set_digest, x.init_event)) {
+ pr_err("attest verify: cannot hash the init event");
+ goto out;
+ }
x.have_init = true;
}
if (read_evidence(evidence_path, &evidence, &evidence_len))
diff --git a/builtin-init.c b/builtin-init.c
index e3652467..7acad6c4 100644
--- a/builtin-init.c
+++ b/builtin-init.c
@@ -1201,7 +1201,11 @@ static int chain_extend_init(struct shirudo_measured_upatch *set, size_t n)
pr_err("chain: no certificate enrolled");
return -ENOENT;
}
- keys_set_digest(&enrolled, cert_sha);
+ rc = keys_set_digest(&enrolled, cert_sha);
+ if (rc) {
+ pr_err("chain: cannot hash the enrolled set: %s", strerror(-rc));
+ return rc;
+ }
/*
* init_event = SHA256("shirudo-init\0" || cert_sha256 || set_digest
@@ -1209,9 +1213,13 @@ static int chain_extend_init(struct shirudo_measured_upatch *set, size_t n)
* predictor shares (util/attest.c).
*/
tree_root_at_boot(tree_root);
- chain_init_event(cert_sha, set, n, tree_root, set_digest,
- init_digest);
+ rc = chain_init_event(cert_sha, set, n, tree_root, set_digest,
+ init_digest);
+ if (rc) {
+ pr_err("chain: cannot hash the init event: %s", strerror(-rc));
+ return rc;
+ }
rc = chain_init(init_digest, &info);
if (rc == -ENODEV) {
pr_err("tpm: not usable; shirudo requires a TPM 2.0 "
diff --git a/builtin-upatch.c b/builtin-upatch.c
index 972033a6..7219abec 100644
--- a/builtin-upatch.c
+++ b/builtin-upatch.c
@@ -1849,23 +1849,34 @@ static int upatch_apply(const char *path, bool verify_only,
{
__u8 loader_digest[SHIRUDO_UPATCH_PAYLOAD_HASH_LEN];
- shirudo_sha256(insns, u.hdr.loader_insns_len, loader_digest);
+ if (shirudo_sha256(insns, u.hdr.loader_insns_len,
+ loader_digest)) {
+ pr_err("__loader.map: cannot hash the loader");
+ rep_fail(rep, "signed_loader_load", "unknown", EIO,
+ "loader digest failed");
+ rc = 1;
+ goto out;
+ }
map_fd = loader_map_create("__loader.map", u.hdr.data_len,
loader_digest, sizeof(loader_digest));
}
if (map_fd < 0) {
- pr_err("__loader.map create: %s", strerror(errno));
- rep_fail(rep, "signed_loader_load", cat_from_load_errno(errno),
- errno, "__loader.map create failed");
+ int err = errno;
+
+ pr_err("__loader.map create: %s", strerror(err));
+ rep_fail(rep, "signed_loader_load", cat_from_load_errno(err),
+ err, "__loader.map create failed");
rc = 1;
goto out;
}
rc = loader_map_update(map_fd, data, u.hdr.data_len);
if (rc) {
- pr_err("__loader.map update: %s", strerror(errno));
- rep_fail(rep, "signed_loader_load", cat_from_load_errno(errno),
- errno, "__loader.map update failed");
+ int err = errno;
+
+ pr_err("__loader.map update: %s", strerror(err));
+ rep_fail(rep, "signed_loader_load", cat_from_load_errno(err),
+ err, "__loader.map update failed");
rc = 1;
goto out;
}
@@ -2208,7 +2219,12 @@ static int upatch_chain_event(const char *tag, const char *type,
out_chain[0] = '\0';
if (measured)
*measured = false;
- chain_upatch_event(tag, name, payload, event);
+ rc = chain_upatch_event(tag, name, payload, event);
+ if (rc) {
+ pr_err("upatch %s: cannot hash the event (category: tpm_error)",
+ op);
+ return rc;
+ }
rc = chain_extend(event, chain);
if (rc == -ENODEV) {
diff --git a/testing/fuzz/chain.c b/testing/fuzz/chain.c
index 4a483a2c..8b626259 100644
--- a/testing/fuzz/chain.c
+++ b/testing/fuzz/chain.c
@@ -10,10 +10,10 @@
#include "chain.h"
#include "crypto.h"
-void shirudo_sha256(const void *data, size_t len,
- __u8 out[SHIRUDO_CHAIN_DIGEST_LEN])
+int shirudo_sha256(const void *data, size_t len,
+ __u8 out[SHIRUDO_CHAIN_DIGEST_LEN])
{
- sha256_buffer(data, len, out);
+ return sha256_buffer(data, len, out);
}
int ct_eq(const void *a, const void *b, size_t n)
diff --git a/util/bpm_tree_state.c b/util/bpm_tree_state.c
index 3c0ffe80..35ffe881 100644
--- a/util/bpm_tree_state.c
+++ b/util/bpm_tree_state.c
@@ -624,7 +624,9 @@ int tree_event_replay(__u8 out[32])
}
memcpy(next, chain, 32);
memcpy(next + 32, d, 32);
- shirudo_sha256(next, sizeof(next), chain);
+ rc = shirudo_sha256(next, sizeof(next), chain);
+ if (rc)
+ break;
if (!ct_eq(chain, recorded, 32)) {
rc = -EINVAL;
break;
diff --git a/util/chain.c b/util/chain.c
index 8370b369..0bf275dc 100644
--- a/util/chain.c
+++ b/util/chain.c
@@ -29,10 +29,13 @@
#include "paths.h"
#include "tpm.h"
-void shirudo_sha256(const void *data, size_t len, __u8 out[32])
+int shirudo_sha256(const void *data, size_t len, __u8 out[32])
{
- if (sha256_buffer(data, len, out) != 0)
+ int rc = sha256_buffer(data, len, out);
+
+ if (rc)
memset(out, 0, 32);
+ return rc;
}
void sha256_2(const void *a, size_t a_len,
@@ -69,14 +72,15 @@ static int member_cmp(const void *a, const void *b)
((const struct shirudo_measured_upatch *)b)->name);
}
-void chain_init_event(const __u8 cert_sha[32],
- struct shirudo_measured_upatch *set, size_t n,
- const __u8 tree_root[32],
- __u8 set_digest[32], __u8 event[32])
+int chain_init_event(const __u8 cert_sha[32],
+ struct shirudo_measured_upatch *set, size_t n,
+ const __u8 tree_root[32],
+ __u8 set_digest[32], __u8 event[32])
{
__u8 tag[sizeof("shirudo-init") + 96];
size_t taglen = sizeof("shirudo-init"), listing_len = 0, off = 0, i;
char *listing;
+ int rc;
/* set_digest = SHA256(sorted "<payload_hex> <name>\n" listing) */
if (n > 1)
@@ -84,36 +88,35 @@ void chain_init_event(const __u8 cert_sha[32],
for (i = 0; i < n; i++)
listing_len += strlen(set[i].payload_hex) + 1 +
strlen(set[i].name) + 1;
+ memset(set_digest, 0, 32);
+ memset(event, 0, 32);
listing = xmalloc(listing_len + 1);
- if (!listing) {
- memset(set_digest, 0, 32);
- memset(event, 0, 32);
- return;
- }
+ if (!listing)
+ return -ENOMEM;
for (i = 0; i < n; i++) {
int w = strsprintf(listing + off, listing_len + 1 - off,
"%s %s\n", set[i].payload_hex, set[i].name);
if (w < 0) {
xfree(listing, listing_len + 1);
- memset(set_digest, 0, 32);
- memset(event, 0, 32);
- return;
+ return w;
}
off += (size_t)w;
}
- shirudo_sha256(listing, listing_len, set_digest);
+ rc = shirudo_sha256(listing, listing_len, set_digest);
xfree(listing, listing_len + 1);
+ if (rc)
+ return rc;
memcpy(tag, "shirudo-init", taglen);
memcpy(tag + taglen, cert_sha, 32);
memcpy(tag + taglen + 32, set_digest, 32);
memcpy(tag + taglen + 64, tree_root, 32);
- shirudo_sha256(tag, taglen + 96, event);
+ return shirudo_sha256(tag, taglen + 96, event);
}
-void chain_upatch_event(const char *tag, const char *name,
- const __u8 payload[32], __u8 event[32])
+int chain_upatch_event(const char *tag, const char *name,
+ const __u8 payload[32], __u8 event[32])
{
__u8 buf[sizeof("shirudo-unload") + 32 + SHIRUDO_UPATCH_NAME_MAX];
size_t taglen = strlen(tag) + 1, off = 0;
@@ -125,7 +128,7 @@ void chain_upatch_event(const char *tag, const char *name,
off += 32;
memcpy(buf + off, name, namelen);
off += namelen;
- shirudo_sha256(buf, off, event);
+ return shirudo_sha256(buf, off, event);
}
void chain_key_event(const char *tag, const __u8 cert_sha[32],
@@ -425,7 +428,10 @@ int chain_init(const __u8 event[32],
goto out;
memcpy(info->name, written, sizeof(written));
info->name_len = sizeof(written);
- shirudo_sha256(info->anchor, strlen(info->anchor), info->anchor_digest);
+ rc = shirudo_sha256(info->anchor, strlen(info->anchor),
+ info->anchor_digest);
+ if (rc)
+ goto out;
rc = tpm_pcr_extend(tpm, SHIRUDO_CHAIN_PCR,
info->anchor_digest);
if (rc) {
diff --git a/util/chain.h b/util/chain.h
index 4ef6a10f..b6895f56 100644
--- a/util/chain.h
+++ b/util/chain.h
@@ -34,8 +34,8 @@
(1u << SHIRUDO_CHAIN_PHASE_PCR))
#define SHIRUDO_CHAIN_ANCHOR_MAX 128
-void shirudo_sha256(const void *data, size_t len,
- __u8 out[SHIRUDO_CHAIN_DIGEST_LEN]);
+int shirudo_sha256(const void *data, size_t len,
+ __u8 out[SHIRUDO_CHAIN_DIGEST_LEN]);
void sha256_2(const void *a, size_t a_len,
const void *b, size_t b_len,
@@ -53,15 +53,15 @@ struct shirudo_measured_upatch {
* The event digests every measuring path and the predictor share.
* The set is sorted by name before hashing.
*/
-void chain_init_event(const __u8 cert_sha[32],
- struct shirudo_measured_upatch *set, size_t n,
- const __u8 tree_root[32],
- __u8 set_digest[32], __u8 event[32]);
+int chain_init_event(const __u8 cert_sha[32],
+ struct shirudo_measured_upatch *set, size_t n,
+ const __u8 tree_root[32],
+ __u8 set_digest[32], __u8 event[32]);
/* SHA256(tag || NUL || cert_sha256), tag "shirudo-key-revoke". */
void chain_key_event(const char *tag, const __u8 cert_sha[32],
__u8 event[32]);
-void chain_upatch_event(const char *tag, const char *name,
- const __u8 payload[32], __u8 event[32]);
+int chain_upatch_event(const char *tag, const char *name,
+ const __u8 payload[32], __u8 event[32]);
void chain_tree_event(__s64 seq, const __u8 operation_digest[32],
__u8 event[32]);
int shirudo_chain_fold_checked(__u8 chain[32], const __u8 event[32]);
diff --git a/util/keys.c b/util/keys.c
index ea387f38..cdf62317 100644
--- a/util/keys.c
+++ b/util/keys.c
@@ -457,35 +457,38 @@ static int digest_cmp(const void *a, const void *b)
return memcmp(a, b, 32);
}
-void keys_anchor_digest(const __u8 sha256[][32], size_t n,
- __u8 out[32])
+int keys_anchor_digest(const __u8 sha256[][32], size_t n,
+ __u8 out[32])
{
__u8 sorted[SHIRUDO_KEYS_MAX][32];
size_t i;
+ int rc;
if (n == 1) {
memcpy(out, sha256[0], 32);
- return;
- }
- if (n == 0 || n > SHIRUDO_KEYS_MAX) {
- memset(out, 0, 32);
- return;
+ return 0;
}
+ memset(out, 0, 32);
+ if (n == 0 || n > SHIRUDO_KEYS_MAX)
+ return -EINVAL;
for (i = 0; i < n; i++)
memcpy(sorted[i], sha256[i], 32);
qsort(sorted, n, 32, digest_cmp);
- sha256_buffer(sorted, n * 32, out);
+ rc = sha256_buffer(sorted, n * 32, out);
+ if (rc)
+ memset(out, 0, 32);
+ return rc;
}
-void keys_set_digest(const struct shirudo_trusted_set *set,
- __u8 out[32])
+int keys_set_digest(const struct shirudo_trusted_set *set,
+ __u8 out[32])
{
__u8 sha[SHIRUDO_KEYS_MAX][32];
size_t i;
for (i = 0; i < set->n; i++)
memcpy(sha[i], set->certs[i].sha256, 32);
- keys_anchor_digest(sha, set->n, out);
+ return keys_anchor_digest(sha, set->n, out);
}
int keys_write_file(const char *path, const void *data, size_t len)
diff --git a/util/keys.h b/util/keys.h
index 57850430..46a7cc20 100644
--- a/util/keys.h
+++ b/util/keys.h
@@ -78,10 +78,10 @@ int keys_digest_file(const char *path, __u8 sha256[32],
* the SHA-256 over the sorted digests of several. The same function
* serves the operator predicting a register for a set.
*/
-void keys_anchor_digest(const __u8 sha256[][32], size_t n,
- __u8 out[32]);
-void keys_set_digest(const struct shirudo_trusted_set *set,
- __u8 out[32]);
+int keys_anchor_digest(const __u8 sha256[][32], size_t n,
+ __u8 out[32]);
+int keys_set_digest(const struct shirudo_trusted_set *set,
+ __u8 out[32]);
bool keys_is_revoked(const char *revoked_dir,
const __u8 fingerprint[32]);
diff --git a/util/tpm_wire.c b/util/tpm_wire.c
index ceddd997..8e3948eb 100644
--- a/util/tpm_wire.c
+++ b/util/tpm_wire.c
@@ -90,17 +90,18 @@ static int get2b_fixed(struct reader *r, __u8 *out, size_t want)
return 0;
}
-static void policy_hash(const __u8 prev[32], __u32 cc,
- const __u8 *a, size_t a_len,
- const __u8 *b, size_t b_len, __u8 out[32])
+static int policy_hash(const __u8 prev[32], __u32 cc,
+ const __u8 *a, size_t a_len,
+ const __u8 *b, size_t b_len, __u8 out[32])
{
struct shirudo_sha256_ctx ctx;
__u8 cc_be[4];
+ /* prev and out may be one buffer; out changes only once done. */
tpm_put32(cc_be, cc);
if (sha256_init(&ctx) != 0) {
memset(out, 0, 32);
- return;
+ return -EIO;
}
if (sha256_update(&ctx, prev, 32) != 0 ||
sha256_update(&ctx, cc_be, sizeof(cc_be)) != 0 ||
@@ -109,15 +110,18 @@ static void policy_hash(const __u8 prev[32], __u32 cc,
sha256_final(&ctx, out) != 0) {
memset(out, 0, 32);
sha256_free(&ctx);
+ return -EIO;
}
+ return 0;
}
-void tpm_policy_nv_written(const __u8 prev[32], bool written,
- __u8 out[32])
+int tpm_policy_nv_written(const __u8 prev[32], bool written,
+ __u8 out[32])
{
__u8 set = written ? 1 : 0;
- policy_hash(prev, TPM_CC_POLICY_NV_WRITTEN, &set, 1, NULL, 0, out);
+ return policy_hash(prev, TPM_CC_POLICY_NV_WRITTEN, &set, 1, NULL, 0,
+ out);
}
static void
@@ -132,22 +136,21 @@ shirudo_tpm_pcr_selection(__u32 pcr_mask,
out[9] = (__u8)(pcr_mask >> 16);
}
-void tpm_policy_pcr(const __u8 prev[32], __u32 pcr_mask,
- const __u8 pcr_digest[32], __u8 out[32])
+int tpm_policy_pcr(const __u8 prev[32], __u32 pcr_mask,
+ const __u8 pcr_digest[32], __u8 out[32])
{
__u8 sel[SHIRUDO_TPM_PCR_SELECTION_LEN];
shirudo_tpm_pcr_selection(pcr_mask, sel);
- policy_hash(prev, TPM_CC_POLICY_PCR, sel, sizeof(sel), pcr_digest, 32,
- out);
+ return policy_hash(prev, TPM_CC_POLICY_PCR, sel, sizeof(sel),
+ pcr_digest, 32, out);
}
-void tpm_policy_or(const __u8 a[32], const __u8 b[32],
- __u8 out[32])
+int tpm_policy_or(const __u8 a[32], const __u8 b[32], __u8 out[32])
{
static const __u8 zero[32];
- policy_hash(zero, TPM_CC_POLICY_OR, a, 32, b, 32, out);
+ return policy_hash(zero, TPM_CC_POLICY_OR, a, 32, b, 32, out);
}
/*
@@ -211,20 +214,24 @@ int tpm_policy_signed(const __u8 prev[32],
rc = tpm_object_name(public, sizeof(public), name);
if (rc)
return rc;
- policy_hash(prev, TPM_CC_POLICY_SIGNED, name, sizeof(name), NULL, 0, out);
+ rc = policy_hash(prev, TPM_CC_POLICY_SIGNED, name, sizeof(name), NULL,
+ 0, out);
+ if (rc)
+ return rc;
memcpy(bytes, out, 32);
memcpy(bytes + 32, SHIRUDO_TPM_NV_POLICY_REF,
sizeof(SHIRUDO_TPM_NV_POLICY_REF) - 1);
return sha256_buffer(bytes, sizeof(bytes), out);
}
-void tpm_policy_command_code(const __u8 prev[32],
- __u32 command_code, __u8 out[32])
+int tpm_policy_command_code(const __u8 prev[32],
+ __u32 command_code, __u8 out[32])
{
__u8 cc_be[4];
tpm_put32(cc_be, command_code);
- policy_hash(prev, TPM_CC_POLICY_COMMAND_CODE, cc_be, sizeof(cc_be), NULL, 0, out);
+ return policy_hash(prev, TPM_CC_POLICY_COMMAND_CODE, cc_be,
+ sizeof(cc_be), NULL, 0, out);
}
int tpm_register_policy_final(const __u8 branch_written[32],
@@ -234,12 +241,13 @@ int tpm_register_policy_final(const __u8 branch_written[32],
{
int rc;
- tpm_policy_or(branch_written, branch_init, policy);
- rc = tpm_policy_signed(policy, writer_public, policy);
- if (rc)
- return rc;
- tpm_policy_command_code(policy, SHIRUDO_TPM_CC_NV_EXTEND, policy);
- return 0;
+ rc = tpm_policy_or(branch_written, branch_init, policy);
+ if (!rc)
+ rc = tpm_policy_signed(policy, writer_public, policy);
+ if (!rc)
+ rc = tpm_policy_command_code(policy, SHIRUDO_TPM_CC_NV_EXTEND,
+ policy);
+ return rc;
}
int tpm_register_policy(__u32 pcr_mask,
@@ -250,12 +258,20 @@ int tpm_register_policy(__u32 pcr_mask,
{
static const __u8 zero[32];
__u8 pcr_digest[32], unwritten[32];
+ int rc;
- tpm_policy_nv_written(zero, true, branch_written);
- tpm_policy_nv_written(zero, false, unwritten);
- sha256_buffer(pcr_values, 32 * n_values, pcr_digest);
- tpm_policy_pcr(unwritten, pcr_mask, pcr_digest, branch_init);
- return tpm_register_policy_final(branch_written, branch_init, writer_public, policy);
+ rc = tpm_policy_nv_written(zero, true, branch_written);
+ if (!rc)
+ rc = tpm_policy_nv_written(zero, false, unwritten);
+ if (!rc)
+ rc = sha256_buffer(pcr_values, 32 * n_values, pcr_digest);
+ if (!rc)
+ rc = tpm_policy_pcr(unwritten, pcr_mask, pcr_digest,
+ branch_init);
+ if (rc)
+ return rc;
+ return tpm_register_policy_final(branch_written, branch_init,
+ writer_public, policy);
}
void tpm_nv_name(__u32 index, __u32 attrs,
@@ -271,7 +287,8 @@ void tpm_nv_name(__u32 index, __u32 attrs,
memcpy(pub + 12, policy, 32);
tpm_put16(pub + 44, data_size);
tpm_put16(name, SHIRUDO_TPM_ALG_SHA256);
- sha256_buffer(pub, sizeof(pub), name + 2);
+ if (sha256_buffer(pub, sizeof(pub), name + 2))
+ memset(name, 0, SHIRUDO_TPM_NAME_LEN);
}
int tpm_object_name(const __u8 *public, size_t len,
diff --git a/util/tpm_wire.h b/util/tpm_wire.h
index a39cde1f..d1e1e13e 100644
--- a/util/tpm_wire.h
+++ b/util/tpm_wire.h
@@ -67,9 +67,9 @@ int tpm_writer_auth_hash(const __u8 *nonce, size_t nonce_len,
int tpm_policy_signed(const __u8 prev[32],
const __u8 writer_public[SHIRUDO_TPM_NV_RSA_BYTES],
__u8 out[32]);
-void tpm_policy_command_code(const __u8 prev[SHIRUDO_TPM_DIGEST_LEN],
- __u32 command_code,
- __u8 out[SHIRUDO_TPM_DIGEST_LEN]);
+int tpm_policy_command_code(const __u8 prev[SHIRUDO_TPM_DIGEST_LEN],
+ __u32 command_code,
+ __u8 out[SHIRUDO_TPM_DIGEST_LEN]);
int tpm_register_policy_final(const __u8 branch_written[32],
const __u8 branch_init[32],
const __u8 writer_public[SHIRUDO_TPM_NV_RSA_BYTES],
@@ -85,16 +85,16 @@ int tpm_register_policy_final(const __u8 branch_written[32],
#define SHIRUDO_TPM_REGISTER_ATTRS 0x0E060048u
#define SHIRUDO_TPM_NV_WRITTEN 0x20000000u
-void tpm_policy_nv_written(const __u8 prev[SHIRUDO_TPM_DIGEST_LEN],
- bool written,
- __u8 out[SHIRUDO_TPM_DIGEST_LEN]);
-void tpm_policy_pcr(const __u8 prev[SHIRUDO_TPM_DIGEST_LEN],
- __u32 pcr_mask,
- const __u8 pcr_digest[SHIRUDO_TPM_DIGEST_LEN],
- __u8 out[SHIRUDO_TPM_DIGEST_LEN]);
-void tpm_policy_or(const __u8 a[SHIRUDO_TPM_DIGEST_LEN],
- const __u8 b[SHIRUDO_TPM_DIGEST_LEN],
+int tpm_policy_nv_written(const __u8 prev[SHIRUDO_TPM_DIGEST_LEN],
+ bool written,
+ __u8 out[SHIRUDO_TPM_DIGEST_LEN]);
+int tpm_policy_pcr(const __u8 prev[SHIRUDO_TPM_DIGEST_LEN],
+ __u32 pcr_mask,
+ const __u8 pcr_digest[SHIRUDO_TPM_DIGEST_LEN],
__u8 out[SHIRUDO_TPM_DIGEST_LEN]);
+int tpm_policy_or(const __u8 a[SHIRUDO_TPM_DIGEST_LEN],
+ const __u8 b[SHIRUDO_TPM_DIGEST_LEN],
+ __u8 out[SHIRUDO_TPM_DIGEST_LEN]);
/*
* The register's write policy from the values the binding PCRs held