All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul-Erwan Rio <paulerwan.rio@gmail.com>
To: u-boot@lists.denx.de
Cc: "Simon Glass" <sjg@chromium.org>,
	"Paul-Erwan Rio" <paulerwan.rio@gmail.com>,
	"AKASHI Takahiro" <takahiro.akashi@linaro.org>,
	"Andre Przywara" <andre.przywara@arm.com>,
	"Fabio Estevam" <festevam@denx.de>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Jan Kiszka" <jan.kiszka@siemens.com>,
	"Mamta Shukla" <mamta.shukla@leica-geosystems.com>,
	"Mark Kettenis" <kettenis@openbsd.org>,
	"Mikhail Ilin" <ilin.mikhail.ol@gmail.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Philippe Reynes" <philippe.reynes@softathome.com>,
	"Sean Anderson" <sean.anderson@seco.com>,
	"Stefan Eichenberger" <eichest@gmail.com>,
	"Steven Lawrance" <steven.lawrance@softathome.com>,
	"Thomas Haemmerle" <thomas.haemmerle@leica-geosystems.com>
Subject: [PATCH v1 2/2] tools: fix build without LIBCRYPTO support
Date: Sat, 21 Jan 2023 16:47:42 +0100	[thread overview]
Message-ID: <20230121154743.667253-3-paulerwan.rio@gmail.com> (raw)
In-Reply-To: <20230121154743.667253-1-paulerwan.rio@gmail.com>

Commit <cb9faa6f98ae56d70d59505dad290dd3d381cb7b> introduced a
target-independent configuration to build crypto features in host tools.

But since commit <2c21256b27d70b5950bd059330cdab027fb6ab7e>, the build
without OpenSSL is broken, due to FIT signature/encryption features. Add
missing conditional compilation tokens to fix this.

Signed-off-by: Paul-Erwan Rio <paulerwan.rio@gmail.com>
---

 include/image.h    | 2 +-
 tools/Kconfig      | 1 +
 tools/fit_image.c  | 2 +-
 tools/image-host.c | 2 ++
 tools/mkimage.c    | 5 +++--
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/image.h b/include/image.h
index 7717a4c13d..6a616d15fb 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1388,7 +1388,7 @@ int calculate_hash(const void *data, int data_len, const char *algo,
  * device
  */
 #if defined(USE_HOSTCC)
-# if defined(CONFIG_FIT_SIGNATURE)
+# if CONFIG_IS_ENABLED(FIT_SIGNATURE)
 #  define IMAGE_ENABLE_SIGN	1
 #  define FIT_IMAGE_ENABLE_VERIFY	1
 #  include <openssl/evp.h>
diff --git a/tools/Kconfig b/tools/Kconfig
index 539708f277..cfad26302c 100644
--- a/tools/Kconfig
+++ b/tools/Kconfig
@@ -46,6 +46,7 @@ config TOOLS_FIT_RSASSA_PSS
 	  Support the rsassa-pss signature scheme in the tools builds
 
 config TOOLS_FIT_SIGNATURE
+	depends on TOOLS_LIBCRYPTO
 	def_bool y
 	help
 	  Enable signature verification of FIT uImages in the tools builds
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 8a18b1b0ba..148dc5df40 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -61,7 +61,7 @@ static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
 		ret = fit_set_timestamp(ptr, 0, time);
 	}
 
-	if (!ret)
+	if (CONFIG_IS_ENABLED(FIT_SIGNATURE) && !ret)
 		ret = fit_pre_load_data(params->keydir, dest_blob, ptr);
 
 	if (!ret) {
diff --git a/tools/image-host.c b/tools/image-host.c
index 4a24dee815..d09a03bd76 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -1119,6 +1119,7 @@ static int fit_config_add_verification_data(const char *keydir,
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(FIT_SIGNATURE)
 /*
  * 0) open file (open)
  * 1) read certificate (PEM_read_X509)
@@ -1227,6 +1228,7 @@ int fit_pre_load_data(const char *keydir, void *keydest, void *fit)
  out:
 	return ret;
 }
+#endif
 
 int fit_cipher_data(const char *keydir, void *keydest, void *fit,
 		    const char *comment, int require_keys,
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 8306861ce5..866410934e 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -115,7 +115,7 @@ static void usage(const char *msg)
 		"          -B => align size in hex for FIT structure and header\n"
 		"          -b => append the device tree binary to the FIT\n"
 		"          -t => update the timestamp in the FIT\n");
-#ifdef CONFIG_FIT_SIGNATURE
+#if CONFIG_IS_ENABLED(FIT_SIGNATURE)
 	fprintf(stderr,
 		"Signing / verified boot options: [-k keydir] [-K dtb] [ -c <comment>] [-p addr] [-r] [-N engine]\n"
 		"          -k => set directory containing private keys\n"
@@ -130,8 +130,9 @@ static void usage(const char *msg)
 		"          -o => algorithm to use for signing\n");
 #else
 	fprintf(stderr,
-		"Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)\n");
+		"Signing / verified boot not supported (CONFIG_TOOLS_FIT_SIGNATURE undefined)\n");
 #endif
+
 	fprintf(stderr, "       %s -V ==> print version information and exit\n",
 		params.cmdname);
 	fprintf(stderr, "Use '-T list' to see a list of available image types\n");
-- 
2.39.0


  parent reply	other threads:[~2023-01-21 15:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 15:47 [PATCH v1 0/2] Fix host tools build without LIBCRYPTO support Paul-Erwan Rio
2023-01-21 15:47 ` [PATCH v1 1/2] tools: kwbimage: disable secure boot " Paul-Erwan Rio
2023-01-21 15:56   ` Pali Rohar
2023-01-21 16:08     ` Paul-Erwan RIO
2023-01-21 16:21       ` Pali Rohar
2023-01-21 16:31         ` Paul-Erwan RIO
2023-01-21 16:35           ` Pali Rohar
2023-01-21 16:40             ` Paul-Erwan RIO
2023-01-21 15:47 ` Paul-Erwan Rio [this message]
2023-01-23 18:50   ` [PATCH v1 2/2] tools: fix " Simon Glass
2023-12-13 15:38   ` Alexander Dahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230121154743.667253-3-paulerwan.rio@gmail.com \
    --to=paulerwan.rio@gmail.com \
    --cc=andre.przywara@arm.com \
    --cc=eichest@gmail.com \
    --cc=festevam@denx.de \
    --cc=ilin.mikhail.ol@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kettenis@openbsd.org \
    --cc=mamta.shukla@leica-geosystems.com \
    --cc=pali@kernel.org \
    --cc=philippe.reynes@softathome.com \
    --cc=sean.anderson@seco.com \
    --cc=sjg@chromium.org \
    --cc=steven.lawrance@softathome.com \
    --cc=takahiro.akashi@linaro.org \
    --cc=thomas.haemmerle@leica-geosystems.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.