From 589eff7e476f452773bb3cc2ca1469446e2097f4 Mon Sep 17 00:00:00 2001 From: Frans Hendriks Date: Wed, 26 Jun 2019 10:43:40 +0200 Subject: security/tpm/tss/tcg-2.0: Add TPM2 function tlcl_getcapability() Add function tlcl_getcapability() to return TPM2 capability. To support TPM2 capability TPM_CAP_PCRS handling is added to unmarshal_get_capability(). BUG=N/A TEST=Build binary and verified logging on Facebook FBG-1701 Change-Id: I85e1bd2822aa6e7fd95ff2b9faa25cf183e6de37 Signed-off-by: Frans Hendriks Reviewed-on: https://review.coreboot.org/c/coreboot/+/30826 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/security/tpm/tss/tcg-2.0/tss_marshaling.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/security/tpm/tss/tcg-2.0/tss_marshaling.c') diff --git a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c index 21da73a885..345aec5124 100644 --- a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c +++ b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c @@ -1,5 +1,6 @@ /* * Copyright 2016 The Chromium OS Authors. All rights reserved. + * Copyright (c) 2018 Eltan B.V. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -12,6 +13,7 @@ #include "tss_marshaling.h" #include +#include static uint16_t tpm_tag CAR_GLOBAL; /* Depends on the command type. */ @@ -421,6 +423,22 @@ static int unmarshal_get_capability(struct ibuf *ib, rc |= ibuf_read_be32(ib, &pp->value); } break; + case TPM_CAP_PCRS: + if (ibuf_read_be32(ib, &gcr->cd.data.assignedPCR.count)) + return -1; + if (gcr->cd.data.assignedPCR.count > + ARRAY_SIZE(gcr->cd.data.assignedPCR.pcrSelections)) { + printk(BIOS_INFO, "%s:%s:%d - %d - too many properties\n", + __FILE__, __func__, __LINE__, + gcr->cd.data.assignedPCR.count); + return -1; + } + for (i = 0; i < gcr->cd.data.assignedPCR.count; i++) { + TPMS_PCR_SELECTION *pp = + &gcr->cd.data.assignedPCR.pcrSelections[i]; + rc |= ibuf_read(ib, pp, sizeof(TPMS_PCR_SELECTION)); + } + break; default: printk(BIOS_ERR, "%s:%d - unable to unmarshal capability response", -- cgit v1.2.3