From 961e260cdcd01d68c8dae87eef67e116f1a67aed Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Fri, 20 Jun 2025 00:38:17 +0800 Subject: [PATCH] lib: rsa: fix compilation error without openssl The symbol TOOLS_IMAGE_PRE_LOAD doesn't depend on TOOLS_LIBCRYPTO. If we choose to build tools without openssl, rsa_verify_openssl() will attempt to call the unavailable openssl library functions. Fixes: 942c8c8e6697 ("rsa: Add rsa_verify_openssl() to use openssl for host builds") Signed-off-by: Shiji Yang --- include/image.h | 2 +- lib/rsa/rsa-verify.c | 2 +- tools/image-host.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/image.h b/include/image.h index c1db8383459..5f4e23a0ae9 100644 --- a/include/image.h +++ b/include/image.h @@ -1688,7 +1688,7 @@ struct sig_header_s { */ int image_pre_load(ulong addr); -#if defined(USE_HOSTCC) +#if defined(USE_HOSTCC) && CONFIG_IS_ENABLED(LIBCRYPTO) /** * rsa_verify_openssl() - Verify a signature against some data with openssl API * diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 4a0418a75f1..b65fbe44007 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -570,7 +570,7 @@ int rsa_verify(struct image_sign_info *info, uint8_t hash[info->crypto->key_len]; int ret; -#ifdef USE_HOSTCC +#if defined(USE_HOSTCC) && CONFIG_IS_ENABLED(LIBCRYPTO) if (!info->fdt_blob) return rsa_verify_openssl(info, region, region_count, sig, sig_len); #endif diff --git a/tools/image-host.c b/tools/image-host.c index a9b86902763..21dd7f2d922 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -19,7 +19,7 @@ #include #endif -#if CONFIG_IS_ENABLED(IMAGE_PRE_LOAD) +#if CONFIG_IS_ENABLED(IMAGE_PRE_LOAD) && CONFIG_IS_ENABLED(LIBCRYPTO) #include #include #endif @@ -1416,7 +1416,7 @@ int fit_check_sign(const void *fit, const void *key, } #endif -#if CONFIG_IS_ENABLED(IMAGE_PRE_LOAD) +#if CONFIG_IS_ENABLED(IMAGE_PRE_LOAD) && CONFIG_IS_ENABLED(LIBCRYPTO) /** * rsa_verify_openssl() - Verify a signature against some data with openssl API * -- 2.39.5