summaryrefslogtreecommitdiff
path: root/tests/vb2_sha_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vb2_sha_tests.c')
-rw-r--r--tests/vb2_sha_tests.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/vb2_sha_tests.c b/tests/vb2_sha_tests.c
index c3185cac..94236355 100644
--- a/tests/vb2_sha_tests.c
+++ b/tests/vb2_sha_tests.c
@@ -50,13 +50,18 @@ void sha256_tests(void)
uint8_t digest[VB2_SHA256_DIGEST_SIZE];
uint8_t *test_inputs[3];
struct vb2_sha256_context ctx;
- uint8_t expect_multiple[VB2_SHA256_DIGEST_SIZE] =
- {
+ const uint8_t expect_multiple[VB2_SHA256_DIGEST_SIZE] = {
0x07, 0x08, 0xb4, 0xca, 0x46, 0x4c, 0x40, 0x39,
0x07, 0x06, 0x88, 0x80, 0x30, 0x55, 0x5d, 0x86,
0x0e, 0x4a, 0x0d, 0x2b, 0xc6, 0xc4, 0x87, 0x39,
- 0x2c, 0x16, 0x55, 0xb0, 0x82, 0x13, 0x16, 0x29
- };
+ 0x2c, 0x16, 0x55, 0xb0, 0x82, 0x13, 0x16, 0x29 };
+ const uint8_t extend_from[VB2_SHA256_DIGEST_SIZE] = { 0x00, };
+ const uint8_t extend_by[VB2_SHA256_BLOCK_SIZE] = { 0x00, };
+ const uint8_t expected_extend[VB2_SHA256_DIGEST_SIZE] = {
+ 0x7c, 0xa5, 0x16, 0x14, 0x42, 0x5c, 0x3b, 0xa8, 0xce, 0x54,
+ 0xdd, 0x2f, 0xc2, 0x02, 0x0a, 0xe7, 0xb6, 0xe5, 0x74, 0xd1,
+ 0x98, 0x13, 0x6d, 0x0f, 0xae, 0x7e, 0x26, 0xcc, 0xbf, 0x0b,
+ 0xe7, 0xa6 };
int i;
test_inputs[0] = (uint8_t *) oneblock_msg;
@@ -90,6 +95,10 @@ void sha256_tests(void)
TEST_EQ(vb2_hash_block_size(VB2_HASH_SHA256), VB2_SHA256_BLOCK_SIZE,
"vb2_hash_block_size(VB2_HASH_SHA256)");
+
+ /* Test SHA256 hash extend */
+ vb2_sha256_extend(extend_from, extend_by, digest);
+ TEST_SUCC(memcmp(digest, expected_extend, sizeof(digest)), NULL);
}
void sha512_tests(void)