diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2016-10-04 09:48:18 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-17 15:23:09 -0700 |
commit | 8fe8f6ca89c9f6e03486703efd8b2898a8347333 (patch) | |
tree | a353586fc661573345b8fca6dff738857957d5bf | |
parent | 6858261b271322e2c1180f563908ac4111e5000f (diff) | |
download | vboot-8fe8f6ca89c9f6e03486703efd8b2898a8347333.tar.gz |
bdb: Enable futility-show to dump key info
This change makes futility show command dump information of the keys
found in a BDB.
BUG=chromium:649554
BRANCH=none
TEST=make runtests. run futility show tests/futility/data/bdb.bin
Change-Id: I82bb3956b043adf1febe42941618608865525da2
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399059
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | futility/bdb_helper.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/futility/bdb_helper.c b/futility/bdb_helper.c index 83a57bc6..74bdc467 100644 --- a/futility/bdb_helper.c +++ b/futility/bdb_helper.c @@ -46,19 +46,40 @@ static void print_hash_entry(const char *label, const struct bdb_hash *hash) print_digest(" Digest: ", hash->digest, sizeof(hash->digest)); } +static void print_key_info(const char *label, const struct bdb_key *key) +{ + uint8_t digest[BDB_SHA256_DIGEST_SIZE]; + + if (label) + printf("%s", label); + printf(" Struct Version: 0x%x:0x%x\n", + key->struct_major_version, key->struct_minor_version); + printf(" Size: %d\n", key->struct_size); + printf(" Hash Algorithm: %d\n", key->hash_alg); + printf(" Sign Algorithm: %d\n", key->sig_alg); + printf(" Version: %d\n", key->key_version); + printf(" Description: %s\n", key->description); + bdb_sha256(digest, key, key->struct_size); + print_digest(" Digest: ", digest, sizeof(digest)); +} + static void show_bdb_header(const uint8_t *bdb) { const struct bdb_header *header = bdb_get_header(bdb); - const struct bdb_key *key = bdb_get_bdbkey(bdb); - uint8_t digest[BDB_SHA256_DIGEST_SIZE]; printf("BDB Header:\n"); printf(" Struct Version: 0x%x:0x%x\n", header->struct_major_version, header->struct_minor_version); +} - bdb_sha256(digest, key, key->struct_size); - print_digest(" BDB key digest: ", digest, sizeof(digest)); - printf(" size: %d\n", key->struct_size); +static void show_bdbkey_info(const uint8_t *bdb) +{ + print_key_info("BDB key:\n", bdb_get_bdbkey(bdb)); +} + +static void show_datakey_info(const uint8_t *bdb) +{ + print_key_info("Data key:\n", bdb_get_datakey(bdb)); } static void show_data_header(const uint8_t *bdb) @@ -100,6 +121,8 @@ 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_bdbkey_info(buf); + show_datakey_info(buf); show_data_header(buf); show_hashes(buf); |