diff options
author | danh-arm <dan.handley@arm.com> | 2016-09-19 11:54:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-19 11:54:27 +0100 |
commit | 368d4ebfc1682bfeea1057f7f37c23ca531e9e91 (patch) | |
tree | 43a560b5a3eedd1154e7b5a44a9f7378cf96f393 /tools/fiptool/fiptool.c | |
parent | a8de89c97461b7cc13a596db8771c30843b06405 (diff) | |
parent | 9df69ba37f3dd3a3f02fc8c0ba41236960b6b771 (diff) |
Merge pull request #701 from dp-arm/dp/fiptool-sha256
fiptool: Add support for printing the sha256 digest with info command
Diffstat (limited to 'tools/fiptool/fiptool.c')
-rw-r--r-- | tools/fiptool/fiptool.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c index 68ddcf5a..6a3406e0 100644 --- a/tools/fiptool/fiptool.c +++ b/tools/fiptool/fiptool.c @@ -42,6 +42,8 @@ #include <string.h> #include <unistd.h> +#include <openssl/sha.h> + #include "fiptool.h" #include "firmware_image_package.h" #include "tbbr_config.h" @@ -354,6 +356,14 @@ static void add_opt(struct option *opts, int idx, char *name, opts[idx].val = val; } +static void md_print(unsigned char *md, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + printf("%02x", md[i]); +} + static int info_cmd(int argc, char *argv[]) { image_t *image; @@ -391,10 +401,16 @@ static int info_cmd(int argc, char *argv[]) (unsigned long long)image_offset, (unsigned long long)image_size); if (image->toc_entry != NULL) - printf(", cmdline=\"--%s\"\n", + printf(", cmdline=\"--%s\"", image->toc_entry->cmdline_name); - else - putchar('\n'); + if (verbose) { + unsigned char md[SHA256_DIGEST_LENGTH]; + + SHA256(image->buffer, image_size, md); + printf(", sha256="); + md_print(md, sizeof(md)); + } + putchar('\n'); image_offset += image_size; } |