Change the image header magic

Since we've changed the meaning of several fields in the header, bump
the header to a new magic number.  The fields that are still present are
in the same place, but all of the signature and TLV information is moved
into the TLV itself, which is still immediately after the image.

As of this commit, this defines the new image header/TLV format used for
1.0.

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>
diff --git a/boot/bootutil/include/bootutil/image.h b/boot/bootutil/include/bootutil/image.h
index 35a8321..2ff8902 100644
--- a/boot/bootutil/include/bootutil/image.h
+++ b/boot/bootutil/include/bootutil/image.h
@@ -28,7 +28,8 @@
 
 struct flash_area;
 
-#define IMAGE_MAGIC                 0x96f3b83c
+#define IMAGE_MAGIC                 0x96f3b83d
+#define IMAGE_MAGIC_V1              0x96f3b83c
 #define IMAGE_MAGIC_NONE            0xffffffff
 #define IMAGE_TLV_INFO_MAGIC        0x6907
 
@@ -71,9 +72,7 @@
 /** Image header.  All fields are in little endian byte order. */
 struct image_header {
     uint32_t ih_magic;
-    uint16_t _pad00;
-    uint8_t  _pad0;
-    uint8_t  _pad1;
+    uint32_t _pad1;
     uint16_t ih_hdr_size; /* Size of image header (bytes). */
     uint16_t _pad2;
     uint32_t ih_img_size; /* Does not include header. */
diff --git a/scripts/imgtool/image.py b/scripts/imgtool/image.py
index 7eb6c0c..358b1f2 100644
--- a/scripts/imgtool/image.py
+++ b/scripts/imgtool/image.py
@@ -6,7 +6,7 @@
 import hashlib
 import struct
 
-IMAGE_MAGIC = 0x96f3b83c
+IMAGE_MAGIC = 0x96f3b83d
 IMAGE_HEADER_SIZE = 32
 
 # Image header flags.
diff --git a/sim/src/main.rs b/sim/src/main.rs
index 9e38172..713bb52 100644
--- a/sim/src/main.rs
+++ b/sim/src/main.rs
@@ -750,7 +750,7 @@
 
     // Generate a boot header.  Note that the size doesn't include the header.
     let header = ImageHeader {
-        magic: 0x96f3b83c,
+        magic: 0x96f3b83d,
         tlv_size: tlv.get_size(),
         _pad1: 0,
         hdr_size: 32,