Merge pull request #20 from rsalveti/zep2newt

zep2newt.py: use /usr/bin/env when searching for python2
diff --git a/boot/bootutil/design.txt b/boot/bootutil/design.txt
index bfa12d2..5d25ec1 100644
--- a/boot/bootutil/design.txt
+++ b/boot/bootutil/design.txt
@@ -84,13 +84,15 @@
 #define IMAGE_F_PKCS15_RSA2048_SHA256 0x00000004 /* PKCS15 w/RSA and SHA */
 #define IMAGE_F_ECDSA224_SHA256       0x00000008 /* ECDSA256 over SHA256 */
 #define IMAGE_F_NON_BOOTABLE          0x00000010 /* Split image app. */
+#define IMAGE_F_ECDSA256_SHA256       0x00000020 /* ECDSA256 over SHA256 */
 
 /*
  * Image trailer TLV types.
  */
-#define IMAGE_TLV_SHA256            1	/* SHA256 of image hdr and body */
-#define IMAGE_TLV_RSA2048           2	/* RSA2048 of hash output */
+#define IMAGE_TLV_SHA256            1   /* SHA256 of image hdr and body */
+#define IMAGE_TLV_RSA2048           2   /* RSA2048 of hash output */
 #define IMAGE_TLV_ECDSA224          3   /* ECDSA of hash output */
+#define IMAGE_TLV_ECDSA256          4   /* ECDSA of hash output */
 
 Optional type-length-value records (TLVs) containing image metadata are placed
 after the end of the image.
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index e94b205..89b4e13 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -506,7 +506,6 @@
           boot_status_internal_off(bs->idx, bs->state, boot_data.write_sz);
 
     align = hal_flash_align(fap->fa_device_id);
-    // ASSERT(align <= 8);
     memset(buf, 0xFF, 8);
     buf[0] = bs->state;
 
@@ -580,22 +579,20 @@
         return -1;
     }
 
-    /* Image in slot 1 is invalid.  Erase the image and continue booting
-     * from slot 0.
-     */
     rc = flash_area_open(flash_area_id_from_image_slot(slot), &fap);
     if (rc != 0) {
         return BOOT_EFLASH;
     }
 
     if ((boot_data.imgs[slot].hdr.ih_magic != IMAGE_MAGIC ||
-	 boot_image_check(&boot_data.imgs[slot].hdr, fap) != 0) &&
-	slot == 1) {
+         boot_image_check(&boot_data.imgs[slot].hdr, fap) != 0)) {
 
-        /* Image in slot 1 is invalid.  Erase the image and continue booting
-         * from slot 0.
-         */
-        flash_area_erase(fap, 0, fap->fa_size);
+        if (slot != 0) {
+            flash_area_erase(fap, 0, fap->fa_size);
+            /* Image in slot 1 is invalid. Erase the image and
+             * continue booting from slot 0.
+             */
+        }
         return -1;
     }
 
@@ -790,7 +787,7 @@
  *
  * @return                      0 on success; nonzero on failure.
  */
-static int
+static void
 boot_swap_sectors(int idx, uint32_t sz, struct boot_status *bs)
 {
     uint32_t copy_sz;
@@ -803,24 +800,19 @@
 
     if (bs->state == 0) {
         rc = boot_erase_sector(FLASH_AREA_IMAGE_SCRATCH, 0, sz);
-        if (rc != 0) {
-            return rc;
-        }
+        assert(rc == 0);
 
         rc = boot_copy_sector(FLASH_AREA_IMAGE_1, FLASH_AREA_IMAGE_SCRATCH,
                               img_off, 0, sz);
-        if (rc != 0) {
-            return rc;
-        }
+        assert(rc == 0);
 
         bs->state = 1;
-        (void)boot_write_status(bs);
+        rc = boot_write_status(bs);
+        assert(rc == 0);
     }
     if (bs->state == 1) {
         rc = boot_erase_sector(FLASH_AREA_IMAGE_1, img_off, sz);
-        if (rc != 0) {
-            return rc;
-        }
+        assert(rc == 0);
 
         copy_sz = sz;
         if (boot_data.imgs[0].sectors[idx].fa_off + sz >=
@@ -834,31 +826,25 @@
 
         rc = boot_copy_sector(FLASH_AREA_IMAGE_0, FLASH_AREA_IMAGE_1,
                               img_off, img_off, copy_sz);
-        if (rc != 0) {
-            return rc;
-        }
+        assert(rc == 0);
 
         bs->state = 2;
-        (void)boot_write_status(bs);
+        rc = boot_write_status(bs);
+        assert(rc == 0);
     }
     if (bs->state == 2) {
         rc = boot_erase_sector(FLASH_AREA_IMAGE_0, img_off, sz);
-        if (rc != 0) {
-            return rc;
-        }
+        assert(rc == 0);
 
         rc = boot_copy_sector(FLASH_AREA_IMAGE_SCRATCH, FLASH_AREA_IMAGE_0,
                               0, img_off, sz);
-        if (rc != 0) {
-            return rc;
-        }
+        assert(rc == 0);
 
         bs->idx++;
         bs->state = 0;
-        (void)boot_write_status(bs);
+        rc = boot_write_status(bs);
+        assert(rc == 0);
     }
-
-    return 0;
 }
 
 /**