Place TLV size into TLV itself
To allow the signatures to be replaced, move the size of the TLV into a
small "info" header at the start of the TLV.
Note that this causes image swapping to lose robustness. This is fixed
by a later commit.
Based on work by Marko Kiiskila <marko@runtime.io>
Signed-off-by: Marko Kiiskila <marko@runtime.io>
Signed-off-by: David Brown <david.brown@linaro.org>
JIRA: MCUB-65
diff --git a/scripts/imgtool/image.py b/scripts/imgtool/image.py
index 9a9225f..7eb6c0c 100644
--- a/scripts/imgtool/image.py
+++ b/scripts/imgtool/image.py
@@ -21,6 +21,8 @@
'ECDSA224': 0x21,
'ECDSA256': 0x22, }
+TLV_INFO_SIZE = 4
+TLV_INFO_MAGIC = 0x6907
TLV_HEADER_SIZE = 4
# Sizes of the image trailer, depending on flash write size.
@@ -46,7 +48,8 @@
self.buf += payload
def get(self):
- return bytes(self.buf)
+ header = struct.pack('<HH', TLV_INFO_MAGIC, TLV_INFO_SIZE + len(self.buf))
+ return header + bytes(self.buf)
class Image():
@classmethod