From ac935ca8bcb5227a599284799917c9c04c26e3ee Mon Sep 17 00:00:00 2001
From: Juergen Repp <juergen.repp@sit.fraunhofer.de>
Date: Fri, 21 Aug 2020 17:55:16 +0200
Subject: [PATCH] FAPI: Fix execution of policy callback for reading PCR
 registers.

For Policy PCR current PCR registers of the TPM registers can be used to compute
the policy digest. The counter in the computed PCR list was not set. Thus a empty
PCR list was used for the policy digest computation.

Signed-off-by: Juergen Repp <juergen.repp@sit.fraunhofer.de>
---
 src/tss2-fapi/ifapi_policy_callbacks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/tss2-fapi/ifapi_policy_callbacks.c b/src/tss2-fapi/ifapi_policy_callbacks.c
index c0600ae..887a2c3 100644
--- a/src/tss2-fapi/ifapi_policy_callbacks.c
+++ b/src/tss2-fapi/ifapi_policy_callbacks.c
@@ -364,6 +364,7 @@ ifapi_read_pcr(
 
         /* Initialize digest list with pcr values from TPM */
         i_pcr = 0;
+        (*pcr_values)->count = pcr_digests->count;
         for (i = 0; i < out_selection->count; i++) {
             for (pcr = 0; pcr < TPM2_MAX_PCRS; pcr++) {
                 uint8_t byte_idx = pcr / 8;
-- 
1.8.3.1

