All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] image-pre-load: Move macros/definitions to image.h
@ 2022-09-14 18:57 Steven Lawrance
  2022-09-14 18:57 ` [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info Steven Lawrance
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Steven Lawrance @ 2022-09-14 18:57 UTC (permalink / raw)
  To: u-boot; +Cc: Philippe Reynes

Putting these definitions in a header will allow signatures to be
validated independently of bootm.

Signed-off-by: Steven Lawrance <steven.lawrance@softathome.com>
---
 boot/image-pre-load.c | 43 -------------------------------------------
 include/image.h       | 43 +++++++++++++++++++++++++++++++++++++++++++
 tools/image-host.c    |  2 --
 3 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c
index 5ab9ae1874..01b60030fc 100644
--- a/boot/image-pre-load.c
+++ b/boot/image-pre-load.c
@@ -11,49 +11,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #include <u-boot/sha256.h>
 
-#define IMAGE_PRE_LOAD_SIG_MAGIC		0x55425348
-#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC		0
-#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN	4
-#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG		8
-
-#define IMAGE_PRE_LOAD_PATH			"/image/pre-load/sig"
-#define IMAGE_PRE_LOAD_PROP_ALGO_NAME		"algo-name"
-#define IMAGE_PRE_LOAD_PROP_PADDING_NAME	"padding-name"
-#define IMAGE_PRE_LOAD_PROP_SIG_SIZE		"signature-size"
-#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY		"public-key"
-#define IMAGE_PRE_LOAD_PROP_MANDATORY		"mandatory"
-
-/*
- * Information in the device-tree about the signature in the header
- */
-struct image_sig_info {
-	char *algo_name;	/* Name of the algo (eg: sha256,rsa2048) */
-	char *padding_name;	/* Name of the padding */
-	u8 *key;		/* Public signature key */
-	int key_len;		/* Length of the public key */
-	u32 sig_size;		/* size of the signature (in the header) */
-	int mandatory;		/* Set if the signature is mandatory */
-
-	struct image_sign_info sig_info; /* Signature info */
-};
-
-/*
- * Header of the signature header
- */
-struct sig_header_s {
-	u32 magic;
-	u32 version;
-	u32 header_size;
-	u32 image_size;
-	u32 offset_img_sig;
-	u32 flags;
-	u32 reserved0;
-	u32 reserved1;
-	u8 sha256_img_sig[SHA256_SUM_LEN];
-};
-
-#define SIG_HEADER_LEN			(sizeof(struct sig_header_s))
-
 /*
  * Offset of the image
  *
diff --git a/include/image.h b/include/image.h
index d7d756c645..10fe5115e7 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1411,6 +1411,49 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name);
  */
 struct padding_algo *image_get_padding_algo(const char *name);
 
+#define IMAGE_PRE_LOAD_SIG_MAGIC		0x55425348
+#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC		0
+#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN	4
+#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG		8
+
+#define IMAGE_PRE_LOAD_PATH			"/image/pre-load/sig"
+#define IMAGE_PRE_LOAD_PROP_ALGO_NAME		"algo-name"
+#define IMAGE_PRE_LOAD_PROP_PADDING_NAME	"padding-name"
+#define IMAGE_PRE_LOAD_PROP_SIG_SIZE		"signature-size"
+#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY		"public-key"
+#define IMAGE_PRE_LOAD_PROP_MANDATORY		"mandatory"
+
+/*
+ * Information in the device-tree about the signature in the header
+ */
+struct image_sig_info {
+	char *algo_name;	/* Name of the algo (eg: sha256,rsa2048) */
+	char *padding_name;	/* Name of the padding */
+	uint8_t *key;		/* Public signature key */
+	int key_len;		/* Length of the public key */
+	uint32_t sig_size;		/* size of the signature (in the header) */
+	int mandatory;		/* Set if the signature is mandatory */
+
+	struct image_sign_info sig_info; /* Signature info */
+};
+
+/*
+ * Header of the signature header
+ */
+struct sig_header_s {
+	uint32_t magic;
+	uint32_t version;
+	uint32_t header_size;
+	uint32_t image_size;
+	uint32_t offset_img_sig;
+	uint32_t flags;
+	uint32_t reserved0;
+	uint32_t reserved1;
+	uint8_t sha256_img_sig[SHA256_SUM_LEN];
+};
+
+#define SIG_HEADER_LEN			(sizeof(struct sig_header_s))
+
 /**
  * image_pre_load() - Manage pre load header
  *
diff --git a/tools/image-host.c b/tools/image-host.c
index 698adfb3e1..0bf18df50e 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -17,8 +17,6 @@
 #include <openssl/pem.h>
 #include <openssl/evp.h>
 
-#define IMAGE_PRE_LOAD_PATH                             "/image/pre-load/sig"
-
 /**
  * fit_set_hash_value - set hash value in requested has node
  * @fit: pointer to the FIT format image header
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info
  2022-09-14 18:57 [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Steven Lawrance
@ 2022-09-14 18:57 ` Steven Lawrance
  2022-09-16  1:30   ` Simon Glass
  2022-10-11 21:36   ` Tom Rini
  2022-09-16  1:30 ` [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Simon Glass
  2022-10-11 21:36 ` Tom Rini
  2 siblings, 2 replies; 6+ messages in thread
