All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Marek Behún" <marek.behun@nic.cz>,
	u-boot@lists.denx.de, "Chris Packham" <judge.packham@gmail.com>,
	"Baruch Siach" <baruch@tkos.co.il>,
	"Dirk Eibach" <dirk.eibach@gdsys.cc>,
	"Chris Packham" <chris.packham@alliedtelesis.co.nz>
Cc: "Dennis Gilmore" <dgilmore@redhat.com>,
	"Mario Six" <mario.six@gdsys.cc>,
	"Jon Nettleton" <jon@solid-run.com>,
	"Pali Rohár" <pali@kernel.org>
Subject: Re: [PATCH u-boot-mvebu v2 19/41] tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X
Date: Wed, 21 Jul 2021 11:36:57 +0200	[thread overview]
Message-ID: <bd7919e7-7577-977e-e392-0855d133ec43@denx.de> (raw)
In-Reply-To: <20210719122104.29698-20-marek.behun@nic.cz>

On 19.07.21 14:20, Marek Behún wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> The mkimage host tool can be used to generate kwbimage v1 image with
> secure header on host system for A38x plaform also when U-Boot is being
> compiled for different platform. So there is no reason to not allow
> compiling of mkimage/kwbimage with secure header support for e.g. x86-64
> host.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marek Behún <marek.behun@nic.cz>
> Reviewed-by: Chris Packham <judge.packham@gmail.com>
> Tested-by: Chris Packham <judge.packham@gmail.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   tools/Makefile   |  4 ----
>   tools/kwbimage.c | 22 ----------------------
>   2 files changed, 26 deletions(-)
> 
> diff --git a/tools/Makefile b/tools/Makefile
> index fadf3135d6..7c27069c86 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -159,10 +159,6 @@ ifneq ($(CONFIG_SYS_U_BOOT_OFFS),)
>   HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS)
>   endif
>   
> -ifneq ($(CONFIG_ARMADA_38X),)
> -HOSTCFLAGS_kwbimage.o += -DCONFIG_KWB_SECURE
> -endif
> -
>   # MXSImage needs LibSSL
>   ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_FIT_SIGNATURE)$(CONFIG_FIT_CIPHER),)
>   HOSTCFLAGS_kwbimage.o += \
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 469e5b55f2..f3b16d94ad 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -16,7 +16,6 @@
>   #include <stdint.h>
>   #include "kwbimage.h"
>   
> -#ifdef CONFIG_KWB_SECURE
>   #include <openssl/bn.h>
>   #include <openssl/rsa.h>
>   #include <openssl/pem.h>
> @@ -42,13 +41,10 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
>   	EVP_MD_CTX_reset(ctx);
>   }
>   #endif
> -#endif
>   
>   static struct image_cfg_element *image_cfg;
>   static int cfgn;
> -#ifdef CONFIG_KWB_SECURE
>   static int verbose_mode;
> -#endif
>   
>   struct boot_mode {
>   	unsigned int id;
> @@ -243,8 +239,6 @@ image_count_options(unsigned int optiontype)
>   	return count;
>   }
>   
> -#if defined(CONFIG_KWB_SECURE)
> -
>   static int image_get_csk_index(void)
>   {
>   	struct image_cfg_element *e;
> @@ -267,8 +261,6 @@ static bool image_get_spezialized_img(void)
>   	return e->sec_specialized_img;
>   }
>   
> -#endif
> -
>   /*
>    * Compute a 8-bit checksum of a memory area. This algorithm follows
>    * the requirements of the Marvell SoC BootROM specifications.
> @@ -363,7 +355,6 @@ static uint8_t baudrate_to_option(unsigned int baudrate)
>   	}
>   }
>   
> -#if defined(CONFIG_KWB_SECURE)
>   static void kwb_msg(const char *fmt, ...)
>   {
>   	if (verbose_mode) {
> @@ -852,8 +843,6 @@ done:
>   	return ret;
>   }
>   
> -#endif
> -
>   static void *image_create_v0(size_t *imagesz, struct image_tool_params *params,
>   			     int payloadsz)
>   {
> @@ -984,13 +973,11 @@ static size_t image_headersz_v1(int *hasext)
>   			*hasext = 1;
>   	}
>   
> -#if defined(CONFIG_KWB_SECURE)
>   	if (image_get_csk_index() >= 0) {
>   		headersz += sizeof(struct secure_hdr_v1);
>   		if (hasext)
>   			*hasext = 1;
>   	}
> -#endif
>   
>   #if defined(CONFIG_SYS_U_BOOT_OFFS)
>   	if (headersz > CONFIG_SYS_U_BOOT_OFFS) {
> @@ -1080,8 +1067,6 @@ err_close:
>   	return -1;
>   }
>   
> -#if defined(CONFIG_KWB_SECURE)
> -
>   int export_pub_kak_hash(RSA *kak, struct secure_hdr_v1 *secure_hdr)
>   {
>   	FILE *hashf;
> @@ -1189,7 +1174,6 @@ int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,
>   
>   	return 0;
>   }
> -#endif
>   
>   static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   			     uint8_t *ptr, int payloadsz)
> @@ -1197,9 +1181,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   	struct image_cfg_element *e;
>   	struct main_hdr_v1 *main_hdr;
>   	struct register_set_hdr_v1 *register_set_hdr;
> -#if defined(CONFIG_KWB_SECURE)
>   	struct secure_hdr_v1 *secure_hdr = NULL;
> -#endif
>   	size_t headersz;
>   	uint8_t *image, *cur;
>   	int hasext = 0;
> @@ -1275,7 +1257,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   	if (main_hdr->blockid == IBR_HDR_PEX_ID)
>   		main_hdr->srcaddr = cpu_to_le32(0xFFFFFFFF);
>   
> -#if defined(CONFIG_KWB_SECURE)
>   	if (image_get_csk_index() >= 0) {
>   		/*
>   		 * only reserve the space here; we fill the header later since
> @@ -1286,7 +1267,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   		*next_ext = 1;
>   		next_ext = &secure_hdr->next;
>   	}
> -#endif
>   
>   	datai = 0;
>   	register_set_hdr = (struct register_set_hdr_v1 *)cur;
> @@ -1334,11 +1314,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   			return NULL;
>   	}
>   
> -#if defined(CONFIG_KWB_SECURE)
>   	if (secure_hdr && add_secure_header_v1(params, ptr, payloadsz,
>   					       headersz, image, secure_hdr))
>   		return NULL;
> -#endif
>   
>   	/* Calculate and set the header checksum */
>   	main_hdr->checksum = image_checksum8(main_hdr, headersz);
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

  parent reply	other threads:[~2021-07-21  9:37 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 12:20 [PATCH u-boot-mvebu v2 00/41] kwboot / kwbimage improvements reducing image size Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 01/41] tools: kwbimage: Fix compilation without CONFIG_SYS_U_BOOT_OFFS Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 02/41] tools: kwbimage: Simplify aligning and calculating checksum Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 03/41] tools: kwbimage: Align SPI and NAND images to 256 bytes Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 04/41] tools: kwbimage: Add constant for SDIO bootfrom Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 05/41] tools: kwbimage: Fix generation of SATA, SDIO and PCIe images Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 06/41] tools: kwbimage: Don't crash when binary file name does not contain '/' Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 07/41] tools: kwbimage: Fix check for v0 extended header checksum Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 08/41] tools: kwbimage: Validate extended headers of v1 images Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 09/41] tools: kwbimage: Validate data checksum " Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 10/41] tools: kwbimage: Print size of binary header in kwbimage_print_header() Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 11/41] tools: kwbimage: Cosmetic fix - remove redundant space character Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 12/41] tools: kwbimage: Use -a parameter (load address) for v1 images Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 13/41] tools: kwbimage: Change maximum number of arguments in binary header to 256 Marek Behún
