summaryrefslogtreecommitdiff
path: root/utils/imxtools/sbtools/sb.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/imxtools/sbtools/sb.c')
-rw-r--r--utils/imxtools/sbtools/sb.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/utils/imxtools/sbtools/sb.c b/utils/imxtools/sbtools/sb.c
index ff8e0da..cbeacf9 100644
--- a/utils/imxtools/sbtools/sb.c
+++ b/utils/imxtools/sbtools/sb.c
@@ -802,7 +802,11 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, unsigned flags, vo
if(memcmp(hdr_sha1, computed_sha1, 20) == 0)
printf(RED, " Ok\n");
else
+ {
printf(RED, " Failed\n");
+ if(!(flags & SB_IGNORE_SHA1))
+ fatal(SB_FORMAT_ERROR, "Bad header checksum\n");
+ }
printf(GREEN, " Flags: ");
printf(YELLOW, "%x\n", sb_header->flags);
printf(GREEN, " Total file size : ");
@@ -1045,7 +1049,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, unsigned flags, vo
printf(OFF, "%s", indent);
uint8_t checksum = instruction_checksum(hdr);
if(checksum != hdr->checksum)
- printf(GREY, "[Bad checksum']");
+ printf(GREY, "[Bad checksum]");
if(hdr->opcode == SB_INST_NOP)
{
@@ -1093,6 +1097,14 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, unsigned flags, vo
printf(RED, " (Encrypted)");
printf(OFF, "\n");
+ /* skip it if we cannot decrypt it */
+ if(encrypted && !valid_key)
+ {
+ printf(GREY, " Skipping section content (no valid key)\n");
+ offset += size;
+ continue;
+ }
+
/* save it */
byte *sec = xmalloc(size);
if(encrypted)
@@ -1161,7 +1173,7 @@ struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, unsigned flags, vo
else if(flags & SB_IGNORE_SHA1)
{
/* some weird images produced by some buggy tools have wrong SHA-1,
- * this probably gone unnoticed because the bootloader ignores the SH1-1
+ * this probably gone unnoticed because the bootloader ignores the SHA-1
* anyway */
printf(RED, " Failed\n");
cprintf(u, true, GREY, "Warning: SHA-1 mismatch ignored per flags\n");