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 4/8] ima-evm-utils: add support in tpm2_read_pcrs to read different TPM banks
Date: Fri, 21 Feb 2020 13:38:54 -0500 [thread overview]
Message-ID: <1582310338-1562-5-git-send-email-zohar@linux.ibm.com> (raw)
In-Reply-To: <1582310338-1562-1-git-send-email-zohar@linux.ibm.com>
tpm2_read_pcrs() reads the sha1 PCRs in order to verify the measurmeent
list. This patch adds support for reading other TPM banks.
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
src/evmctl.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/evmctl.c b/src/evmctl.c
index 61a0e15c8dd7..1eeab1d8268b 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1423,14 +1423,16 @@ static int tpm_pcr_read(int idx, uint8_t *pcr, int len)
}
#ifdef HAVE_TSSPCRREAD
-static int tpm2_pcr_read(int idx, uint8_t *hwpcr, int len, char **errmsg)
+static int tpm2_pcr_read(const char *algo_name, int idx, uint8_t *hwpcr,
+ int len, char **errmsg)
{
FILE *fp;
char pcr[100]; /* may contain an error */
char cmd[50];
int ret;
- sprintf(cmd, "tsspcrread -halg sha1 -ha %d -ns 2> /dev/null", idx);
+ sprintf(cmd, "tsspcrread -halg %s -ha %d -ns 2> /dev/null",
+ algo_name, idx);
fp = popen(cmd, "r");
if (!fp) {
ret = asprintf(errmsg, "popen failed: %s", strerror(errno));
@@ -1456,7 +1458,7 @@ static int tpm2_pcr_read(int idx, uint8_t *hwpcr, int len, char **errmsg)
ret = -1;
if (!ret)
- hex2bin(hwpcr, pcr, SHA_DIGEST_LENGTH);
+ hex2bin(hwpcr, pcr, len);
else
*errmsg = strndup(pcr, strlen(pcr) - 1); /* remove newline */
@@ -1885,7 +1887,8 @@ static int ima_measurement(const char *file)
#ifdef HAVE_TSSPCRREAD
char *errmsg = NULL;
- err = tpm2_pcr_read(i, hwpcr, sizeof(hwpcr), &errmsg);
+ err = tpm2_pcr_read("sha1", i, hwpcr, sizeof(hwpcr),
+ &errmsg);
if (err) {
log_info("Failed to read PCRs: (%s)\n", errmsg);
free(errmsg);
--
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 ` Mimi Zohar [this message]
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 ` [RFC PATCH 6/8] ima-evm-utils: compare re-calculated PCRs with the TPM values Mimi Zohar
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-5-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