diff options
author | Jon Murphy <jpmurphy@google.com> | 2023-09-05 11:36:43 -0600 |
---|---|---|
committer | Raul Rangel <rrangel@chromium.org> | 2023-09-28 16:54:37 +0000 |
commit | d7b8dc9cf5978809912dcffefce2eda5937c9653 (patch) | |
tree | 56befbc9563ce2baca6f31ccbfb041e99fb858d6 /src/security/vboot/vbios_cache_hash_tpm.c | |
parent | 53fc667943052bd592b8406bdf4bf652c6c9cd3a (diff) |
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 <jpmurphy@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77666
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/security/vboot/vbios_cache_hash_tpm.c')
-rw-r--r-- | src/security/vboot/vbios_cache_hash_tpm.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/security/vboot/vbios_cache_hash_tpm.c b/src/security/vboot/vbios_cache_hash_tpm.c index 6ad09ace8e..49971350f1 100644 --- a/src/security/vboot/vbios_cache_hash_tpm.c +++ b/src/security/vboot/vbios_cache_hash_tpm.c @@ -12,10 +12,12 @@ void vbios_cache_update_hash(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, "VBIOS_CACHE: TPM driver initialization failed.\n"); + rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "VBIOS_CACHE: TPM driver initialization failed with error %#x.\n", rc); return; } @@ -35,9 +37,9 @@ void vbios_cache_update_hash(const uint8_t *data, size_t size) } /* Write hash of data to TPM space. */ - if (antirollback_write_space_vbios_hash(hash.sha256, sizeof(hash.sha256)) - != TPM_SUCCESS) { - printk(BIOS_ERR, "VBIOS_CACHE: Could not save hash to TPM.\n"); + rc = antirollback_write_space_vbios_hash(hash.sha256, sizeof(hash.sha256)); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "VBIOS_CACHE: Could not save hash to TPM with error %#x.\n", rc); return; } @@ -48,17 +50,19 @@ void vbios_cache_update_hash(const uint8_t *data, size_t size) enum cb_err vbios_cache_verify_hash(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, "VBIOS_CACHE: TPM driver initialization failed.\n"); + rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "VBIOS_CACHE: TPM driver initialization failed with error %#x.\n", rc); return CB_ERR; } /* Read hash of VBIOS data saved in TPM. */ - if (antirollback_read_space_vbios_hash(tpm_hash.sha256, sizeof(tpm_hash.sha256)) - != TPM_SUCCESS) { - printk(BIOS_ERR, "VBIOS_CACHE: Could not read hash from TPM.\n"); + rc = antirollback_read_space_vbios_hash(tpm_hash.sha256, sizeof(tpm_hash.sha256)); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "VBIOS_CACHE: Could not read hash from TPM with error %#x.\n", rc); return CB_ERR; } |