From: Steven Lawrance @ 2022-09-14 18:57 UTC (permalink / raw)
  To: u-boot; +Cc: Philippe Reynes

Setting an alternative signature info node in "pre_load_sig_info_path"
allows verification of an image using the bootm pre-load mechanism with
a different key, e.g.: setenv pre_load_sig_info_path "/alt/sig" ; bootm
preload [addr]

Signed-off-by: Steven Lawrance <steven.lawrance@softathome.com>
---
 boot/image-pre-load.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c
index 01b60030fc..b504ab42a5 100644
--- a/boot/image-pre-load.c
+++ b/boot/image-pre-load.c
@@ -33,6 +33,7 @@ static int image_pre_load_sig_setup(struct image_sig_info *info)
 	const u32 *sig_size;
 	int key_len;
 	int node, ret = 0;
+	char *sig_info_path = NULL;
 
 	if (!info) {
 		log_err("ERROR: info is NULL for image pre-load sig check\n");
@@ -42,7 +43,11 @@ static int image_pre_load_sig_setup(struct image_sig_info *info)
 
 	memset(info, 0, sizeof(*info));
 
-	node = fdt_path_offset(gd_fdt_blob(), IMAGE_PRE_LOAD_PATH);
+	sig_info_path = env_get("pre_load_sig_info_path");
+	if (!sig_info_path)
+		sig_info_path = IMAGE_PRE_LOAD_PATH;
+
+	node = fdt_path_offset(gd_fdt_blob(), sig_info_path);
 	if (node < 0) {
 		log_info("INFO: no info for image pre-load sig check\n");
 		ret = 1;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] image-pre-load: Move macros/definitions to image.h
  2022-09-14 18:57 [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Steven Lawrance
  2022-09-14 18:57 ` [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info Steven Lawrance
@ 2022-09-16  1:30 ` Simon Glass
  2022-10-11 21:36 ` Tom Rini
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2022-09-16  1:30 UTC (permalink / raw)
  To: Steven Lawrance; +Cc: U-Boot Mailing List, Philippe Reynes

On Wed, 14 Sept 2022 at 12:58, Steven Lawrance
<steven.lawrance@softathome.com> wrote:
>
> Putting these definitions in a header will allow signatures to be
> validated independently of bootm.
>
> Signed-off-by: Steven Lawrance <steven.lawrance@softathome.com>
> ---
>  boot/image-pre-load.c | 43 -------------------------------------------
>  include/image.h       | 43 +++++++++++++++++++++++++++++++++++++++++++
>  tools/image-host.c    |  2 --
>  3 files changed, 43 insertions(+), 45 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info
  2022-09-14 18:57 ` [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info Steven Lawrance
@ 2022-09-16  1:30   ` Simon Glass
  2022-10-11 21:36   ` Tom Rini
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Glass @ 2022-09-16  1:30 UTC (permalink / raw)
  To: Steven Lawrance; +Cc: U-Boot Mailing List, Philippe Reynes

On Wed, 14 Sept 2022 at 12:57, Steven Lawrance
<steven.lawrance@softathome.com> wrote:
>
> Setting an alternative signature info node in "pre_load_sig_info_path"
> allows verification of an image using the bootm pre-load mechanism with
> a different key, e.g.: setenv pre_load_sig_info_path "/alt/sig" ; bootm
> preload [addr]
>
> Signed-off-by: Steven Lawrance <steven.lawrance@softathome.com>
> ---
>  boot/image-pre-load.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] image-pre-load: Move macros/definitions to image.h
  2022-09-14 18:57 [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Steven Lawrance
  2022-09-14 18:57 ` [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info Steven Lawrance
  2022-09-16  1:30 ` [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Simon Glass
@ 2022-10-11 21:36 ` Tom Rini
  2 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2022-10-11 21:36 UTC (permalink / raw)
  To: Steven Lawrance; +Cc: u-boot, Philippe Reynes

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

On Wed, Sep 14, 2022 at 08:57:27PM +0200, Steven Lawrance wrote:

> Putting these definitions in a header will allow signatures to be
> validated independently of bootm.
> 
> Signed-off-by: Steven Lawrance <steven.lawrance@softathome.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info
  2022-09-14 18:57 ` [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info Steven Lawrance
  2022-09-16  1:30   ` Simon Glass
@ 2022-10-11 21:36   ` Tom Rini
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Rini @ 2022-10-11 21:36 UTC (permalink / raw)
  To: Steven Lawrance; +Cc: u-boot, Philippe Reynes

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

On Wed, Sep 14, 2022 at 08:57:28PM +0200, Steven Lawrance wrote:

> Setting an alternative signature info node in "pre_load_sig_info_path"
> allows verification of an image using the bootm pre-load mechanism with
> a different key, e.g.: setenv pre_load_sig_info_path "/alt/sig" ; bootm
> preload [addr]
> 
> Signed-off-by: Steven Lawrance <steven.lawrance@softathome.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-11 21:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 18:57 [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Steven Lawrance
2022-09-14 18:57 ` [PATCH 2/2] boot: image-pre-load: Check environment for location of signature info Steven Lawrance
2022-09-16  1:30   ` Simon Glass
2022-10-11 21:36   ` Tom Rini
2022-09-16  1:30 ` [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Simon Glass
2022-10-11 21:36 ` Tom Rini

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.