From 83087efe7197dcae77d94a8ff56e1eb70907aa9e Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 26 Sep 2019 06:52:30 +0200 Subject: img4: Add new TBMDigests key for stashbag local manifest --- src/img4.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/img4.c b/src/img4.c index 06fda7f..c088926 100644 --- a/src/img4.c +++ b/src/img4.c @@ -500,7 +500,7 @@ void _manifest_write_component(unsigned char **p, unsigned int *length, const ch unsigned int inner_length = 0; asn1_write_element(&inner_start, &inner_length, ASN1_IA5_STRING, (void*)tag, -1); - unsigned char tmp_[256] = { 0, }; + unsigned char tmp_[512] = { 0, }; unsigned int tmp_len = 0; unsigned char *tmp = &tmp_[0]; @@ -542,6 +542,25 @@ void _manifest_write_component(unsigned char **p, unsigned int *length, const ch _manifest_write_key_value(&tmp, &tmp_len, "ESEC", ASN1_BOOLEAN, &int_bool_val, -1); } + node = plist_dict_get_item(comp, "TBMDigests"); + if (node) { + char *data = NULL; + uint64_t datalen = 0; + plist_get_data_val(node, &data, &datalen); + const char *tbmtag = NULL; + if (!strcmp(tag, "sepi")) { + tbmtag = "tbms"; + } else if (!strcmp(tag, "rsep")) { + tbmtag = "tbmr"; + } + if (!tbmtag) { + error("ERROR: Unexpected TMBDigests for comp '%s'\n", tag); + } else { + _manifest_write_key_value(&tmp, &tmp_len, tbmtag, ASN1_OCTET_STRING, data, datalen); + } + free(data); + } + asn1_write_element_header(ASN1_SET | ASN1_CONSTRUCTED, tmp_len, &inner_start, &inner_length); memcpy(inner_start, tmp_, tmp_len); inner_start += tmp_len; -- cgit v1.1-32-gdbae