diff options
-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} |