summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2016-09-27 08:55:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-10-14 01:02:16 -0700
commite96e46a5185e9bd9bc758a6757500c5e97dc2829 (patch)
tree0836c1e0d45be790394b54fce2915de6f3db881b
parentfb267154d29356937eb304234793ab2e28ad0bab (diff)
downloadvboot-e96e46a5185e9bd9bc758a6757500c5e97dc2829.tar.gz
bdb: Enable futility-show to dump hash info
This patch makes futility show command print out hash information. BUG=chromium:649555 BRANCH=none TEST=make runtests. Ran futility show tests/futility/data/bdb.bin. Change-Id: I4d0e933b7b9dca6548aa8488d9ca85b8692a5d49 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/392948
-rw-r--r--futility/bdb_helper.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/futility/bdb_helper.c b/futility/bdb_helper.c
index d2f428c8..ac8012ad 100644
--- a/futility/bdb_helper.c
+++ b/futility/bdb_helper.c
@@ -5,6 +5,7 @@
* Boot descriptor block helper functions
*/
+#include <inttypes.h>
#include <stdio.h>
#include "2sha.h"
@@ -33,6 +34,18 @@ static void print_digest(const char *label, const uint8_t *digest, size_t size)
printf("\n");
}
+static void print_hash_entry(const char *label, const struct bdb_hash *hash)
+{
+ if (label)
+ printf("%s", label);
+ printf(" Offset: 0x%" PRIx64 "\n", hash->offset);
+ printf(" Size: %d\n", hash->size);
+ printf(" Partition: %d\n", hash->partition);
+ printf(" Type: %d\n", hash->type);
+ printf(" Load Address: 0x%" PRIx64 "\n", hash->load_address);
+ print_digest(" Digest: ", hash->digest, sizeof(hash->digest));
+}
+
static void show_bdb_header(const uint8_t *bdb)
{
const struct bdb_header *header = bdb_get_header(bdb);
@@ -48,6 +61,17 @@ static void show_bdb_header(const uint8_t *bdb)
printf(" size: %d\n", key->struct_size);
}
+static void show_hashes(const uint8_t *bdb)
+{
+ const struct bdb_data *data = bdb_get_data(bdb);
+ int i;
+
+ for (i = 0; i < data->num_hashes; i++) {
+ const struct bdb_hash *hash = bdb_get_hash_by_index(bdb, i);
+ printf("Hash #%d:\n", i);
+ print_hash_entry(NULL, hash);
+ }
+}
int ft_show_bdb(const char *name, uint8_t *buf, uint32_t len, void *data)
{
@@ -63,6 +87,7 @@ int ft_show_bdb(const char *name, uint8_t *buf, uint32_t len, void *data)
printf("Boot Descriptor Block: %s\n", name);
show_bdb_header(buf);
+ show_hashes(buf);
return 0;
}