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/mrc_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/mrc_cache_hash_tpm.c')
-rw-r--r-- | src/security/vboot/mrc_cache_hash_tpm.c | 24 |
1 files changed, 14 insertions, 10 deletions
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; } |