2021-07-21  9:31   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 14/41] tools: kwbimage: Fix calculating size of binary header Marek Behún
2021-07-21  9:32   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 15/41] tools: kwbimage: Add support for more BINARY headers Marek Behún
2021-07-21  9:32   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 16/41] tools: kwbimage: Don't parse PAYLOAD keyword Marek Behún
2021-07-21  9:33   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 17/41] tools: kwbimage: Add support for DATA command also for v1 images Marek Behún
2021-07-21  9:35   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 18/41] tools: kwbimage: Add support for a new DATA_DELAY command Marek Behún
2021-07-21  9:35   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 19/41] tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X Marek Behún
2021-07-19 12:50   ` Marek Behún
2021-07-19 12:52     ` Stefan Roese
2021-07-21  9:36   ` Stefan Roese [this message]
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 20/41] tools: kwbimage: Mark all BootROM structures __packed Marek Behún
2021-07-21  9:38   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 21/41] tools: dumpimage: Fix crashing when trying to extract data from kwbimage Marek Behún
2021-07-21  9:38   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 22/41] tools: dumpimage: Show error message " Marek Behún
2021-07-21  9:39   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 23/41] tools: kwboot: Fix wrong parameter passed to read() Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 24/41] tools: kwboot: Fix restoring terminal Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 25/41] tools: kwboot: Print trailing newline after terminal is terminated Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 26/41] tools: kwboot: Cosmetic fix - add missing curly brackets Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 27/41] tools: kwboot: Check for v1 header size Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 28/41] tools: kwboot: Fix checking image header version Marek Behún
2021-07-21  9:40   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 29/41] arm: mvebu: Fix return_to_bootrom() Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 30/41] arm: mvebu: Mark return_to_bootrom() as a noreturn function Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 31/41] arm: mvebu: Implement return_to_bootrom() via U-Boot's SPL framework Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 32/41] arm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UART Marek Behún
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 33/41] SPL: Add support for specifying offset between header and image Marek Behún
2021-07-21 10:29   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 34/41] SPL: Add support for parsing board / BootROM specific image types Marek Behún
2021-07-22  8:50   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 35/41] arm: mvebu: Load main U-Boot binary in SPL code based on kwbimage header Marek Behún
2021-07-22  8:51   ` Stefan Roese
2021-07-19 12:20 ` [PATCH u-boot-mvebu v2 36/41] arm: mvebu: Remove legacy U-Boot header from kwbimage v1 files Marek Behún
2021-07-22  8:52   ` Stefan Roese
2021-07-19 12:21 ` [PATCH u-boot-mvebu v2 37/41] tools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytes Marek Behún
2021-07-22  8:52   ` Stefan Roese
2021-07-19 12:21 ` [PATCH u-boot-mvebu v2 38/41] arm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFS Marek Behún
2021-07-22  8:53   ` Stefan Roese
2021-07-19 12:21 ` [PATCH u-boot-mvebu v2 39/41] arm: mvebu: gdsys: Remove custom spl_board_init() Marek Behún
2021-07-22  8:55   ` Stefan Roese
2021-07-19 12:21 ` [PATCH u-boot-mvebu v2 40/41] kwbimage: Add support for extracting images via dumpimage tool Marek Behún
2021-07-22  8:55   ` Stefan Roese
2021-07-19 12:21 ` [PATCH u-boot-mvebu v2 41/41] kwbimage: Update help message about how to extract from an existing image Marek Behún
2021-07-22  8:56   ` Stefan Roese
2021-07-22  7:35 ` [PATCH u-boot-mvebu v2 00/41] kwboot / kwbimage improvements reducing image size Stefan Roese

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=bd7919e7-7577-977e-e392-0855d133ec43@denx.de \
    --to=sr@denx.de \
    --cc=baruch@tkos.co.il \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=dgilmore@redhat.com \
    --cc=dirk.eibach@gdsys.cc \
    --cc=jon@solid-run.com \
    --cc=judge.packham@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=mario.six@gdsys.cc \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.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.