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.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/security/tpm/tss/tcg-2.0/tss.c') diff --git a/src/security/tpm/tss/tcg-2.0/tss.c b/src/security/tpm/tss/tcg-2.0/tss.c index c4b553840f..08a7caa1a9 100644 --- a/src/security/tpm/tss/tcg-2.0/tss.c +++ b/src/security/tpm/tss/tcg-2.0/tss.c @@ -1,5 +1,6 @@ /* * Copyright 2016 The Chromium OS Authors. All rights reserved. + * Copyright 2017-2019 Eltan B.V. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -366,3 +367,31 @@ uint32_t tlcl_disable_platform_hierarchy(void) return TPM_SUCCESS; } + +uint32_t tlcl_get_capability(TPM_CAP capability, uint32_t property, + uint32_t property_count, + TPMS_CAPABILITY_DATA *capability_data) +{ + struct tpm2_get_capability cmd; + struct tpm2_response *response; + + cmd.capability = capability; + cmd.property = property; + cmd.propertyCount = property_count; + + if (property_count > 1) { + printk(BIOS_ERR, "%s: property_count more than one not " + "supported yet\n", __func__); + return TPM_E_IOERROR; + } + + response = tpm_process_command(TPM2_GetCapability, &cmd); + + if (!response) { + printk(BIOS_ERR, "%s: Command Failed\n", __func__); + return TPM_E_IOERROR; + } + + memcpy(capability_data, &response->gc.cd, sizeof(TPMS_CAPABILITY_DATA)); + return TPM_SUCCESS; +} -- cgit v1.2.3