summaryrefslogtreecommitdiff
path: root/src/security/vboot/vbios_cache_hash_tpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/security/vboot/vbios_cache_hash_tpm.c')
-rw-r--r--src/security/vboot/vbios_cache_hash_tpm.c24
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;
}