Commit c94591e7 authored by Fabio Utzig's avatar Fabio Utzig Committed by David Brown
Browse files

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: default avatarFabio Utzig <utzig@apache.org>
Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent 56ede834
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -352,7 +352,11 @@ class Image():
        if self.enckey is not None:
        if self.enckey is not None:
            pad_len = len(self.payload) % 16
            pad_len = len(self.payload) % 16
            if pad_len > 0:
            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
        # This adds the header to the payload as well
        self.add_header(enckey, protected_tlv_size)
        self.add_header(enckey, protected_tlv_size)