summaryrefslogtreecommitdiff
path: root/src/security/tpm/tspi/crtm.h
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2021-08-11 18:19:23 -0700
committerFelix Held <felix-coreboot@felixheld.de>2021-12-03 21:20:35 +0000
commit7e7cc1a8c9a87e33bd772e8526734c7a82ec2db7 (patch)
treec091beebe657af44f3800402645fa8d257eaab8e /src/security/tpm/tspi/crtm.h
parentc75d846971c2fd96c989a7f8a14011bb70866409 (diff)
cbfs | tspi: Join hash calculation for verification and measurement
This patch moves the CBFS file measurement when CONFIG_TPM_MEASURED_BOOT is enabled from the lookup step into the code where a file is actually loaded or mapped from flash. This has the advantage that CBFS routines which just look up a file to inspect its metadata (e.g. cbfs_get_size()) do not cause the file to be measured twice. It also removes the existing inefficiency that files are loaded twice when measurement is enabled (once to measure and then again when they are used). When CBFS verification is enabled and uses the same hash algorithm as the TPM, we are even able to only hash the file a single time and use the result for both purposes. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I70d7066c6768195077f083c7ffdfa30d9182b2b7 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59681 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
Diffstat (limited to 'src/security/tpm/tspi/crtm.h')
-rw-r--r--src/security/tpm/tspi/crtm.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/security/tpm/tspi/crtm.h b/src/security/tpm/tspi/crtm.h
index 011fa26ad7..8ebb661130 100644
--- a/src/security/tpm/tspi/crtm.h
+++ b/src/security/tpm/tspi/crtm.h
@@ -7,6 +7,7 @@
#include <program_loading.h>
#include <security/tpm/tspi.h>
#include <types.h>
+#include <vb2_sha.h>
/* CRTM */
#define TPM_CRTM_PCR 2
@@ -16,21 +17,16 @@
*/
#define TPM_RUNTIME_DATA_PCR 3
+#define TPM_MEASURE_ALGO (CONFIG(TPM1) ? VB2_HASH_SHA1 : VB2_HASH_SHA256)
+
/**
* Measure digests cached in TCPA log entries into PCRs
*/
int tspi_measure_cache_to_pcr(void);
-#if !ENV_SMM && CONFIG(TPM_MEASURED_BOOT)
-/*
- * Measures cbfs data via hook (cbfs)
- * rdev covers the file data (not metadata)
- * return 0 if successful, else an error
+/**
+ * Extend a measurement hash taken for a CBFS file into the appropriate PCR.
*/
-uint32_t tspi_measure_cbfs_hook(const struct region_device *rdev,
- const char *name, uint32_t cbfs_type);
-#else
-#define tspi_measure_cbfs_hook(rdev, name, cbfs_type) 0
-#endif
+uint32_t tspi_cbfs_measurement(const char *name, uint32_t type, const struct vb2_hash *hash);
#endif /* __SECURITY_TSPI_CRTM_H__ */