diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-07-05 13:18:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-05 13:18:57 +0000 |
commit | fe10a25f2e22b2f6461bb1736651dd2d81b3db44 (patch) | |
tree | 76c311c0dda9a13f7fada48007c94bd8c8eae005 | |
parent | db1291b1c03c0b2fcaa80fadd74224ca2a5a1376 (diff) | |
parent | 05e7677b9197d3f5ccd1f97b2115b03a0d9b4f89 (diff) | |
download | genimage-fe10a25f2e22b2f6461bb1736651dd2d81b3db44.tar.gz genimage-fe10a25f2e22b2f6461bb1736651dd2d81b3db44.tar.xz |
Merge pull request #65 from Bastian-Krause/bst/rauc-pkcs11
image-rauc: support PKCS#11 URLs for cert/key
-rw-r--r-- | image-rauc.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/image-rauc.c b/image-rauc.c index 79aab10..c4195a3 100644 --- a/image-rauc.c +++ b/image-rauc.c @@ -91,29 +91,36 @@ static int rauc_generate(struct image *image) static int rauc_parse(struct image *image, cfg_t *cfg) { + const char *pkcs11_prefix = "pkcs11:"; unsigned int i; unsigned int num_files; struct partition *part; + char *part_image_key; + char *part_image_cert; - part = xzalloc(sizeof *part); - part->image = cfg_getstr(image->imagesec, "key"); - if (!part->image) { + part_image_key = cfg_getstr(image->imagesec, "key"); + if (!part_image_key) { image_error(image, "Mandatory 'key' option is missing!\n"); - free(part); return -EINVAL; } - part->partition_type = RAUC_KEY; - list_add_tail(&part->list, &image->partitions); + if (strncmp(pkcs11_prefix, part_image_key, strlen(pkcs11_prefix))) { + part = xzalloc(sizeof *part); + part->image = part_image_key; + part->partition_type = RAUC_KEY; + list_add_tail(&part->list, &image->partitions); + } - part = xzalloc(sizeof *part); - part->image = cfg_getstr(image->imagesec, "cert"); - if (!part->image) { + part_image_cert = cfg_getstr(image->imagesec, "cert"); + if (!part_image_cert) { image_error(image, "Mandatory 'cert' option is missing!\n"); - free(part); return -EINVAL; } - part->partition_type = RAUC_CERT; - list_add_tail(&part->list, &image->partitions); + if (strncmp(pkcs11_prefix, part_image_cert, strlen(pkcs11_prefix))) { + part = xzalloc(sizeof *part); + part->image = part_image_cert; + part->partition_type = RAUC_CERT; + list_add_tail(&part->list, &image->partitions); + } num_files = cfg_size(cfg, "file"); for (i = 0; i < num_files; i++) { |