From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: Roberto Sassu <roberto.sassu@huawei.com>,
Vitaly Chikunov <vt@altlinux.org>,
Patrick Uiterwijk <puiterwi@redhat.com>,
Petr Vorel <pvorel@suse.cz>, Mimi Zohar <zohar@linux.ibm.com>
Subject: [RFC PATCH 6/8] ima-evm-utils: compare re-calculated PCRs with the TPM values
Date: Fri, 21 Feb 2020 13:38:56 -0500 [thread overview]
Message-ID: <1582310338-1562-7-git-send-email-zohar@linux.ibm.com> (raw)
In-Reply-To: <1582310338-1562-1-git-send-email-zohar@linux.ibm.com>
After walking the measurement list, re-calculating and extending the TPM
PCRs with the appropriate template digest for each bank, compare the
re-calculated PCR values for each TPM bank with the actual TPM values.
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
src/evmctl.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/src/evmctl.c b/src/evmctl.c
index 3e512cf4e3d2..9e21d3963556 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1701,6 +1701,38 @@ static struct tpm_bank_info *init_tpm_banks(int *num_banks)
return banks;
}
+static int compare_tpm_banks(int num_banks, struct tpm_bank_info *bank,
+ struct tpm_bank_info *tpm_bank)
+{
+ int i, j;
+ int ret = 0;
+
+ for (i = 0; i < num_banks; i++) {
+ if (!bank[i].supported || !tpm_bank[i].supported)
+ continue;
+ for (j = 0; j < NUM_PCRS; j++) {
+ if (memcmp(bank[i].pcr[j], zero, bank[i].digest_size)
+ == 0)
+ continue;
+ log_info("%s: PCRAgg %d: ", bank[i].algo_name, j);
+ log_dump(bank[i].pcr[j], bank[i].digest_size);
+
+ log_info("%s: TPM PCR-%d: ", tpm_bank[i].algo_name, j);
+ log_dump(tpm_bank[i].pcr[j], tpm_bank[i].digest_size);
+
+ ret = memcmp(bank[i].pcr[j], tpm_bank[i].pcr[j],
+ bank[i].digest_size);
+ if (!ret)
+ log_info("%s PCR-%d: succeed\n",
+ bank[i].algo_name, j);
+ else
+ log_info("%s: PCRAgg %d does not match TPM PCR-%d\n",
+ bank[i].algo_name, i, i);
+ }
+ }
+ return ret;
+}
+
/* Calculate the template hash for a particular hash algorithm */
static int calculate_template_digest(EVP_MD_CTX *pctx, const EVP_MD *md,
struct template_entry *entry,
@@ -1959,8 +1991,10 @@ static int ima_measurement(const char *file)
if (!verify_failed)
err = 0;
+ else if (read_tpm_banks(num_banks, tpm_banks) != 0)
+ log_info("Failed to read TPM 2.0 PCRs\n");
else
- read_tpm_banks(num_banks, tpm_banks);
+ err = compare_tpm_banks(num_banks, pseudo_banks, tpm_banks);
out:
fclose(fp);
--
2.7.5
next prev parent reply other threads:[~2020-02-21 18:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 18:38 [RFC PATCH 0/8] ima-evm-utils: calculate per TPM bank template digest Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 1/8] ima-evm-utils: treat unallocated banks as an error Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 2/8] ima-evm-utils: increase the size of "zero" and "fox" variables Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 3/8] ima-evm-utils: calculate the digests for multiple TPM banks Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 4/8] ima-evm-utils: add support in tpm2_read_pcrs to read different " Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 5/8] ima-evm-utils: read the PCRs for the requested " Mimi Zohar
2020-02-21 18:38 ` Mimi Zohar [this message]
2020-02-21 18:38 ` [RFC PATCH 7/8] ima-evm-utils: use a common bank variable for TPM 1.2 and TPM 2.0 Mimi Zohar
2020-02-21 18:38 ` [RFC PATCH 8/8] ima-evm-utils: remove TPM 1.2 specific code Mimi Zohar
2020-02-22 0:11 ` [RFC PATCH 0/8] ima-evm-utils: calculate per TPM bank template digest Lakshmi Ramasubramanian
2020-02-23 1:12 ` Mimi Zohar
2020-02-24 16:23 ` Lakshmi Ramasubramanian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1582310338-1562-7-git-send-email-zohar@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=puiterwi@redhat.com \
--cc=pvorel@suse.cz \
--cc=roberto.sassu@huawei.com \
--cc=vt@altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).