diff mbox series

[1/2] image-pre-load: Move macros/definitions to image.h

Message ID 20220914185728.393277-1-steven.lawrance@softathome.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [1/2] image-pre-load: Move macros/definitions to image.h | expand

Commit Message

Steven Lawrance Sept. 14, 2022, 6:57 p.m. UTC
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(-)

Comments

Simon Glass Sept. 16, 2022, 1:30 a.m. UTC | #1
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>
Tom Rini Oct. 11, 2022, 9:36 p.m. UTC | #2
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!
diff mbox series

Patch

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