From: Marcin Niestroj <m.niestroj@grinn-global.com>
To: barebox@lists.infradead.org
Cc: Marcin Niestroj <m.niestroj@grinn-global.com>
Subject: [PATCH 1/5] scripts: imx: add optional argument to hab_blocks command
Date: Mon, 3 Sep 2018 12:57:11 +0200 [thread overview]
Message-ID: <20180903105715.24263-2-m.niestroj@grinn-global.com> (raw)
In-Reply-To: <20180903105715.24263-1-m.niestroj@grinn-global.com>
hab_blocks command is used to specify image authentication blocks for
HAB. Currently it was configured to authenticate full barebox
image. However in case of booting from SD card and adding MBR
partition table, HAB authentication fails, as final boot image is
modified.
Add an optional argument to hab_blocks command, to select between
3 types of authentication areas:
- full: whole barebox image will be authenticated (this is default to
keep compatibility),
- from-dcdofs: image area up to dcdofs is not authenticated, so any
changes up to dcdofs are possible,
- skip-mbr: image area from 440 to 512 bytes is excluded from beeing
authenticated, which allows to add / modify MBR partition table
after building barebox image.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
---
Changes rfc -> v1: none
scripts/imx/imx.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index d3786b6e1..21206387e 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -317,15 +317,40 @@ static int do_hab(struct config_data *data, int argc, char *argv[])
static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
{
+ const char *type;
char *str;
int ret;
if (!data->csf)
return -EINVAL;
- ret = asprintf(&str, "Blocks = 0x%08x 0 %d \"%s\"\n",
- data->image_load_addr,
- data->load_size, data->outfile);
+ if (argc < 2)
+ type = "full";
+ else
+ type = argv[1];
+
+ if (!strcmp(type, "full")) {
+ ret = asprintf(&str, "Blocks = 0x%08x 0 %d \"%s\"\n",
+ data->image_load_addr, data->load_size,
+ data->outfile);
+ } else if (!strcmp(type, "from-dcdofs")) {
+ ret = asprintf(&str, "Blocks = 0x%08x 0x%x %d \"%s\"\n",
+ data->image_load_addr + data->image_dcd_offset,
+ data->image_dcd_offset,
+ data->load_size - data->image_dcd_offset,
+ data->outfile);
+ } else if (!strcmp(type, "skip-mbr")) {
+ ret = asprintf(&str,
+ "Blocks = 0x%08x 0 440 \"%s\", \\\n"
+ " 0x%08x 512 %d \"%s\"\n",
+ data->image_load_addr, data->outfile,
+ data->image_load_addr + 512,
+ data->load_size - 512, data->outfile);
+ } else {
+ fprintf(stderr, "Invalid hab_blocks option: %s\n", type);
+ return -EINVAL;
+ }
+
if (ret < 0)
return -ENOMEM;
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-09-03 10:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 10:57 [PATCH 0/5] ARM: imx: HAB improvements Marcin Niestroj
2018-09-03 10:57 ` Marcin Niestroj [this message]
2018-09-03 10:57 ` [PATCH 2/5] ARM: imx: Update default image certificate for CST tool Marcin Niestroj
2018-09-03 10:57 ` [PATCH 3/5] scripts: imx: Support encrypted boot with HABv4 Marcin Niestroj
2018-09-03 10:57 ` [PATCH 4/5] images: imx: Add targets for signed encrypted images Marcin Niestroj
2018-09-03 10:57 ` [PATCH 5/5] scripts: imx: Do not include autoconf.h Marcin Niestroj
2018-09-04 7:54 ` Sascha Hauer
2018-09-04 9:38 ` Marcin Niestrój
2018-09-07 8:39 ` Sascha Hauer
2018-09-04 8:17 ` [PATCH 0/5] ARM: imx: HAB improvements Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180903105715.24263-2-m.niestroj@grinn-global.com \
--to=m.niestroj@grinn-global.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox