mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-15 19:20:55 +00:00
Strengthen psa_mac_verify testing
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
0c38385858
commit
d2c9f6d256
@ -62,10 +62,16 @@ void hmac(int alg_arg, char *input, data_t *expected_mac)
|
||||
size_t input_len = strlen(input);
|
||||
PSA_ASSERT(psa_mac_compute(key, alg, (uint8_t const *) input, input_len, mac, sizeof(mac), &mac_length));
|
||||
|
||||
// manual comparison against expected MAC
|
||||
ASSERT_COMPARE(expected_mac->x, expected_mac->len, mac, mac_length);
|
||||
|
||||
// use psa_mac_verify to compare to expected MAC
|
||||
PSA_ASSERT(psa_mac_verify(key, alg, (uint8_t const *) input, input_len, expected_mac->x, expected_mac->len));
|
||||
|
||||
// corrupt the MAC and check that psa_mac_verify fails
|
||||
expected_mac->x[0] ^= 0x7f;
|
||||
TEST_EQUAL(psa_mac_verify(key, alg, (uint8_t const *) input, input_len, expected_mac->x, expected_mac->len), PSA_ERROR_INVALID_SIGNATURE);
|
||||
|
||||
PSA_ASSERT(psa_destroy_key(key));
|
||||
exit:
|
||||
PSA_DONE();
|
||||
|
Loading…
x
Reference in New Issue
Block a user