tests: secure_storage: psa: crypto: improve compatibility
The psa_key_attributes_t type is implementation-defined according to the PSA Crypto spec. Compare its fields individually instead of doing a memcmp() over the entire struct. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
This commit is contained in:
parent
62fe34dd02
commit
744e9f70f4
1 changed files with 11 additions and 1 deletions
|
@ -26,6 +26,16 @@ static void fill_key_attributes(psa_key_attributes_t *key_attributes)
|
||||||
psa_set_key_bits(key_attributes, KEY_BITS);
|
psa_set_key_bits(key_attributes, KEY_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void compare_key_attributes(const psa_key_attributes_t *l, const psa_key_attributes_t *r)
|
||||||
|
{
|
||||||
|
zassert_equal(psa_get_key_lifetime(l), psa_get_key_lifetime(r));
|
||||||
|
zassert_equal(psa_get_key_usage_flags(l), psa_get_key_usage_flags(r));
|
||||||
|
zassert_equal(psa_get_key_id(l), psa_get_key_id(r));
|
||||||
|
zassert_equal(psa_get_key_type(l), psa_get_key_type(r));
|
||||||
|
zassert_equal(psa_get_key_algorithm(l), psa_get_key_algorithm(r));
|
||||||
|
zassert_equal(psa_get_key_bits(l), psa_get_key_bits(r));
|
||||||
|
}
|
||||||
|
|
||||||
static void fill_data(uint8_t *data, size_t size)
|
static void fill_data(uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
zassert_equal(psa_generate_random(data, size), PSA_SUCCESS);
|
zassert_equal(psa_generate_random(data, size), PSA_SUCCESS);
|
||||||
|
@ -77,7 +87,7 @@ ZTEST(secure_storage_psa_crypto, test_its_caller_isolation)
|
||||||
|
|
||||||
ret = psa_get_key_attributes(ID, &retrieved_key_attributes);
|
ret = psa_get_key_attributes(ID, &retrieved_key_attributes);
|
||||||
zassert_equal(ret, PSA_SUCCESS);
|
zassert_equal(ret, PSA_SUCCESS);
|
||||||
zassert_mem_equal(&retrieved_key_attributes, &key_attributes, sizeof(key_attributes));
|
compare_key_attributes(&retrieved_key_attributes, &key_attributes);
|
||||||
ret = psa_destroy_key(ID);
|
ret = psa_destroy_key(ID);
|
||||||
zassert_equal(ret, PSA_SUCCESS);
|
zassert_equal(ret, PSA_SUCCESS);
|
||||||
ret = psa_get_key_attributes(ID, &retrieved_key_attributes);
|
ret = psa_get_key_attributes(ID, &retrieved_key_attributes);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue