test_suite_psa_crypto_storage_format: improve input bit length specification for static key buffer

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti 2024-08-16 12:43:47 +02:00
parent ba98d5b90e
commit 9e154debfb
2 changed files with 7 additions and 7 deletions

View File

@ -305,17 +305,17 @@ void key_storage_read(int lifetime_arg, int type_arg, int bits_arg,
/* Create a persistent key which is intentionally larger than the specified
* bit size. */
if (flags & TEST_FLAG_OVERSIZED_KEY) {
TEST_CALLOC(custom_key_data, PSA_BITS_TO_BYTES(bits) + 1);
memset(custom_key_data, 0xAA, PSA_BITS_TO_BYTES(bits) + 1);
material->len = PSA_BITS_TO_BYTES(bits) + 1;
TEST_CALLOC(custom_key_data, PSA_BITS_TO_BYTES(bits));
memset(custom_key_data, 0xAA, PSA_BITS_TO_BYTES(bits));
material->len = PSA_BITS_TO_BYTES(bits);
material->x = custom_key_data;
/* 36 bytes are the overhead of psa_persistent_key_storage_format */
TEST_CALLOC(custom_storage_data, PSA_BITS_TO_BYTES(bits) + 1 + 36);
representation->len = PSA_BITS_TO_BYTES(bits) + 1 + 36;
TEST_CALLOC(custom_storage_data, PSA_BITS_TO_BYTES(bits) + 36);
representation->len = PSA_BITS_TO_BYTES(bits) + 36;
representation->x = custom_storage_data;
psa_format_key_data_for_storage(custom_key_data, PSA_BITS_TO_BYTES(bits) + 1,
psa_format_key_data_for_storage(custom_key_data, PSA_BITS_TO_BYTES(bits),
&attributes, custom_storage_data);
}

View File

@ -14,4 +14,4 @@ key_storage_save:PSA_KEY_LIFETIME_PERSISTENT:PSA_KEY_TYPE_AES:128:PSA_KEY_USAGE_
# so that when psa_get_key_attributes() tries to load it from the storage it will fail.
PSA storage read: key larger than MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
depends_on:PSA_WANT_KEY_TYPE_RAW_DATA:MBEDTLS_PSA_STATIC_KEY_SLOTS
key_storage_read:PSA_KEY_LIFETIME_PERSISTENT:PSA_KEY_TYPE_RAW_DATA:MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE*8:PSA_KEY_USAGE_EXPORT:PSA_ALG_NONE:PSA_ALG_NONE:"":"":TEST_FLAG_OVERSIZED_KEY
key_storage_read:PSA_KEY_LIFETIME_PERSISTENT:PSA_KEY_TYPE_RAW_DATA:PSA_BYTES_TO_BITS(MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE + 1):PSA_KEY_USAGE_EXPORT:PSA_ALG_NONE:PSA_ALG_NONE:"":"":TEST_FLAG_OVERSIZED_KEY