RFC: add fdt_add_pubkey tool
cover RFC: add fdt_add_pubkey tool
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds fdt_add_pubkey useful as is), but I thought I might as well send it out for early comments.
Roman Kopytin (2):
tools: add fdt_add_pubkey
test_vboot.py: include test of fdt_add_pubkey tool
test/py/tests/test_vboot.py | 8 +++ tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 +++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100755 tools/fdt_add_pubkey.c
Signature · 1 line
2.25.1
PATCH 1/2 tools: add fdt_add_pubkey
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.c
tools/.gitignore +1 -0
@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_sign
tools/Makefile +3 -0
@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o hostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign +hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include
@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)
@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage) hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
tools/fdt_add_pubkey.c new file +97 -0
97 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 1/2] tools: add fdt_add_pubkey
Hi Roman,
Quoted 78 lines · Roman Kopytin
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.ctools/.gitignore +1
-0@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_signtools/Makefile +3
-0@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o hostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign +hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage) hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspltools/fdt_add_pubkey.c new file +5
-0@@ -0,0 +1,97 @@ +#include <image.h> +#include "fit_common.h" + +static const char *cmdname; +
tools/fdt_add_pubkey.c line 15
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+static const char *algo_name ="sha1,rsa2048" ;/* -a <algo> */ +static const char *keydir ="." ;/* -k <keydir> */ +static const char *keyname ="key" ;/* -n <keyname> */ +static const char *require_keys;/* -r <conf|image> */ +static const char *keydest;/* argv[n] */ + +static void usage (const char *msg) +{ +fprintf (stderr,"Error: %s\n" , msg); + fprintf(stderr, "Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n",
Some of these are not optional so should not have [] around them.
Quoted 37 lines
tools/fdt_add_pubkey.c new file +37
-0+ cmdname); +exit (EXIT_FAILURE ); +} + +static void process_args (int argc,char *argv[]) +{ +int opt; + +while ((opt =getopt (argc, argv,"a:k:n:r:" )) !=-1 ) { +switch (opt) { +case 'k' : + keydir = optarg; +break ; +case 'a' : + algo_name = optarg; +break ; +case 'n' : + keyname = optarg; +break ; +case 'r' : + require_keys = optarg; +break ; +default : +usage ("Invalid option" ); + } + } +/* The last parameter is expected to be the .dtb to add the public key to */ +if (optind < argc) + keydest = argv[optind]; + +if (!keydest) +usage ("Missing dtb file to update" ); +} + +int main (int argc,char *argv[]) +{ +struct image_sign_info info;
tools/fdt_add_pubkey.c line 62
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+int destfd, ret; +void *dest_blob =NULL ; +struct stat dest_sbuf; +size_t size_inc =0 ; + + cmdname = argv[0 ]; + +process_args (argc, argv); + +memset (&info,0 ,sizeof (info));
'\0'
tools/fdt_add_pubkey.c line 72
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+ + info.keydir = keydir; + info.keyname = keyname; + info.name = algo_name; + info.require_keys = require_keys; + info.crypto =image_get_crypto_algo (algo_name); +if (!info.crypto) { +fprintf (stderr,"Unsupported signature algorithm '%s'\n" , algo_name); +exit (EXIT_FAILURE ); + }
Can you please put the block above and the loop below into a separate function that returns an error code? Then you can print that out at the bottom, with a single EXIT_FAILURE.
tools/fdt_add_pubkey.c line 85
Quoted 13 lines
tools/fdt_add_pubkey.c new file +13
-0+ +while (1 ) { + destfd =mmap_fdt (cmdname, keydest, size_inc, &dest_blob, &dest_sbuf, false, false); +if (destfd <0 ) +exit (EXIT_FAILURE ); + + ret = info.crypto->add_verify_data (&info, dest_blob); + +munmap (dest_blob, dest_sbuf.st_size); +close (destfd); +if (!ret || ret != -ENOSPC ) +break ; +fprintf (stderr,".dtb too small, increasing size by 1024 bytes\n" );
debug() I think. This isn't very important. BTW I found that 512 bytes is enough, if you want to use that, but 1024 is fine too.
Quoted 13 lines
tools/fdt_add_pubkey.c new file +12
-1+ size_inc =1024 ; + } + +if (ret) { +fprintf (stderr,"%s: Cannot add public key to FIT blob: %s\n" , + cmdname,strerror (-ret)); +exit (EXIT_FAILURE ); + } + +exit (EXIT_SUCCESS ); +} + --
Quoted 2 lines
2.25.1
Regards,
Simon
RE: [PATCH 1/2] tools: add fdt_add_pubkey
Hi, Simon
I have question about:
Some of these are not optional so should not have [] around them.
As I see we have defaults for:
static const char *algo_name = "sha1,rsa2048"; /* -a <algo> */ static const char *keydir = "."; /* -k <keydir> */ static const char *keyname = "key"; /* -n <keyname> */
It means that we can skip it in command line. Should I need to remove [] from code for those parameters?
-----Original Message-----
From: Simon Glass <[email protected]>
Sent: Wednesday, November 10, 2021 3:58 AM
To: Roman Kopytin <[email protected]>
Cc: [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 1/2] tools: add fdt_add_pubkey
Hi Roman,
Quoted 79 lines · Roman Kopytin
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.ctools/.gitignore index renamed from tools/.gitignore +0
-0
a88453f64d..f312b760e4100644tools/.gitignore +1
-0@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_signtools/Makefile index renamed from tools/Makefile +0
-0
4a86321f64..44f25dda18100644tools/Makefile +0
-0@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o
lib/crc32.ohostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) +=
fit_infofit_check_signtools/Makefile +2
-0+hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info :=$(HOSTLDLIBS_mkimage)
HOSTLDLIBS_fit_check_sign:= $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage)hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl diff --git
a/tools/fdt_add_pubkey.cb/tools/fdt_add_pubkey.cnew file mode 100755 index 0000000000..9306ecedd1tools/fdt_add_pubkey.c new file +5
-0@@ -0,0 +1,97 @@ +#include <image.h> +#include "fit_common.h" + +static const char *cmdname; +
tools/fdt_add_pubkey.c line 15
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+static const char *algo_name ="sha1,rsa2048" ;/* -a <algo> */ static +const char *keydir ="." ;/* -k <keydir> */ static const char +*keyname ="key" ;/* -n <keyname> */ static const char *require_keys; +/* -r <conf|image> */ static const char *keydest;/* argv[n] */ + +static void usage(const char *msg) +{ + fprintf(stderr, "Error: %s\n", msg); + fprintf(stderr, "Usage: %s [-a <algo>] [-k <keydir>] [-n +<keyname>] [-r <conf|image>] <fdt blob>\n",
Some of these are not optional so should not have [] around them.
Quoted 35 lines
tools/fdt_add_pubkey.c new file +35
-0+ cmdname); +exit (EXIT_FAILURE ); +} + +static void process_args (int argc,char *argv[]) { +int opt; + +while ((opt =getopt (argc, argv,"a:k:n:r:" )) !=-1 ) { +switch (opt) { +case 'k' : + keydir = optarg; +break ; +case 'a' : + algo_name = optarg; +break ; +case 'n' : + keyname = optarg; +break ; +case 'r' : + require_keys = optarg; +break ; +default : +usage ("Invalid option" ); + } + } +/* The last parameter is expected to be the .dtb to add the public key to */ +if (optind < argc) + keydest = argv[optind]; + +if (!keydest) +usage ("Missing dtb file to update" ); } + +int main (int argc,char *argv[]) +{ +struct image_sign_info info;
tools/fdt_add_pubkey.c line 62
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+int destfd, ret; +void *dest_blob =NULL ; +struct stat dest_sbuf; +size_t size_inc =0 ; + + cmdname = argv[0 ]; + +process_args (argc, argv); + +memset (&info,0 ,sizeof (info));
'\0'
tools/fdt_add_pubkey.c line 72
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+ + info.keydir = keydir; + info.keyname = keyname; + info.name = algo_name; + info.require_keys = require_keys; + info.crypto =image_get_crypto_algo (algo_name); +if (!info.crypto) { +fprintf (stderr,"Unsupported signature algorithm '%s'\n" , algo_name); +exit (EXIT_FAILURE ); + }
Can you please put the block above and the loop below into a separate function that returns an error code? Then you can print that out at the bottom, with a single EXIT_FAILURE.
Quoted 4 lines
tools/fdt_add_pubkey.c new file +4
-0+ +while (1 ) { + destfd =mmap_fdt (cmdname, keydest, size_inc, &dest_blob, &dest_sbuf, false, false); +if (destfd <0 )
tools/fdt_add_pubkey.c
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+exit (EXIT_FAILURE ); + + ret = info.crypto->add_verify_data (&info, dest_blob); + +munmap (dest_blob, dest_sbuf.st_size); +close (destfd); +if (!ret || ret != -ENOSPC ) +break ; +fprintf (stderr,".dtb too small, increasing size by + 1024 bytes\n");
debug() I think. This isn't very important. BTW I found that 512 bytes is enough, if you want to use that, but 1024 is fine too.
Quoted 13 lines
tools/fdt_add_pubkey.c new file +12
-1+ size_inc =1024 ; + } + +if (ret) { +fprintf (stderr,"%s: Cannot add public key to FIT blob: %s\n" , + cmdname,strerror (-ret)); +exit (EXIT_FAILURE ); + } + +exit (EXIT_SUCCESS ); +} + --
Quoted 2 lines
2.25.1
Regards,
Simon
Re: [PATCH 1/2] tools: add fdt_add_pubkey
[no top-posting please]
Quoted 11 lines · Roman Kopytin
Hi, Simon
I have question about:
Some of these are not optional so should not have [] around them.As I see we have defaults for:
static const char*algo_name= "sha1,rsa2048"; /* -a <algo> */ static const char *keydir = "."; /* -k <keydir> */ static const char *keyname = "key"; /* -n <keyname> */It means that we can skip it in command line. Should I need to remove [] from code for those parameters?
Those have defaults, and if you place a rsa2048 key in ./key.key, fdt_add_pubkey will be happy.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Re: [PATCH 1/2] tools: add fdt_add_pubkey
In reply to Roman KopytinQuoted 160 lines · Roman Kopytin
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.ctools/.gitignore +1
-0@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_signtools/Makefile +3
-0@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o hostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign +hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage) hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspltools/fdt_add_pubkey.c new file +87
-0@@ -0,0 +1,97 @@ +#include <image.h> +#include "fit_common.h" + +static const char *cmdname; + +static const char *algo_name ="sha1,rsa2048" ;/* -a <algo> */ +static const char *keydir ="." ;/* -k <keydir> */ +static const char *keyname ="key" ;/* -n <keyname> */ +static const char *require_keys;/* -r <conf|image> */ +static const char *keydest;/* argv[n] */ + +static void usage (const char *msg) +{ +fprintf (stderr,"Error: %s\n" , msg); +fprintf (stderr,"Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n" , + cmdname); +exit (EXIT_FAILURE ); +} + +static void process_args (int argc,char *argv[]) +{ +int opt; + +while ((opt =getopt (argc, argv,"a:k:n:r:" )) !=-1 ) { +switch (opt) { +case 'k' : + keydir = optarg; +break ; +case 'a' : + algo_name = optarg; +break ; +case 'n' : + keyname = optarg; +break ; +case 'r' : + require_keys = optarg; +break ; +default : +usage ("Invalid option" ); + } + } +/* The last parameter is expected to be the .dtb to add the public key to */ +if (optind < argc) + keydest = argv[optind]; + +if (!keydest) +usage ("Missing dtb file to update" ); +} + +int main (int argc,char *argv[]) +{ +struct image_sign_info info; +int destfd, ret; +void *dest_blob =NULL ; +struct stat dest_sbuf; +size_t size_inc =0 ; + + cmdname = argv[0 ]; + +process_args (argc, argv); + +memset (&info,0 ,sizeof (info)); + + info.keydir = keydir; + info.keyname = keyname; + info.name = algo_name; + info.require_keys = require_keys; + info.crypto =image_get_crypto_algo (algo_name); +if (!info.crypto) { +fprintf (stderr,"Unsupported signature algorithm '%s'\n" , algo_name); +exit (EXIT_FAILURE ); + } + +while (1 ) { + destfd =mmap_fdt (cmdname, keydest, size_inc, &dest_blob, &dest_sbuf, false, false); +if (destfd <0 ) +exit (EXIT_FAILURE ); + + ret = info.crypto->add_verify_data (&info, dest_blob); + +munmap (dest_blob, dest_sbuf.st_size); +close (destfd); +if (!ret || ret != -ENOSPC ) +break ; +fprintf (stderr,".dtb too small, increasing size by 1024 bytes\n" ); + size_inc =1024 ; + }
tools/fdt_add_pubkey.c line 97
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+ +if (ret) { +fprintf (stderr,"%s: Cannot add public key to FIT blob: %s\n" , + cmdname,strerror (-ret)); +exit (EXIT_FAILURE ); + } + +exit (EXIT_SUCCESS ); +} +
git says: "new blank line at EOF."
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Re: [PATCH 1/2] tools: add fdt_add_pubkey
In reply to Roman KopytinQuoted 78 lines · Roman Kopytin
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.ctools/.gitignore +1
-0@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_signtools/Makefile +3
-0@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o hostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign +hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage) hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspltools/fdt_add_pubkey.c new file +6
-0@@ -0,0 +1,97 @@ +#include <image.h> +#include "fit_common.h" + +static const char *cmdname; + +static const char *algo_name ="sha1,rsa2048" ;/* -a <algo> */
tools/fdt_add_pubkey.c line 16
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+static const char *keydir ="." ;/* -k <keydir> */ +static const char *keyname ="key" ;/* -n <keyname> */ +static const char *require_keys;/* -r <conf|image> */ +static const char *keydest;/* argv[n] */ + +static void usage (const char *msg) +{ +fprintf (stderr,"Error: %s\n" , msg); +fprintf (stderr,"Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n" , + cmdname);
The tool should support --help and document the default of these optional parameters that way.
Is there an easy way to derive algo from the key?
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
RE: [PATCH 1/2] tools: add fdt_add_pubkey
Could you please provide good example with needed style for helper? In tools I saw a lot of programs w/o help.
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Wednesday, November 10, 2021 10:39 AM
To: Roman Kopytin <[email protected]>; [email protected]
Cc: Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 1/2] tools: add fdt_add_pubkey
Quoted 78 lines · Roman Kopytin
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.ctools/.gitignore index renamed from tools/.gitignore +0
-0
a88453f64d..f312b760e4100644tools/.gitignore +1
-0@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_signtools/Makefile index renamed from tools/Makefile +0
-0
4a86321f64..44f25dda18100644tools/Makefile +0
-0@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o
lib/crc32.ohostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) +=
fit_infofit_check_signtools/Makefile +2
-0+hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info :=$(HOSTLDLIBS_mkimage)
HOSTLDLIBS_fit_check_sign:= $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage)hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl diff --git
a/tools/fdt_add_pubkey.cb/tools/fdt_add_pubkey.cnew file mode 100755 index 0000000000..9306ecedd1tools/fdt_add_pubkey.c new file +5
-0@@ -0,0 +1,97 @@ +#include <image.h> +#include "fit_common.h" + +static const char *cmdname; +
tools/fdt_add_pubkey.c line 15
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+static const char *algo_name ="sha1,rsa2048" ;/* -a <algo> */ static +const char *keydir ="." ;/* -k <keydir> */ static const char +*keyname ="key" ;/* -n <keyname> */ static const char *require_keys; +/* -r <conf|image> */ static const char *keydest;/* argv[n] */ + +static void usage (const char *msg) +{ +fprintf (stderr,"Error: %s\n" , msg); +fprintf (stderr,"Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n" , + cmdname);
The tool should support --help and document the default of these optional parameters that way.
Is there an easy way to derive algo from the key?
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Re: [PATCH 1/2] tools: add fdt_add_pubkey
Quoted 3 lines · Roman Kopytin
Could you please provide good example with needed style for helper? In tools I saw a lot of programs w/o help.
Have a look at binman to see this full-blown - not a completely fair comparison as it benefits from Python argparse.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
RE: [PATCH 1/2] tools: add fdt_add_pubkey
Thanks, I found example in fdtgrep.
What do you think about function like:
static void print_usage(const char *msg)
{
if (msg != NULL)
fprintf(stderr, "Error: %s\n", msg);
fprintf(stderr, "Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n"
"Options:\n"
"\t-a <algo> Cryptographic algorithm. Optional parameter, default: sha1,rsa2048\n"
"\t-k <keydir> Directory with public key. Optional parameter, default: .\n"
"\t-n <keyname> Public key name. Optional parameter, default: key\n"
"\t-r <conf|image> Required: If present this indicates that the key must be verified for the image / configuration to be considered valid\n"
"\t<fdt blob> FDT blob file for adding of the public key. Required parameter.\n",
cmdname);
exit(EXIT_FAILURE);
}Is it ok?
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Wednesday, November 10, 2021 10:22 PM
To: Roman Kopytin <[email protected]>; [email protected]
Cc: Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 1/2] tools: add fdt_add_pubkey
Quoted 3 lines · Roman Kopytin
Could you please provide good example with needed style for helper? In tools I saw a lot of programs w/o help.
Have a look at binman to see this full-blown - not a completely fair comparison as it benefits from Python argparse.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Re: [PATCH 1/2] tools: add fdt_add_pubkey
Quoted 4 lines · Roman Kopytin
Thanks, I found example in fdtgrep.
What do you think about function like:static void
print_usage(const char *msg)
Quoted 10 lines
{
if (msg != NULL)
fprintf(stderr, "Error: %s\n", msg);
fprintf(stderr, "Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n"
"Options:\n"
"\t-a <algo> Cryptographic algorithm. Optional parameter, default: sha1,rsa2048\n"
"\t-k <keydir> Directory with public key. Optional parameter, default: .\n"
"\t-n <keyname> Public key name. Optional parameter, default: key\n"
"\t-r <conf|image> Required: If present this indicates that the key must be verified for the image / configuration to be considered valid\n"Maybe reorder to "configuration / image" (or reorder to "<image|conf>").
Quoted 7 lines
"\t<fdt blob> FDT blob file for adding of the public key. Required parameter.\n", cmdname); exit(EXIT_FAILURE); }Is it ok?
Yes, looks good to me.
I'm still looking for a way to overcome -a, though...
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Re: [PATCH 1/2] tools: add fdt_add_pubkey
In reply to Roman KopytinQuoted 160 lines · Roman Kopytin
Having to use the -K option to mkimage to populate U-Boot's .dtb with the public key while signing the kernel FIT image is often a little awkward. In particular, when using a meta-build system such as bitbake/Yocto, having the tasks of the kernel and U-Boot recipes intertwined, modifying deployed artifacts and rebuilding U-Boot with an updated .dtb is quite cumbersome. Also, in some scenarios one may wish to build U-Boot complete with the public key(s) embedded in the .dtb without the corresponding private keys being present on the same build host.
So this adds a simple tool that allows one to disentangle the kernel and U-Boot builds, by simply copy-pasting just enough of the mkimage code to allow one to add a public key to a .dtb. When using mkimage, some of the information is taken from the .its used to build the kernel (algorithm and key name), so that of course needs to be supplied on the command line.
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- tools/.gitignore | 1 + tools/Makefile | 3 ++ tools/fdt_add_pubkey.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 tools/fdt_add_pubkey.ctools/.gitignore +1
-0@@ -6,6 +6,7 @@ /dumpimage /easylogo/easylogo /envcrc +/fdt_add_pubkey /fdtgrep /file2include /fit_check_signtools/Makefile +3
-0@@ -73,6 +73,7 @@ mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o hostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign +hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fdt_add_pubkey hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include@@ -153,6 +154,7 @@ dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +fdt_add_pubkey-objs := $(dumpimage-mkimage-objs) fdt_add_pubkey.o file2include-objs := file2include.o ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)@@ -190,6 +192,7 @@ HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\" HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage) HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage) +HOSTLDLIBS_fdt_add_pubkey := $(HOSTLDLIBS_mkimage) hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspltools/fdt_add_pubkey.c new file +87
-0@@ -0,0 +1,97 @@ +#include <image.h> +#include "fit_common.h" + +static const char *cmdname; + +static const char *algo_name ="sha1,rsa2048" ;/* -a <algo> */ +static const char *keydir ="." ;/* -k <keydir> */ +static const char *keyname ="key" ;/* -n <keyname> */ +static const char *require_keys;/* -r <conf|image> */ +static const char *keydest;/* argv[n] */ + +static void usage (const char *msg) +{ +fprintf (stderr,"Error: %s\n" , msg); +fprintf (stderr,"Usage: %s [-a <algo>] [-k <keydir>] [-n <keyname>] [-r <conf|image>] <fdt blob>\n" , + cmdname); +exit (EXIT_FAILURE ); +} + +static void process_args (int argc,char *argv[]) +{ +int opt; + +while ((opt =getopt (argc, argv,"a:k:n:r:" )) !=-1 ) { +switch (opt) { +case 'k' : + keydir = optarg; +break ; +case 'a' : + algo_name = optarg; +break ; +case 'n' : + keyname = optarg; +break ; +case 'r' : + require_keys = optarg; +break ; +default : +usage ("Invalid option" ); + } + } +/* The last parameter is expected to be the .dtb to add the public key to */ +if (optind < argc) + keydest = argv[optind]; + +if (!keydest) +usage ("Missing dtb file to update" ); +} + +int main (int argc,char *argv[]) +{ +struct image_sign_info info; +int destfd, ret; +void *dest_blob =NULL ; +struct stat dest_sbuf; +size_t size_inc =0 ; + + cmdname = argv[0 ]; + +process_args (argc, argv); + +memset (&info,0 ,sizeof (info)); + + info.keydir = keydir; + info.keyname = keyname; + info.name = algo_name; + info.require_keys = require_keys; + info.crypto =image_get_crypto_algo (algo_name); +if (!info.crypto) { +fprintf (stderr,"Unsupported signature algorithm '%s'\n" , algo_name); +exit (EXIT_FAILURE ); + } + +while (1 ) { + destfd =mmap_fdt (cmdname, keydest, size_inc, &dest_blob, &dest_sbuf, false, false); +if (destfd <0 ) +exit (EXIT_FAILURE ); + + ret = info.crypto->add_verify_data (&info, dest_blob); + +munmap (dest_blob, dest_sbuf.st_size); +close (destfd); +if (!ret || ret != -ENOSPC ) +break ; +fprintf (stderr,".dtb too small, increasing size by 1024 bytes\n" ); + size_inc =1024 ; + }
tools/fdt_add_pubkey.c line 97
Quoted 10 lines
tools/fdt_add_pubkey.c new file +10
-0+ +if (ret) { +fprintf (stderr,"%s: Cannot add public key to FIT blob: %s\n" , + cmdname,strerror (-ret)); +exit (EXIT_FAILURE ); + } + +exit (EXIT_SUCCESS ); +} +
I'm playing with this diff on top in order to support embedding into SPL control FDTs:
tools/fdt_add_pubkey.c +31 -10
@@ -50,10 +50,11 @@ static void process_args(int argc, char *argv[])int main (int argc,char *argv[]) {struct image_sign_info info; -int destfd, ret; +int signode, keynode, ret;void *dest_blob =NULL ;struct stat dest_sbuf;size_t size_inc =0 ; +int destfd =-1 ; cmdname = argv[0 ];
@@ -71,20 +72,41 @@ int main(int argc, char *argv[])exit (EXIT_FAILURE ); } -while (1 ) { +do { +if (destfd >=0 ) { +munmap (dest_blob, dest_sbuf.st_size); +close (destfd); + +fprintf (stderr,".dtb too small, increasing size by 1024 bytes\n" ); + size_inc =1024 ; + } + destfd =mmap_fdt (cmdname, keydest, size_inc, &dest_blob, &dest_sbuf, false, false);if (destfd <0 )exit (EXIT_FAILURE ); ret = info.crypto->add_verify_data (&info, dest_blob); - -munmap (dest_blob, dest_sbuf.st_size); -close (destfd); -if (!ret || ret != -ENOSPC ) +if (ret == -ENOSPC ) +continue ; +else if (ret)break ; -fprintf (stderr,".dtb too small, increasing size by 1024 bytes\n" ); - size_inc =1024 ; - } + + signode =fdt_path_offset (dest_blob,"/signature" ); +if (signode <0 ) { +fprintf (stderr,"%s: /signature node not found?!\n" , + cmdname); +exit (EXIT_FAILURE ); + } + + keynode =fdt_first_subnode (dest_blob, signode); +if (keynode <0 ) { +fprintf (stderr,"%s: /signature/<key> node not found?!\n" , + cmdname); +exit (EXIT_FAILURE ); + } + + ret =fdt_appendprop (dest_blob, keynode,"u-boot,dm-spl" ,NULL ,0 ); + }while (ret == -ENOSPC );if (ret) { fprintf(stderr, "%s: Cannot add public key to FIT blob: %s\n",
@@ -94,4 +116,3 @@ int main(int argc, char *argv[])exit (EXIT_SUCCESS ); } -
This is step one. Step two is a diff - actually still rather a hack due to some hard-coded options - to use the tool during dtb builds:
common/Kconfig.boot +8 -0
@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMAT
scripts/Makefile.lib +4 -1
@@ -326,9 +326,12 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ -d $(depfile).dtc.tmp $(dtc-tmp) || \ (echo "Check $(shell pwd)/$(pre-tmp) for errors" && false) \ ; \ + $(foreach key,$(subst $(quote),,$(CONFIG_FIT_SIGNATURE_PUB_KEYS)), \ + tools/fdt_add_pubkey -a sha256,rsa4096 -k $(shell dirname $(key)) \ + -n $(subst .key,,$(shell basename $(key))) -r conf $@;) \ sed "s:$(pre-tmp):$(<):" $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) -$(obj)/%.dtb: $(src)/%.dts FORCE +$(obj)/%.dtb: $(src)/%.dts tools/fdt_add_pubkey FORCE $(call if_changed_dep,dtc) pre-tmp = $(subst $(comma),_,$(dot-target).pre.tmp)
This permits the workflow:
- make flash.bin (via binman)
- mkimage -r -F [email protected] (an embedded FIT in flash.bin)
- binman replace -i flash.bin -f [email protected] fit@0x280000 (the latter on in theory, that command is broken ATM)
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
PATCH 2/2 test_vboot.py: include test of fdt_add_pubkey tool
In reply to Roman Kopytin--- test/py/tests/test_vboot.py | 8 ++++++++ 1 file changed, 8 insertions(+)
test/py/tests/test_vboot.py +8 -0
@@ -230,6 +230,13 @@ def test_vboot(u_boot_console, sha_algo, padding, sign_options, required, cons.log.action('%s: Check signed config on the host' % sha_algo) util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb]) + + # Create a fresh .dtb without the public keys + dtc('sandbox-u-boot.dts') + # Then add the dev key via the fdt_add_pubkey tool + util.run_and_log(cons, [fdt_add_pubkey, '-a', '%s,rsa2048' % sha_algo, + '-k', tmpdir, '-n', 'dev', '-r', 'conf', dtb]) + util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb]) if full_test: # Make sure that U-Boot checks that the config is in the list of
@@ -370,6 +377,7 @@ def test_vboot(u_boot_console, sha_algo, padding, sign_options, required, fit = '%stest.fit' % tmpdir mkimage = cons.config.build_dir + '/tools/mkimage' fit_check_sign = cons.config.build_dir + '/tools/fit_check_sign' + fdt_add_pubkey = cons.config.build_dir + '/tools/fdt_add_pubkey' dtc_args = '-I dts -O dtb -i %s' % tmpdir dtb = '%ssandbox-u-boot.dtb' % tmpdir sig_node = '/configurations/conf-1/signature'
Signature · 1 line
2.25.1
Re: [PATCH 2/2] test_vboot.py: include test of fdt_add_pubkey tool
Hi Roman,
Quoted 1 line · Roman Kopytin
<please add a commit message here>
Quoted 11 lines
Signed-off-by Roman Kopytin <[email protected]>Cc Rasmus Villemoes <[email protected]>--- test/py/tests/test_vboot.py | 8 ++++++++ 1 file changed, 8 insertions(+)test/py/tests/test_vboot.py +0
-0
test/py/tests/test_vboot.py def test_vboot(u_boot_console, sha_algo, padding, sign_options, required, · line 239
Quoted 10 lines
test/py/tests/test_vboot.py +7
-0@@ -230,6 +230,13 @@ def test_vboot(u_boot_console, sha_algo, padding, sign_options, required, cons.log.action('%s: Check signed config on the host' % sha_algo) util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb]) + + # Create a fresh .dtb without the public keys + dtc('sandbox-u-boot.dts') + # Then add the dev key via the fdt_add_pubkey tool + util.run_and_log(cons, [fdt_add_pubkey, '-a', '%s,rsa2048' % sha_algo, + '-k', tmpdir, '-n', 'dev', '-r', 'conf', dtb]) + util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb])
Looks good!
Quoted 12 lines
test/py/tests/test_vboot.py +1
-1if full_test: # Make sure that U-Boot checks that the config is in the list of@@ -370,6 +377,7 @@ def test_vboot(u_boot_console, sha_algo, padding, sign_options, required, fit = '%stest.fit' % tmpdir mkimage = cons.config.build_dir + '/tools/mkimage' fit_check_sign = cons.config.build_dir + '/tools/fit_check_sign' + fdt_add_pubkey = cons.config.build_dir + '/tools/fdt_add_pubkey' dtc_args = '-I dts -O dtb -i %s' % tmpdir dtb = '%ssandbox-u-boot.dtb' % tmpdir sig_node = '/configurations/conf-1/signature' --
Quoted 2 lines
2.25.1
Regards,
Simon
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.
I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a Kconfig option that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: add fdt_add_pubkey tool
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.
I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a Kconfig option that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
For what would you like to have code? The kconfig addition?
common/Kconfig.boot +8 -0
@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMAT
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi
as we are in design discussions, I would promote the idea of not pushing non hardware related things in the DTB that is passed to the kernel. Is your use case to allow U-Boot to verify the kernel's signature ? Why not putting it into an environment variable?
If your use case is on Arm or RISC-V, both environments are working heavily to make https://arm-software.github.io/ebbr/ standard available on a large number of boards.
This offers UEFI interface and SecureBoot (and later MeasuredBoot) services. For Arm boards just check for SystemReady compliance. In this context, traditional UEFI secure variables are used to deal with certificates and hashes: PK, KEK, db...
You can obviously do differently but you will be on your own to extend the chain of trust to IMA, secure containers (rooted down to hRoT) and other security facilities in the Linux side.
Could you describe your use case in more details?
Quoted 85 lines · Jan Kiszka
Quoted 1 line · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear,
because it isn't my code.
Quoted 1 line
Please do not top-post.
Quoted 4 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected];Rasmus Villemoes <[email protected]>
Quoted 16 lines
Subject: Re: [PATCH 0/2] RFC: add
fdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.Quoted 3 lines
I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature
that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 2 lines
My current vision of a user interface would be a
Kconfigoption thattakes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Quoted 5 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/
Quoted 5 lines
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +5
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, thatshall
+ be used to verify signed FIT images. The keys will be embedded
intocommon/Kconfig.boot +2
-0+ the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATBut note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Quoted 4 lines · François Ozog
Hi
as we are in design discussions, I would promote the idea of not pushing non hardware related things in the DTB that is passed to the kernel.
This was never proposed. The public keys go into the *control* FDTs.
Quoted 2 lines
Is your use case to allow U-Boot to verify the kernel's signature ? Why not putting it into an environment variable?
This is both about validating OS FIT containers as well as SPL checking U-Boot proper before continuing the boot there. The former case can be replaced with UEFI logic and likely taking the key from TEE (we do that as well in first prototypes), but the latter can't (yet).
Quoted 13 lines
If your use case is on Arm or RISC-V, both environments are working heavily to make https://arm-software.github.io/ebbr/
<https://arm-software.github.io/ebbr/> standard available on a large number of boards.
This offers UEFI interface and SecureBoot (and later MeasuredBoot) services. For Arm boards just check for SystemReady compliance. In this context, traditional UEFI secure variables are used to deal with certificates and hashes: PK, KEK, db...
You can obviously do differently but you will be on your own to extend the chain of trust to IMA, secure containers (rooted down to hRoT) and other security facilities in the Linux side.
Could you describe your use case in more details?
doc/uImage.FIT/signature.txt ;)
More concrete: We are currently massaging board/siemens/iot2050 to close its static chain of trust between SPL and U-Boot main, using software means (vendor means do not work because FSBL key != TF-A/TEE/U-Boot key).
Jan
Quoted 104 lines
On Tue, 9 Nov 2021 at 11:07, Jan Kiszka <[email protected] <mailto:[email protected]>> wrote:
On 09.11.21 10:37, Roman Kopytin wrote:
> Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
>Please do not top-post.
> -----Original Message-----
> From: Jan Kiszka <[email protected] <mailto:[email protected]>>
> Sent: Tuesday, November 9, 2021 12:17 PM
> To: Roman Kopytin <[email protected] <mailto:[email protected]>>; [email protected] <mailto:[email protected]>; Rasmus Villemoes <[email protected] <mailto:[email protected]>> > Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytool
>
> On 08.11.21 16:28, Roman Kopytin wrote:
>> In order to reduce the coupling between building the kernel and >> U-Boot, I'd like a tool that can add a public key to U-Boot's dtb >> without simultaneously signing a FIT image. That tool doesn't seem to
>> exist, so I stole the necessary pieces from mkimage et al and put it >> in a single .c file.
>>
>> I'm still working on the details of my proposed "require just k out >> these n required keys" and how it should be implemented, but it will >> probably involve teaching this tool a bunch of new options. These >> patches are not necessarily ready for inclusion (unless someone else >> findsfdt_add_pubkeyuseful as is), but I thought I might as well send
>> it out for early comments.
>
> I'd also like to see the usage of this hooked into the build process. >
> And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
>
> My current vision of a user interface would be aKconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea). >
> Jan
>
> [1]
>
https://lore.kernel.org/u-boot/[email protected]/
<https://lore.kernel.org/u-boot/[email protected]/>
>
> --
> Siemens AG, T RDA IOT
> Corporate Competence Center Embedded Linux
>For what would you like to have code? The kconfig addition?
diff --git a/common/Kconfig.boot b/common/Kconfig.boot index
d3a12be228..a9ed4d4ec4100644
--- a/common/Kconfig.boot
+++ b/common/Kconfig.boot
@@ -279,6 +279,14 @@ configSPL_FIT_GENERATORendif # SPL
+config
FIT_SIGNATURE_PUB_KEYS
+ string "Public keys to use for FIT image verification" + depends onFIT_SIGNATURE||SPL_FIT_SIGNATURE+ help
+ Public keys, or certificate files to extract them from, that shall
+ be used to verify signed FIT images. The keys will be embedded into
+ the control device tree of U-Boot.
+
endif # FITconfig
LEGACY_IMAGE_FORMATBut note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxSignature · 3 lines
François-Frédéric Ozog | /Director Business Development/ T: +33.67221.6485 [email protected] <mailto:[email protected]> | Skype: ffozog
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan
Quoted 32 lines · Jan Kiszka
Quoted 4 lines · François Ozog
Hi
as we are in design discussions, I would promote the idea of not pushing non hardware related things in the DTB that is passed to the kernel.
This was never proposed. The public keys go into the *control* FDTs.
great ;-)
Quoted 2 lines
Is your use case to allow U-Boot to verify the kernel's signature ? Why not putting it into an environment variable?
This is both about validating OS FIT containers as well as SPL checking U-Boot proper before continuing the boot there. The former case can be replaced with UEFI logic and likely taking the key from TEE (we do that as well in first prototypes), but the latter can't (yet).
Quoted 13 lines
If your use case is on Arm or RISC-V, both environments are working heavily to make https://arm-software.github.io/ebbr/
<https://arm-software.github.io/ebbr/> standard available on a large number of boards.
This offers UEFI interface and SecureBoot (and later MeasuredBoot) services. For Arm boards just check for SystemReady compliance. In this context, traditional UEFI secure variables are used to deal with certificates and hashes: PK, KEK, db...
You can obviously do differently but you will be on your own to extend the chain of trust to IMA, secure containers (rooted down to hRoT) and other security facilities in the Linux side.
Could you describe your use case in more details?
Quoted 7 lines
doc/uImage.FIT/signature.txt;)More concrete: We are currently massaging board/siemens/iot2050 to close its static chain of trust between SPL and U-Boot main, using software means (vendor means do not work because FSBL key != TF-A/TEE/U-Boot key).
And will the chain of trust be continuous or with a very brief breakage
with this approach?
I other words, can you enroll the TF-A/TEE/U-Boot key so that it can be trusted by FSBL key?
Jan
Quoted 119 lines
Quoted 22 lines
On Tue, 9 Nov 2021 at 11:07, Jan Kiszka <[email protected] <mailto:[email protected]>> wrote:
On 09.11.21 10:37, Roman Kopytin wrote:
> Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
>Please do not top-post.
> -----Original Message-----
> From: Jan Kiszka <[email protected] <mailto:[email protected]>>
> Sent: Tuesday, November 9, 2021 12:17 PM
> To: Roman Kopytin <[email protected] <mailto:[email protected]>>; [email protected] <mailto:[email protected]>; Rasmus Villemoes <[email protected] <mailto:[email protected]>> > Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytool >Quoted 6 lines
> On 08.11.21 16:28, Roman Kopytin wrote:
>> In order to reduce the coupling between building the kernel and >> U-Boot, I'd like a tool that can add a public key to U-Boot's dtb >> without simultaneously signing a FIT image. That tool doesn't seem to
>> exist, so I stole the necessary pieces from mkimage et al and putit
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
in a single .c file.
I'm still working on the details of my proposed "require just k
out
Quoted 1 line
Quoted 1 line
Quoted 1 line
these n required keys" and how it should be implemented, but it
will
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone
else
Quoted 5 lines
Quoted 1 line
Quoted 1 line
finds
fdt_add_pubkeyuseful as is), but I thought I might as wellsend
>> it out for early comments.
>
> I'd also like to see the usage of this hooked into the buildprocess.
Quoted 10 lines
Quoted 2 lines
And to my understanding of [1], that approach will provide a
feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
>
> My current vision of a user interface would be aKconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea). >Quoted 5 lines
> Jan
>
> [1]
>https://lore.kernel.org/u-boot/[email protected]/
Quoted 1 line
<https://lore.kernel.org/u-boot/[email protected]/
Quoted 44 lines
Quoted 6 lines
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
diff --git a/common/Kconfig.boot b/common/Kconfig.boot index
d3a12be228..a9ed4d4ec4100644
--- a/common/Kconfig.boot
+++ b/common/Kconfig.boot
@@ -279,6 +279,14 @@ configSPL_FIT_GENERATORendif # SPL
+config
FIT_SIGNATURE_PUB_KEYS
+ string "Public keys to use for FIT image verification"
+ depends onFIT_SIGNATURE||SPL_FIT_SIGNATURE
+ help
+ Public keys, or certificate files to extract them from,
that shall
+ be used to verify signed FIT images. The keys will be
embedded into
+ the control device tree of U-Boot.
+
endif # FITconfig
LEGACY_IMAGE_FORMATBut note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxQuoted 8 lines
--
François-Frédéric Ozog | /Director Business Development/
T: +33.67221.6485
[email protected] <mailto:[email protected] | Skype: ffozog--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Quoted 48 lines · François Ozog
Hi Jan
On Tue, 9 Nov 2021 at 13:58, Jan Kiszka <[email protected] <mailto:[email protected]>> wrote:
On 09.11.21 13:43, François Ozog wrote:
> Hi
>
> as we are in design discussions, I would promote the idea of not pushing
> non hardware related things in the DTB that is passed to the kernel.This was never proposed. The public keys go into the *control* FDTs.
great ;-)
Quoted 2 lines
Is your use case to allow U-Boot to verify the kernel's signature ? Why not putting it into an environment variable?
This is both about validating OS FIT containers as well as SPL checking U-Boot proper before continuing the boot there. The former case can be replaced with UEFI logic and likely taking the key from TEE (we do that as well in first prototypes), but the latter can't (yet).
>
> If your use case is on Arm or RISC-V, both environments are working > heavily to make https://arm-software.github.io/ebbr/
<https://arm-software.github.io/ebbr/>
> <https://arm-software.github.io/ebbr/
<https://arm-software.github.io/ebbr/>> standard available on a large > number of boards.
> This offers UEFI interface and SecureBoot (and later MeasuredBoot) > services. For Arm boards just check for SystemReady compliance. > In this context, traditional UEFI secure variables are used to deal with
> certificates and hashes: PK, KEK, db...
> You can obviously do differently but you will be on your own to extend > the chain of trust to IMA, secure containers (rooted down to hRoT) and > other security facilities in the Linux side.
> Could you describe your use case in more details?
doc/uImage.FIT/signature.txt;)More concrete: We are currently massaging board/siemens/iot2050 to close its static chain of trust between SPL and U-Boot main, using software means (vendor means do not work because FSBL key != TF-A/TEE/U-Boot key).
Quoted 4 lines
And will the chain of trust be continuous or with a very brief breakage with this approach?
I other words, can you enroll the TF-A/TEE/U-Boot key so that it can be trusted by FSBL key?
The chain will be continuous. Both FSBL and TF-A/TEE/SPL will be OTP-anchored (but deployed at different times / by different authorities), FSBL will validate based on OTP, SPL should do that based on control FDT key. Therefore, we need embedding into the SPL FDT in this case.
If the user decides to continue "classically" by loading the OS from a signed FIT image, also U-Boot proper needs the public key in its control FDT.
That's just one (likely more special) scenario, but I bet there are plenty others on other SOCs / systems.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 83 lines · Jan Kiszka
Quoted 11 lines · François Ozog
Hi Jan
On Tue, 9 Nov 2021 at 13:58, Jan Kiszka <[email protected] <mailto:[email protected]>> wrote:
On 09.11.21 13:43, François Ozog wrote:
> Hi
>
> as we are in design discussions, I would promote the idea of not pushing
> non hardware related things in the DTB that is passed to thekernel.
Quoted 9 lines
This was never proposed. The public keys go into the *control* FDTs.
great ;-)
Quoted 2 lines
Is your use case to allow U-Boot to verify the kernel's signature ? Why not putting it into an environment variable?
This is both about validating OS FIT containers as well as SPL
checking
Quoted 1 line
U-Boot proper before continuing the boot there. The former case can
be
Quoted 1 line
replaced with UEFI logic and likely taking the key from TEE (we do
that
Quoted 8 lines
as well in first prototypes), but the latter can't (yet).
>
> If your use case is on Arm or RISC-V, both environments are working > heavily to make https://arm-software.github.io/ebbr/
<https://arm-software.github.io/ebbr/>
> <https://arm-software.github.io/ebbr/
<https://arm-software.github.io/ebbr/>> standard available on alarge
Quoted 7 lines
Quoted 4 lines
number of boards.
This offers UEFI interface and SecureBoot (and later MeasuredBoot) services. For Arm boards just check for SystemReady compliance. In this context, traditional UEFI secure variables are used todeal with
> certificates and hashes: PK, KEK, db...
> You can obviously do differently but you will be on your own toextend
Quoted 1 line
Quoted 1 line
the chain of trust to IMA, secure containers (rooted down to hRoT)
and
Quoted 6 lines
Quoted 2 lines
other security facilities in the Linux side.
Could you describe your use case in more details?
doc/uImage.FIT/signature.txt;)More concrete: We are currently massaging board/siemens/iot2050 to
close
Quoted 8 lines
its static chain of trust between SPL and U-Boot main, using software means (vendor means do not work because FSBL key != TF-A/TEE/U-Boot key).And will the chain of trust be continuous or with a very brief breakage with this approach?
I other words, can you enroll the TF-A/TEE/U-Boot key so that it can be trusted by FSBL key?The chain will be continuous. Both FSBL and TF-A/TEE/SPL will be OTP-anchored (but deployed at different times / by different authorities), FSBL will validate based on OTP, SPL should do that based on control FDT key. Therefore, we need embedding into the SPL FDT in this case.
If the user decides to continue "classically" by loading the OS from a signed FIT image, also U-Boot proper needs the public key in its control FDT.
That's just one (likely more special) scenario, but I bet there are plenty others on other SOCs / systems.
Get it. Thanks for detailing the case, its very useful for me.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Hi François,
Quoted 7 lines · François Ozog
Hi
as we are in design discussions, I would promote the idea of not pushing non hardware related things in the DTB that is passed to the kernel. Is your use case to allow U-Boot to verify the kernel's signature ? Why not putting it into an environment variable?
We have been through this many times but I'll state it again. U-Boot makes use of the devicetree for configuration information, including public keys, etc.
It does not belong anywhere else.
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Quoted 13 lines
If your use case is on Arm or RISC-V, both environments are working heavily to make https://arm-software.github.io/ebbr/ standard available on a large number of boards.
This offers UEFI interface and SecureBoot (and later MeasuredBoot) services. For Arm boards just check for SystemReady compliance. In this context, traditional UEFI secure variables are used to deal with certificates and hashes: PK, KEK, db...
You can obviously do differently but you will be on your own to extend the chain of trust to IMA, secure containers (rooted down to hRoT) and other security facilities in the Linux side.
Could you describe your use case in more details?
That feature does not use FIT images, nor U-Boot's verified boot.
Regards,
Simon
Quoted 93 lines · Jan Kiszka
Quoted 80 lines · Roman Kopytin
Quoted 1 line
Can we have discussion with code lines? For me it is not very clear,
because it isn't my code.
Quoted 1 line
Please do not top-post.
Quoted 4 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected];Rasmus Villemoes <[email protected]>
Quoted 16 lines
Subject: Re: [PATCH 0/2] RFC: add
fdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.Quoted 3 lines
I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature
that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 2 lines
My current vision of a user interface would be a
Kconfigoption thattakes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Quoted 5 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/
Quoted 5 lines
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +5
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, thatshall
+ be used to verify signed FIT images. The keys will be embedded
intocommon/Kconfig.boot +2
-0+ the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATBut note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
Quoted 6 lines
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux--
François-Frédéric Ozog | *Director Business Development*
T: +33.67221.6485
[email protected] | Skype: ffozog
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMAT
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Regards,
Simon
Quoted 69 lines · Simon Glass
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMAT
Quoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 79 lines · Jan Kiszka
Quoted 69 lines · Simon Glass
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATQuoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Quoted 5 lines
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
The public key is not needed for signing to work, right? I don't understand what you are getting at here. If you want to add the public key to the image before it is signed, that's fine. I just don't understand why you want to do that. Why not have the signer do everything?
Regards,
Simon
Quoted 88 lines · Simon Glass
Hi Jan,
Quoted 79 lines · Jan Kiszka
Quoted 69 lines · Simon Glass
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATQuoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Quoted 5 lines
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
Quoted 5 lines
The public key is not needed for signing to work, right? I don't understand what you are getting at here. If you want to add the public key to the image before it is signed, that's fine. I just don't understand why you want to do that. Why not have the signer do everything?
A) Because sensitive signing environments will not run arbitrary logic. They will hand out the public key, but they may not give you the chance to run mkimage with the private key, like you would do during development.
B) It avoids having to run the signing process in a specific order because it already embeds the public key during build, thus generates everything that shall be signed upfront.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan
Quoted 108 lines · Jan Kiszka
Quoted 8 lines · Simon Glass
Hi Jan,
Quoted 5 lines · Jan Kiszka
Quoted 3 lines · Simon Glass
Hi Jan,
On Tue, 9 Nov 2021 at 03:07, Jan Kiszka <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Roman Kopytin
Quoted 1 line
Can we have discussion with code lines? For me it is not very clear,
because it isn't my code.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Please do not top-post.
Quoted 4 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>;[email protected]; Rasmus Villemoes <[email protected]>
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Subject: Re: [PATCH 0/2] RFC: add
fdt_add_pubkeytoolQuoted 3 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem
to
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as wellsend
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
it out for early comments.
I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature
that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
My current vision of a user interface would be a
Kconfigoption thattakes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +0
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATORQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
common/Kconfig.boot config SPL_FIT_GENERATOR
Quoted 7 lines
common/Kconfig.boot +5
-0endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from,that shall
Quoted 1 line
Quoted 1 line
Quoted 1 line
common/Kconfig.boot config SPL_FIT_GENERATOR · line 287
Quoted 1 line
common/Kconfig.boot +1
-0+ be used to verify signed FIT images. The keys will beembedded into
Quoted 21 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
common/Kconfig.boot +2
-0+ the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATQuoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Quoted 5 lines
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
Quoted 5 lines
The public key is not needed for signing to work, right? I don't understand what you are getting at here. If you want to add the public key to the image before it is signed, that's fine. I just don't understand why you want to do that. Why not have the signer do everything?
Quoted 5 lines
A) Because sensitive signing environments will not run arbitrary logic. They will hand out the public key, but they may not give you the chance to run mkimage with the private key, like you would do during development.
thanks for bringing this very important topic on the list. In this case nobody may have the private key handy as it sits hidden inside an HSM:
correct ?
Quoted 11 lines
B) It avoids having to run the signing process in a specific order because it already embeds the public key during build, thus generates everything that shall be signed upfront.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Quoted 127 lines · François Ozog
Hi Jan
Le mer. 10 nov. 2021 à 17:48, Jan Kiszka <[email protected] <mailto:[email protected]>> a écrit :
On 10.11.21 17:31, Simon Glass wrote:
> Hi Jan,
>
> On Tue, 9 Nov 2021 at 23:44, Jan Kiszka <[email protected] <mailto:[email protected]>> wrote:
>>
>> On 10.11.21 01:58, Simon Glass wrote:
>>> Hi Jan,
>>>
>>> On Tue, 9 Nov 2021 at 03:07, Jan Kiszka <[email protected] <mailto:[email protected]>> wrote:
>>>>
>>>> On 09.11.21 10:37, Roman Kopytin wrote:
>>>>> Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
>>>>>
>>>>
>>>> Please do not top-post.
>>>>
>>>>> -----Original Message-----
>>>>> From: Jan Kiszka <[email protected] <mailto:[email protected]>>
>>>>> Sent: Tuesday, November 9, 2021 12:17 PM
>>>>> To: Roman Kopytin <[email protected] <mailto:[email protected]>>; [email protected] <mailto:[email protected]>; Rasmus Villemoes <[email protected] <mailto:[email protected]>> >>>>> Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytool >>>>>
>>>>> On 08.11.21 16:28, Roman Kopytin wrote:
>>>>>> In order to reduce the coupling between building the kernel and >>>>>> U-Boot, I'd like a tool that can add a public key to U-Boot's dtb >>>>>> without simultaneously signing a FIT image. That tool doesn't seem to
>>>>>> exist, so I stole the necessary pieces from mkimage et al and put it
>>>>>> in a single .c file.
>>>>>>
>>>>>> I'm still working on the details of my proposed "require just k out
>>>>>> these n required keys" and how it should be implemented, but it will
>>>>>> probably involve teaching this tool a bunch of new options. These >>>>>> patches are not necessarily ready for inclusion (unless someone else
>>>>>> findsfdt_add_pubkeyuseful as is), but I thought I might as well send
>>>>>> it out for early comments.
>>>>>
>>>>> I'd also like to see the usage of this hooked into the build process.
>>>>>
>>>>> And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
>>>>>
>>>>> My current vision of a user interface would be aKconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea). >>>>>
>>>>> Jan
>>>>>
>>>>> [1]
>>>>>
https://lore.kernel.org/u-boot/[email protected]/
<https://lore.kernel.org/u-boot/[email protected]/>
>>>>>
>>>>> --
>>>>> Siemens AG, T RDA IOT
>>>>> Corporate Competence Center Embedded Linux
>>>>>
>>>>
>>>> For what would you like to have code? The kconfig addition? >>>>
>>>> diff --git a/common/Kconfig.boot b/common/Kconfig.boot >>>> indexd3a12be228..a9ed4d4ec4100644
>>>> --- a/common/Kconfig.boot
>>>> +++ b/common/Kconfig.boot
>>>> @@ -279,6 +279,14 @@ configSPL_FIT_GENERATOR
>>>>
>>>> endif # SPL
>>>>
>>>> +configFIT_SIGNATURE_PUB_KEYS
>>>> + string "Public keys to use for FIT image verification" >>>> + depends onFIT_SIGNATURE||SPL_FIT_SIGNATURE>>>> + help
>>>> + Public keys, or certificate files to extract them from, that shall
>>>> + be used to verify signed FIT images. The keys will be embedded into
>>>> + the control device tree of U-Boot.
>>>> +
>>>> endif # FIT
>>>>
>>>> configLEGACY_IMAGE_FORMAT
>>>>
>>>>
>>>> But note that we are in a design discussion here, and I'm at least >>>> reluctant to code up n-versions without having some common idea where
>>>> things should move.
>>>
>>> I'm not sure we want this built into U-Boot. I see signing of a >>> firmware image as a final step, with the keys being added then, e.g. >>> by binman.
>>
>> This is not signing, this in embedding public key information into build
>> artifacts before they can be signed. As pointed out in my other thread,
>> not having an embedding feature is a major drawback of the current >> workflow. It easily forces you to rebuild existing build flows in >> out-of-tree scripts.
>
> The public key is not needed for signing to work, right? I don't > understand what you are getting at here. If you want to add the public > key to the image before it is signed, that's fine. I just don't > understand why you want to do that. Why not have the signer do > everything?
Quoted 8 lines
A) Because sensitive signing environments will not run arbitrary logic. They will hand out the public key, but they may not give you the chance to run mkimage with the private key, like you would do during development.
thanks for bringing this very important topic on the list. In this case nobody may have the private key handy as it sits hidden inside an HSM:
correct ?
I have no insides where/how it is stored in our case, ie. our trust center that is managing keys and issuing certificates. In any case, private keys are definitely not in the hands of the build environments or product engineers then - even if those have to be trusted as well, just for different aspects.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 96 lines · Jan Kiszka
Quoted 88 lines · Simon Glass
Hi Jan,
Quoted 79 lines · Jan Kiszka
Quoted 69 lines · Simon Glass
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATQuoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Quoted 5 lines
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
Quoted 5 lines
The public key is not needed for signing to work, right? I don't understand what you are getting at here. If you want to add the public key to the image before it is signed, that's fine. I just don't understand why you want to do that. Why not have the signer do everything?
Quoted 4 lines
A) Because sensitive signing environments will not run arbitrary logic. They will hand out the public key, but they may not give you the chance to run mkimage with the private key, like you would do during development.
That's OK, so long as there is a way to get the data to be signed in, and the public key and signature out.
Quoted 4 lines
B) It avoids having to run the signing process in a specific order because it already embeds the public key during build, thus generates everything that shall be signed upfront.
The public key is not signed though. Whether it is present at the start or not is not important.
Regards,
Simon
Quoted 108 lines · Simon Glass
Hi Jan,
Quoted 96 lines · Jan Kiszka
Quoted 88 lines · Simon Glass
Hi Jan,
Quoted 79 lines · Jan Kiszka
Quoted 69 lines · Simon Glass
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATQuoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Quoted 5 lines
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
Quoted 5 lines
The public key is not needed for signing to work, right? I don't understand what you are getting at here. If you want to add the public key to the image before it is signed, that's fine. I just don't understand why you want to do that. Why not have the signer do everything?
Quoted 4 lines
A) Because sensitive signing environments will not run arbitrary logic. They will hand out the public key, but they may not give you the chance to run mkimage with the private key, like you would do during development.
That's OK, so long as there is a way to get the data to be signed in, and the public key and signature out.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
B) It avoids having to run the signing process in a specific order because it already embeds the public key during build, thus generates everything that shall be signed upfront.
The public key is not signed though. Whether it is present at the start or not is not important.
The public key is signed when it is placed into an image that is signed. That is the case, e.g., when injecting it into the SPL control FDT and then signing the SPL image. Or when injecting it into the main control FDT and signing U-Boot proper afterwards.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 114 lines · Jan Kiszka
Quoted 112 lines · Simon Glass
Hi Jan,
Quoted 96 lines · Jan Kiszka
Quoted 88 lines · Simon Glass
Hi Jan,
Quoted 79 lines · Jan Kiszka
Quoted 69 lines · Simon Glass
Hi Jan,
Quoted 66 lines · Jan Kiszka
Quoted 2 lines · Roman Kopytin
Can we have discussion with code lines? For me it is not very clear, because it isn't my code.
Please do not top-post.
Quoted 26 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Tuesday, November 9, 2021 12:17 PM
To: Roman Kopytin <[email protected]>; [email protected]; Rasmus Villemoes <[email protected]>
Subject: Re: [PATCH 0/2] RFC: addfdt_add_pubkeytoolQuoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded LinuxFor what would you like to have code? The kconfig addition?
common/Kconfig.boot +8
-0@@ -279,6 +279,14 @@ config SPL_FIT_GENERATOR endif # SPL +config FIT_SIGNATURE_PUB_KEYS + string "Public keys to use for FIT image verification" + depends on FIT_SIGNATURE || SPL_FIT_SIGNATURE + help + Public keys, or certificate files to extract them from, that shall + be used to verify signed FIT images. The keys will be embedded into + the control device tree of U-Boot. + endif # FIT config LEGACY_IMAGE_FORMATQuoted 7 lines
Quoted 3 lines
But note that we are in a design discussion here, and I'm at least reluctant to code up n-versions without having some common idea where things should move.
I'm not sure we want this built into U-Boot. I see signing of a firmware image as a final step, with the keys being added then, e.g. by binman.
Quoted 5 lines
This is not signing, this in embedding public key information into build artifacts before they can be signed. As pointed out in my other thread, not having an embedding feature is a major drawback of the current workflow. It easily forces you to rebuild existing build flows in out-of-tree scripts.
Quoted 5 lines
The public key is not needed for signing to work, right? I don't understand what you are getting at here. If you want to add the public key to the image before it is signed, that's fine. I just don't understand why you want to do that. Why not have the signer do everything?
Quoted 4 lines
A) Because sensitive signing environments will not run arbitrary logic. They will hand out the public key, but they may not give you the chance to run mkimage with the private key, like you would do during development.
That's OK, so long as there is a way to get the data to be signed in, and the public key and signature out.
Quoted 4 lines
B) It avoids having to run the signing process in a specific order because it already embeds the public key during build, thus generates everything that shall be signed upfront.
Quoted 7 lines
Quoted 2 lines
The public key is not signed though. Whether it is present at the start or not is not important.
The public key is signed when it is placed into an image that is signed. That is the case, e.g., when injecting it into the SPL control FDT and then signing the SPL image. Or when injecting it into the main control FDT and signing U-Boot proper afterwards.
Ah OK, so it is signed along with everything else.
Regards,
Simon
Quoted 6 lines
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Hi,
Quoted 17 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
Quoted 8 lines
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).
Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Regards,
Simon
Quoted 9 lines
Jan
[1]
https://lore.kernel.org/u-boot/[email protected]/--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Quoted 24 lines · Simon Glass
Hi,
Quoted 21 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 8 lines
Quoted 4 lines
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
But one after the other.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 34 lines · Jan Kiszka
Quoted 24 lines · Simon Glass
Hi,
Quoted 21 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 8 lines
Quoted 4 lines
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
Jan
Quoted 12 lines
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
But one after the other.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 36 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 32 lines · Simon Glass
Hi,
Quoted 17 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
Quoted 8 lines
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.
Well I don't think binman supports that at present, or at least I'm not sure what it would do. We don't have a test case for it. If you have an idea for how it should work, please send some ideas and I can look at it.
Quoted 4 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
The fdtmap provides enough information to extract anything from the image and regenerate/replace things.
What is a map file?
Quoted 10 lines
Jan
Quoted 7 lines
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
Well that needs to be provided somewhere. It should be fairly easy to get Binman to do this, so long as the image description has info about what is being signed.
Quoted 2 lines
Quoted 2 lines
But one after the other.
Possibly, but sometimes it is best to design things up-front.
Regards,
Simon
Quoted 52 lines · Simon Glass
Hi Jan,
Quoted 36 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 32 lines · Simon Glass
Hi,
Quoted 17 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
Quoted 8 lines
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.Well I don't think binman supports that at present, or at least I'm not sure what it would do. We don't have a test case for it. If you have an idea for how it should work, please send some ideas and I can look at it.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
The fdtmap provides enough information to extract anything from the image and regenerate/replace things.
What is a map file?
*.map, e.g. image.map? Also generated by many binmap <cmd> -m?
Quoted 12 lines
Quoted 11 lines
Jan
Quoted 7 lines
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
Quoted 3 lines
Well that needs to be provided somewhere. It should be fairly easy to get Binman to do this, so long as the image description has info about what is being signed.
I would assume that it has to have that information, already to use mkimage on it or its parts.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
But one after the other.
Possibly, but sometimes it is best to design things up-front.
True as well.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 58 lines · Jan Kiszka
Quoted 56 lines · Simon Glass
Hi Jan,
Quoted 36 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 32 lines · Simon Glass
Hi,
Quoted 17 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
Quoted 8 lines
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.Well I don't think binman supports that at present, or at least I'm not sure what it would do. We don't have a test case for it. If you have an idea for how it should work, please send some ideas and I can look at it.
Quoted 4 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
Quoted 6 lines
Quoted 4 lines
The fdtmap provides enough information to extract anything from the image and regenerate/replace things.
What is a map file?
*.map, e.g. image.map? Also generated by many binmap <cmd> -m?
Using map files for what? Do you mean passing it to Binman in lieu of an in-image fdtmap? If so, they are not equivalent. The map is just a simple text output of offsets and sizes. The fdtmap contains the full image description.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Jan
Quoted 7 lines
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
Quoted 6 lines
Quoted 3 lines
Well that needs to be provided somewhere. It should be fairly easy to get Binman to do this, so long as the image description has info about what is being signed.
I would assume that it has to have that information, already to use mkimage on it or its parts.
Well, at present the information is there but Binman does not fully parse the mkimage subnodes. E.g. it doesn't look to see what things are signed/hashed. It just runs mkimage. If we want to output the hash for signing, we would need to implement that somewhere. Binman could do this after the image is build, i.e. look at the various signature nodes, hash the appropriate data and write out an 'instructions' file in a suitable format.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
But one after the other.
Possibly, but sometimes it is best to design things up-front.
True as well.
Regards,
Simon
Quoted 64 lines · Simon Glass
Hi Jan,
Quoted 61 lines · Jan Kiszka
Quoted 59 lines · Simon Glass
Hi Jan,
Quoted 36 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 32 lines · Simon Glass
Hi,
Quoted 17 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
Quoted 8 lines
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.Well I don't think binman supports that at present, or at least I'm not sure what it would do. We don't have a test case for it. If you have an idea for how it should work, please send some ideas and I can look at it.
Quoted 4 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
The fdtmap provides enough information to extract anything from the image and regenerate/replace things.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What is a map file?
*.map, e.g. image.map? Also generated by many binmap <cmd> -m?
Using map files for what? Do you mean passing it to Binman in lieu of an in-image fdtmap? If so, they are not equivalent. The map is just a simple text output of offsets and sizes. The fdtmap contains the full image description.
Too bad. I was looking for a way to avoid having to add fdtmap to an image when all information is already on the build host - and should actually only remain there. Embedding fdtmap into the image solely for build/post-process purposes looks like overkill to me.
Quoted 21 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Jan
Quoted 7 lines
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
Quoted 6 lines
Quoted 3 lines
Well that needs to be provided somewhere. It should be fairly easy to get Binman to do this, so long as the image description has info about what is being signed.
I would assume that it has to have that information, already to use mkimage on it or its parts.
Quoted 7 lines
Well, at present the information is there but Binman does not fully parse the mkimage subnodes. E.g. it doesn't look to see what things are signed/hashed. It just runs mkimage. If we want to output the hash for signing, we would need to implement that somewhere. Binman could do this after the image is build, i.e. look at the various signature nodes, hash the appropriate data and write out an 'instructions' file in a suitable format.
Yep, that would be nice. Or would mkimage have more of the needed logic already on board and would better be extended to write them out?
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Hi Jan,
Quoted 75 lines · Jan Kiszka
Quoted 64 lines · Simon Glass
Hi Jan,
Quoted 61 lines · Jan Kiszka
Quoted 59 lines · Simon Glass
Hi Jan,
Quoted 36 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 32 lines · Simon Glass
Hi,
Quoted 17 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
Quoted 8 lines
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.Well I don't think binman supports that at present, or at least I'm not sure what it would do. We don't have a test case for it. If you have an idea for how it should work, please send some ideas and I can look at it.
Quoted 4 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
The fdtmap provides enough information to extract anything from the image and regenerate/replace things.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
What is a map file?
*.map, e.g. image.map? Also generated by many binmap <cmd> -m?
Using map files for what? Do you mean passing it to Binman in lieu of an in-image fdtmap? If so, they are not equivalent. The map is just a simple text output of offsets and sizes. The fdtmap contains the full image description.
Quoted 4 lines
Too bad. I was looking for a way to avoid having to add fdtmap to an image when all information is already on the build host - and should actually only remain there. Embedding fdtmap into the image solely for build/post-process purposes looks like overkill to me.
and for run-time access and for being able to list the image and extract things from it.
Regards,
Simon
Quoted 38 lines
Quoted 22 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Jan
Quoted 7 lines
And another area: Trust centers that perform the signing (and only that) usually do not support random formats and workflows but just few common ones, e.g. x509. It would be nice to have a way to route out the payload (hashes etc.) that mkimage would sign, ideally into a standard signing request, and permit to inject the resulting signature at the right places into the FIT image.
Quoted 6 lines
Quoted 3 lines
Well that needs to be provided somewhere. It should be fairly easy to get Binman to do this, so long as the image description has info about what is being signed.
I would assume that it has to have that information, already to use mkimage on it or its parts.
Quoted 7 lines
Well, at present the information is there but Binman does not fully parse the mkimage subnodes. E.g. it doesn't look to see what things are signed/hashed. It just runs mkimage. If we want to output the hash for signing, we would need to implement that somewhere. Binman could do this after the image is build, i.e. look at the various signature nodes, hash the appropriate data and write out an 'instructions' file in a suitable format.
Yep, that would be nice. Or would mkimage have more of the needed logic already on board and would better be extended to write them out?
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
binman replace broken? (was: Re: [PATCH 0/2] RFC: add fdt_add_pubkey tool)
In reply to Jan KiszkaQuoted 42 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 24 lines · Simon Glass
Hi,
Quoted 21 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 8 lines
Quoted 4 lines
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.
Quoted 4 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
Well, too quick: "binman replace" writes everything into a temporary directory, including the updated image - and then deletes this directory on exit. So the original image will not be updated, and the update is lost.
I tried to quickly fix it by adding a rename before FinaliseOutputDir, but it feels like I'm working against the design of the internal interfaces here.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Re: binman replace broken? (was: Re: [PATCH 0/2] RFC: add fdt_add_pubkey tool)
Hi Jan,
Quoted 49 lines · Jan Kiszka
Quoted 42 lines · Jan Kiszka
Quoted 34 lines · Jan Kiszka
Quoted 24 lines · Simon Glass
Hi,
Quoted 21 lines · Jan Kiszka
Quoted 6 lines · Roman Kopytin
In order to reduce the coupling between building the kernel and U-Boot, I'd like a tool that can add a public key to U-Boot's dtb without simultaneously signing a FIT image. That tool doesn't seem to exist, so I stole the necessary pieces from mkimage et al and put it in a single .c file.
Quoted 6 lines
I'm still working on the details of my proposed "require just k out these n required keys" and how it should be implemented, but it will probably involve teaching this tool a bunch of new options. These patches are not necessarily ready for inclusion (unless someone else finds
fdt_add_pubkeyuseful as is), but I thought I might as well send it out for early comments.I'd also like to see the usage of this hooked into the build process.
And to my understanding of [1], that approach will provide a feature that permits hooking with the build but would expect the key as dtsi fragment. Can we consolidate the approaches?
Quoted 8 lines
Quoted 4 lines
My current vision of a user interface would be a
Kconfigoption that takes a list of key files to be injected. Maybe make that three lists, one for "required=image", one for "required=conf", and one for optional keys (if that has a use case in practice, no idea).Also please take a look at binman which is designed to handle create (or later updating from Yocto) the devicetree or firmware image.
Quoted 6 lines
Yes, binman is another problem area, but not for the public key injection, rather for permitting to sign fit images that are described for binman (rather than for mkimage). I'm currently back to dd for signing the U-Boot container in
arch/arm/dts/k3-am65-iot2050-boot-image.dtsi, or I would have to split that FIT image description from that file - both not optimal.Quoted 4 lines
OK, this can already be optimized with "binman replace" - once I understood where fdtmap can go and where not. Why no support for using map files?
Quoted 7 lines
Well, too quick: "binman replace" writes everything into a temporary directory, including the updated image - and then deletes this directory on exit. So the original image will not be updated, and the update is lost.
I tried to quickly fix it by adding a rename before FinaliseOutputDir, but it feels like I'm working against the design of the internal interfaces here.
If you want to see how things work, check out ftest.py which has all the tests. If there is a test for it, it probably works. If not, it might not.
Regards,
SImon