diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2016-10-04 09:48:18 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-14 01:02:18 -0700 |
commit | 6858261b271322e2c1180f563908ac4111e5000f (patch) | |
tree | bc32922efcdfa39a3bed5673e0ea318b1ea70b33 | |
parent | e96e46a5185e9bd9bc758a6757500c5e97dc2829 (diff) | |
download | vboot-6858261b271322e2c1180f563908ac4111e5000f.tar.gz |
bdb: Enable futility show to dump data header info
This change makes futility show command to dump data header information
in a BDB. # of hashes is used to verify 'futility bdb --add' can add a
hash in the unit test.
BUG=chromium:649554
BRANCH=none
TEST=make runtests. run futility show tests/futility/data/bdb.bin
BDB Header:
Struct Version: 0x1:0x0
BDB key digest: c7895611c24efb2249d97376189eeee07def6bcd8ab162a3850d279354f08ddf
size: 1176
Data Header:
Struct Version: 0x1:0x0
# of Hashes: 2
Hash Entry Size:56
Signed Size: 272
Description:
Hash #0:
Offset: 0x2
Size: 35
Partition: 3
Type: 1
Load Address: 0x4
Digest: 72bcf33f448465f035bd58e4b61501db925e67c89feb4a70cb909d8b425861f4
Hash #1:
Offset: 0x2
Size: 35
Partition: 3
Type: 1
Load Address: 0x4
Digest: 72bcf33f448465f035bd58e4b61501db925e67c89feb4a70cb909d8b425861f4
Change-Id: I88934b761236f36a5d607c96f6f2543a62e50b68
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/392949
-rw-r--r-- | futility/bdb_helper.c | 14 | ||||
-rwxr-xr-x | tests/futility/test_bdb.sh | 14 |
2 files changed, 27 insertions, 1 deletions
diff --git a/futility/bdb_helper.c b/futility/bdb_helper.c index ac8012ad..83a57bc6 100644 --- a/futility/bdb_helper.c +++ b/futility/bdb_helper.c @@ -61,6 +61,19 @@ static void show_bdb_header(const uint8_t *bdb) printf(" size: %d\n", key->struct_size); } +static void show_data_header(const uint8_t *bdb) +{ + const struct bdb_data *data = bdb_get_data(bdb); + + printf("Data Header:\n"); + printf(" Struct Version: 0x%x:0x%x\n", + data->struct_major_version, data->struct_minor_version); + printf(" # of Hashes: %d\n", data->num_hashes); + printf(" Hash Entry Size:%d\n", data->hash_entry_size); + printf(" Signed Size: %d\n", data->signed_size); + printf(" Description: %s\n", data->description); +} + static void show_hashes(const uint8_t *bdb) { const struct bdb_data *data = bdb_get_data(bdb); @@ -87,6 +100,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_data_header(buf); show_hashes(buf); return 0; diff --git a/tests/futility/test_bdb.sh b/tests/futility/test_bdb.sh index 426b3970..90151b45 100755 --- a/tests/futility/test_bdb.sh +++ b/tests/futility/test_bdb.sh @@ -21,6 +21,8 @@ BDBKEY_DIGEST=${TESTDATA_DIR}/bdbkey_digest.bin DATAKEY_DIGEST=${TESTDATA_DIR}/datakey_digest.bin DATA_FILE=${TESTDATA_DIR}/sp-rw.bin +declare -i num_hash + # Verify a BDB # # $1: Key digest file @@ -32,6 +34,12 @@ verify() { ${extra_option} } +get_num_hash() { + printf "%d" \ + $(${FUTILITY} show ${BDB_FILE} \ + | grep '# of Hashes' | cut -d':' -f 2) +} + # Demonstrate bdb --create can create a valid BDB ${FUTILITY} bdb --create ${BDB_FILE} \ --bdbkey_pri ${BDBKEY_PRI} --bdbkey_pub ${BDBKEY_PUB} \ @@ -39,9 +47,13 @@ ${FUTILITY} bdb --create ${BDB_FILE} \ verify # Demonstrate bdb --add can add a new hash +num_hash=$(get_num_hash) ${FUTILITY} bdb --add ${BDB_FILE} \ --data ${DATA_FILE} --partition 1 --type 2 --offset 3 --load_address 4 -# TODO: Use futility show command to verify the hash is added +# Use futility show command to verify the hash is added +num_hash+=1 +[ $(get_num_hash) -eq $num_hash ] +# TODO: verify partition, type, offset, and load_address # Demonstrate futility bdb --resign can resign the BDB ${FUTILITY} bdb --resign ${BDB_FILE} --datakey_pri ${DATAKEY_PRI} |