Skip to content

Commit c94591e

Browse files
utzigd3zd3z
authored andcommitted
imgtool: fix encrypting hex images
Fixes padding hex images when encrypting. The issues stems from binaries using `bytes` and IntelHex returning `array` where `bytes` cannot be appended to, so use `.extend()` instead. Signed-off-by: Fabio Utzig <utzig@apache.org> Signed-off-by: David Brown <david.brown@linaro.org>
1 parent 56ede83 commit c94591e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/imgtool/image.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ def create(self, key, public_key_format, enckey, dependencies=None,
352352
if self.enckey is not None:
353353
pad_len = len(self.payload) % 16
354354
if pad_len > 0:
355-
self.payload += bytes(16 - pad_len)
355+
pad = bytes(16 - pad_len)
356+
if isinstance(self.payload, bytes):
357+
self.payload += pad
358+
else:
359+
self.payload.extend(pad)
356360

357361
# This adds the header to the payload as well
358362
self.add_header(enckey, protected_tlv_size)

0 commit comments

Comments
 (0)