From d7b8dc9cf5978809912dcffefce2eda5937c9653 Mon Sep 17 00:00:00 2001 From: Jon Murphy Date: Tue, 5 Sep 2023 11:36:43 -0600 Subject: treewide: convert to tpm_result_t Convert TPM functions to return TPM error codes(referred to as tpm_result_t) values to match the TCG standard. BUG=b:296439237 TEST=build and boot to Skyrim BRANCH=None Change-Id: Ifdf9ff6c2a1f9b938dbb04d245799391115eb6b1 Signed-off-by: Jon Murphy Reviewed-on: https://review.coreboot.org/c/coreboot/+/77666 Reviewed-by: Raul Rangel Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/security/vboot/mrc_cache_hash_tpm.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/security/vboot/mrc_cache_hash_tpm.c') diff --git a/src/security/vboot/mrc_cache_hash_tpm.c b/src/security/vboot/mrc_cache_hash_tpm.c index 07baed7eba..d7712a9c5e 100644 --- a/src/security/vboot/mrc_cache_hash_tpm.c +++ b/src/security/vboot/mrc_cache_hash_tpm.c @@ -12,10 +12,12 @@ void mrc_cache_update_hash(uint32_t index, const uint8_t *data, size_t size) { struct vb2_hash hash; + tpm_result_t rc = TPM_SUCCESS; /* Initialize TPM driver. */ - if (tlcl_lib_init() != VB2_SUCCESS) { - printk(BIOS_ERR, "MRC: TPM driver initialization failed.\n"); + rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "MRC: TPM driver initialization failed with error %#x.\n", rc); return; } @@ -35,9 +37,9 @@ void mrc_cache_update_hash(uint32_t index, const uint8_t *data, size_t size) } /* Write hash of data to TPM space. */ - if (antirollback_write_space_mrc_hash(index, hash.sha256, sizeof(hash.sha256)) - != TPM_SUCCESS) { - printk(BIOS_ERR, "MRC: Could not save hash to TPM.\n"); + rc = antirollback_write_space_mrc_hash(index, hash.sha256, sizeof(hash.sha256)); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "MRC: Could not save hash to TPM with error %#x.\n", rc); return; } @@ -47,17 +49,19 @@ void mrc_cache_update_hash(uint32_t index, const uint8_t *data, size_t size) int mrc_cache_verify_hash(uint32_t index, const uint8_t *data, size_t size) { struct vb2_hash tpm_hash = { .algo = VB2_HASH_SHA256 }; + tpm_result_t rc = TPM_SUCCESS; /* Initialize TPM driver. */ - if (tlcl_lib_init() != VB2_SUCCESS) { - printk(BIOS_ERR, "MRC: TPM driver initialization failed.\n"); + rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "MRC: TPM driver initialization failed with error %#x.\n", rc); return 0; } /* Read hash of MRC data saved in TPM. */ - if (antirollback_read_space_mrc_hash(index, tpm_hash.sha256, sizeof(tpm_hash.sha256)) - != TPM_SUCCESS) { - printk(BIOS_ERR, "MRC: Could not read hash from TPM.\n"); + rc = antirollback_read_space_mrc_hash(index, tpm_hash.sha256, sizeof(tpm_hash.sha256)); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "MRC: Could not read hash from TPM with error %#x.\n", rc); return 0; } -- cgit v1.2.3