summaryrefslogtreecommitdiffstats
path: root/common/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-01-15 14:37:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-26 22:45:42 +0100
commitebb1160cddbd58831cc8347dba94f208a0cb8500 (patch)
tree9926fe69c45a5396d2e30479dfdd5de32ae59cdd /common/bootm.c
parent6e686491a5478c13554536a65db6381181472133 (diff)
downloadbarebox-ebb1160cddbd58831cc8347dba94f208a0cb8500.tar.gz
bootm: make verifying/hashing configurable
So long struct bootm_data.verify is a bool which enables CRC checking (hashing). Extend this to a enum and add support for signature checking in the same option. This also adds the corresponding globalvar and a -s option to bootm. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/bootm.c')
-rw-r--r--common/bootm.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/common/bootm.c b/common/bootm.c
index 4409a8b..78a6bb5 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -56,8 +56,22 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.image.loadaddr", &data->os_address);
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
+ data->verify = bootm_get_verify_mode();
}
+static enum bootm_verify bootm_verify_mode = BOOTM_VERIFY_HASH;
+
+enum bootm_verify bootm_get_verify_mode(void)
+{
+ return bootm_verify_mode;
+}
+
+static const char * const bootm_verify_names[] = {
+ [BOOTM_VERIFY_NONE] = "none",
+ [BOOTM_VERIFY_HASH] = "hash",
+ [BOOTM_VERIFY_SIGNATURE] = "signature",
+};
+
/*
* bootm_load_os() - load OS to RAM
*
@@ -122,7 +136,7 @@ static int bootm_open_initrd_uimage(struct image_data *data)
if (!data->initrd)
return -EINVAL;
- if (data->verify) {
+ if (bootm_get_verify_mode() > BOOTM_VERIFY_NONE) {
ret = uimage_verify(data->initrd);
if (ret) {
printf("Checking data crc failed with %s\n",
@@ -382,7 +396,7 @@ static int bootm_open_os_uimage(struct image_data *data)
if (!data->os)
return -EINVAL;
- if (data->verify) {
+ if (bootm_get_verify_mode() > BOOTM_VERIFY_NONE) {
ret = uimage_verify(data->os);
if (ret) {
printf("Checking data crc failed with %s\n",
@@ -550,6 +564,8 @@ static int bootm_init(void)
globalvar_add_simple("bootm.initrd", NULL);
globalvar_add_simple("bootm.initrd.loadaddr", NULL);
}
+ globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode,
+ bootm_verify_names, ARRAY_SIZE(bootm_verify_names));
return 0;
}