image encryption: fix enc_state array indexing for zephyr
enc_state table was indexed with assumption that
image flash area are subsequent and increasing numbers.
It might not be true while building zephyr.
Patch introduce flash_area_id_to_image_slot() implementation for
the zephyr port and uses it to assign proper slot number.
This API is already available in MyNewt.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/sim/mcuboot-sys/csupport/run.c b/sim/mcuboot-sys/csupport/run.c
index eb5b155..fdee14c 100644
--- a/sim/mcuboot-sys/csupport/run.c
+++ b/sim/mcuboot-sys/csupport/run.c
@@ -384,6 +384,19 @@
return 0;
}
+int flash_area_id_to_image_slot(int area_id)
+{
+ switch (area_id) {
+ case FLASH_AREA_IMAGE_PRIMARY:
+ return 0;
+ case FLASH_AREA_IMAGE_SECONDARY:
+ return 1;
+ default:
+ printf("Unsupported image area ID\n");
+ abort();
+ }
+}
+
void sim_assert(int x, const char *assertion, const char *file, unsigned int line, const char *function)
{
if (!(x)) {