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>
diff --git a/scripts/imgtool/image.py b/scripts/imgtool/image.py
index 5030bb4..257c892 100644
--- a/scripts/imgtool/image.py
+++ b/scripts/imgtool/image.py
@@ -354,7 +354,11 @@
if self.enckey is not None:
pad_len = len(self.payload) % 16
if pad_len > 0:
- self.payload += bytes(16 - pad_len)
+ pad = bytes(16 - pad_len)
+ if isinstance(self.payload, bytes):
+ self.payload += pad
+ else:
+ self.payload.extend(pad)
# This adds the header to the payload as well
self.add_header(enckey, protected_tlv_size)