[PATCH 12/23] image: switch sha256 to mbedtls

Raymond Mao raymond.mao at linaro.org
Tue Apr 16 21:00:08 CEST 2024


When MBEDTLS_LIB_CRYPTO is enabled, use the APIs of sha256 from
hash shim layer instead.

Signed-off-by: Raymond Mao <raymond.mao at linaro.org>
---
 boot/image-pre-load.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c
index b504ab42a5..85d5ff3ab7 100644
--- a/boot/image-pre-load.c
+++ b/boot/image-pre-load.c
@@ -8,8 +8,11 @@
 DECLARE_GLOBAL_DATA_PTR;
 #include <image.h>
 #include <mapmem.h>
-
+#if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
+#include <mbedtls/sha256.h>
+#else
 #include <u-boot/sha256.h>
+#endif
 
 /*
  * Offset of the image
@@ -240,8 +243,13 @@ static int image_pre_load_sig_check_img_sig_sha256(struct image_sig_info *info,
 		goto out_sig_header;
 	}
 
+#if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
+	sha256_csum_wd_mb(header + offset_img_sig, info->sig_size,
+			  sha256_img_sig, CHUNKSZ_SHA256);
+#else
 	sha256_csum_wd(header + offset_img_sig, info->sig_size,
 		       sha256_img_sig, CHUNKSZ_SHA256);
+#endif
 
 	ret = memcmp(sig_header->sha256_img_sig, sha256_img_sig, SHA256_SUM_LEN);
 	if (ret) {
-- 
2.25.1



More information about the U-Boot mailing list