refactor(measured-boot): add generic macros for using Crypto library
It doesn't look correct to use mbed TLS defines directly in the Event
Log driver as this driver may use another Crypto library in future.
Hence mbed TLS Crypto dependency on Event Log driver is removed by
introducing generic Crypto defines and uses those in the Event Log
driver to call Crypto functions.
Also, updated mbed TLS glue layer to map these generic Crypto defines
to mbed TLS library defines.
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Change-Id: Ibc9c751f60cbce4d3f3cf049b7c53b3d05cc6735
diff --git a/drivers/auth/mbedtls/mbedtls_common.mk b/drivers/auth/mbedtls/mbedtls_common.mk
index 53ebe30..54c819c 100644
--- a/drivers/auth/mbedtls/mbedtls_common.mk
+++ b/drivers/auth/mbedtls/mbedtls_common.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2015-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -96,6 +96,18 @@
TF_MBEDTLS_USE_AES_GCM := 0
endif
+ifeq ($(MEASURED_BOOT),1)
+ ifeq (${TPM_HASH_ALG}, sha256)
+ TF_MBEDTLS_TPM_HASH_ALG_ID := TF_MBEDTLS_SHA256
+ else ifeq (${TPM_HASH_ALG}, sha384)
+ TF_MBEDTLS_TPM_HASH_ALG_ID := TF_MBEDTLS_SHA384
+ else ifeq (${TPM_HASH_ALG}, sha512)
+ TF_MBEDTLS_TPM_HASH_ALG_ID := TF_MBEDTLS_SHA512
+ else
+ $(error "TPM_HASH_ALG not defined.")
+ endif
+endif
+
# Needs to be set to drive mbed TLS configuration correctly
$(eval $(call add_defines,\
$(sort \
@@ -105,6 +117,10 @@
TF_MBEDTLS_USE_AES_GCM \
)))
+ifeq ($(MEASURED_BOOT),1)
+ $(eval $(call add_define,TF_MBEDTLS_TPM_HASH_ALG_ID))
+endif
+
$(eval $(call MAKE_LIB,mbedtls))
endif