2018-06-18 18:27:26 +02:00
|
|
|
/* BEGIN_HEADER */
|
2019-09-09 18:22:50 +02:00
|
|
|
|
|
|
|
/* The tests in this module verify the contents of key store files. They
|
|
|
|
* access internal key storage functions directly. Some of the tests depend
|
2022-12-04 18:19:59 +01:00
|
|
|
* on the storage format. On the other hand, these tests treat the storage
|
2019-09-09 18:22:50 +02:00
|
|
|
* subsystem as a black box, and in particular have no reliance on the
|
|
|
|
* internals of the ITS implementation.
|
2022-06-20 19:10:35 +02:00
|
|
|
*
|
|
|
|
* Note that if you need to make a change that affects how files are
|
|
|
|
* stored, this may indicate that the key store is changing in a
|
|
|
|
* backward-incompatible way! Think carefully about backward compatibility
|
|
|
|
* before changing how test data is constructed or validated.
|
2019-09-09 18:22:50 +02:00
|
|
|
*/
|
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
#include <stdint.h>
|
2019-05-23 20:25:48 +02:00
|
|
|
|
2020-10-29 15:26:43 +01:00
|
|
|
#include "psa_crypto_slot_management.h"
|
2018-06-18 18:27:26 +02:00
|
|
|
#include "psa_crypto_storage.h"
|
2019-05-23 20:25:48 +02:00
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
#define PSA_KEY_STORAGE_MAGIC_HEADER "PSA\0KEY"
|
2023-01-11 14:50:10 +01:00
|
|
|
#define PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH (sizeof(PSA_KEY_STORAGE_MAGIC_HEADER))
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2019-09-09 18:22:50 +02:00
|
|
|
/* Enforce the storage format for keys. The storage format is not a public
|
|
|
|
* documented interface, but it must be preserved between versions so that
|
|
|
|
* upgrades work smoothly, so it's a stable interface nonetheless.
|
|
|
|
*/
|
2018-06-18 18:27:26 +02:00
|
|
|
typedef struct {
|
|
|
|
uint8_t magic[PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH];
|
|
|
|
uint8_t version[4];
|
2023-01-11 14:50:10 +01:00
|
|
|
uint8_t lifetime[sizeof(psa_key_lifetime_t)];
|
2019-12-04 17:18:41 +01:00
|
|
|
uint8_t type[4];
|
2023-01-11 14:50:10 +01:00
|
|
|
uint8_t policy[sizeof(psa_key_policy_t)];
|
2018-06-18 18:27:26 +02:00
|
|
|
uint8_t data_len[4];
|
|
|
|
uint8_t key_data[];
|
|
|
|
} psa_persistent_key_storage_format;
|
2018-11-07 17:05:30 +01:00
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
/* END_HEADER */
|
|
|
|
|
|
|
|
/* BEGIN_DEPENDENCIES
|
|
|
|
* depends_on:MBEDTLS_PSA_CRYPTO_C:MBEDTLS_PSA_CRYPTO_STORAGE_C
|
|
|
|
* END_DEPENDENCIES
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void format_storage_data_check(data_t *key_data,
|
|
|
|
data_t *expected_file_data,
|
|
|
|
int key_lifetime, int key_type, int key_bits,
|
|
|
|
int key_usage, int key_alg, int key_alg2)
|
2018-06-18 18:27:26 +02:00
|
|
|
{
|
2019-12-02 20:50:16 +01:00
|
|
|
uint8_t *file_data = NULL;
|
|
|
|
size_t file_data_length =
|
2023-01-11 14:50:10 +01:00
|
|
|
key_data->len + sizeof(psa_persistent_key_storage_format);
|
2019-07-23 11:58:03 +02:00
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_set_key_lifetime(&attributes, key_lifetime);
|
|
|
|
psa_set_key_type(&attributes, key_type);
|
|
|
|
psa_set_key_bits(&attributes, key_bits);
|
|
|
|
psa_set_key_usage_flags(&attributes, key_usage);
|
|
|
|
psa_set_key_algorithm(&attributes, key_alg);
|
|
|
|
psa_set_key_enrollment_algorithm(&attributes, key_alg2);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-07-21 12:31:13 +02:00
|
|
|
TEST_CALLOC(file_data, file_data_length);
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_format_key_data_for_storage(key_data->x, key_data->len,
|
|
|
|
&attributes.core,
|
|
|
|
file_data);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
TEST_MEMORY_COMPARE(expected_file_data->x, expected_file_data->len,
|
2023-07-27 15:17:27 +02:00
|
|
|
file_data, file_data_length);
|
2019-12-02 20:50:16 +01:00
|
|
|
|
|
|
|
exit:
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_free(file_data);
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void parse_storage_data_check(data_t *file_data,
|
|
|
|
data_t *expected_key_data,
|
|
|
|
int expected_key_lifetime,
|
|
|
|
int expected_key_type,
|
|
|
|
int expected_key_bits,
|
|
|
|
int expected_key_usage,
|
|
|
|
int expected_key_alg,
|
|
|
|
int expected_key_alg2,
|
|
|
|
int expected_status)
|
2018-06-18 18:27:26 +02:00
|
|
|
{
|
|
|
|
uint8_t *key_data = NULL;
|
|
|
|
size_t key_data_length = 0;
|
2019-07-23 11:58:03 +02:00
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
psa_status_t status;
|
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
status = psa_parse_key_data_from_storage(file_data->x, file_data->len,
|
|
|
|
&key_data, &key_data_length,
|
|
|
|
&attributes.core);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_EQUAL(status, expected_status);
|
|
|
|
if (status != PSA_SUCCESS) {
|
2018-06-18 18:27:26 +02:00
|
|
|
goto exit;
|
2023-01-11 14:50:10 +01:00
|
|
|
}
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_EQUAL(psa_get_key_lifetime(&attributes),
|
|
|
|
(psa_key_type_t) expected_key_lifetime);
|
|
|
|
TEST_EQUAL(psa_get_key_type(&attributes),
|
|
|
|
(psa_key_type_t) expected_key_type);
|
|
|
|
TEST_EQUAL(psa_get_key_bits(&attributes),
|
|
|
|
(psa_key_bits_t) expected_key_bits);
|
|
|
|
TEST_EQUAL(psa_get_key_usage_flags(&attributes),
|
|
|
|
(uint32_t) expected_key_usage);
|
|
|
|
TEST_EQUAL(psa_get_key_algorithm(&attributes),
|
|
|
|
(uint32_t) expected_key_alg);
|
|
|
|
TEST_EQUAL(psa_get_key_enrollment_algorithm(&attributes),
|
|
|
|
(uint32_t) expected_key_alg2);
|
2023-07-21 12:40:20 +02:00
|
|
|
TEST_MEMORY_COMPARE(expected_key_data->x, expected_key_data->len,
|
2023-07-27 15:17:27 +02:00
|
|
|
key_data, key_data_length);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
exit:
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_free(key_data);
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void save_large_persistent_key(int data_length_arg, int expected_status)
|
2018-06-18 18:27:26 +02:00
|
|
|
{
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make(1, 42);
|
2018-06-18 18:27:26 +02:00
|
|
|
uint8_t *data = NULL;
|
2019-07-30 17:26:54 +02:00
|
|
|
size_t data_length = data_length_arg;
|
2019-04-19 14:06:53 +02:00
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-07-21 12:31:13 +02:00
|
|
|
TEST_CALLOC(data, data_length);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_set_key_id(&attributes, key_id);
|
|
|
|
psa_set_key_type(&attributes, PSA_KEY_TYPE_RAW_DATA);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_EQUAL(psa_import_key(&attributes, data, data_length, &key_id),
|
|
|
|
expected_status);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
if (expected_status == PSA_SUCCESS) {
|
|
|
|
PSA_ASSERT(psa_destroy_key(key_id));
|
|
|
|
}
|
2019-05-28 14:08:50 +02:00
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
exit:
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_free(data);
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_destroy_persistent_key(key_id);
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void persistent_key_destroy(int owner_id_arg, int key_id_arg, int restart,
|
|
|
|
int first_type_arg, data_t *first_data,
|
|
|
|
int second_type_arg, data_t *second_data)
|
2018-06-18 18:27:26 +02:00
|
|
|
{
|
2020-07-28 15:06:14 +02:00
|
|
|
mbedtls_svc_key_id_t key_id =
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_svc_key_id_make(owner_id_arg, key_id_arg);
|
2020-08-04 14:58:35 +02:00
|
|
|
mbedtls_svc_key_id_t returned_key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
psa_key_type_t first_type = (psa_key_type_t) first_type_arg;
|
|
|
|
psa_key_type_t second_type = (psa_key_type_t) second_type_arg;
|
2019-04-19 14:06:53 +02:00
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_set_key_id(&attributes, key_id);
|
|
|
|
psa_set_key_type(&attributes, first_type);
|
2018-12-03 17:05:18 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_import_key(&attributes, first_data->x, first_data->len,
|
|
|
|
&returned_key_id));
|
2019-04-19 14:06:53 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
if (restart) {
|
|
|
|
psa_close_key(key_id);
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_EQUAL(psa_is_key_present_in_storage(key_id), 1);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
/* Destroy the key */
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_destroy_key(key_id));
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
/* Check key slot storage is removed */
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_EQUAL(psa_is_key_present_in_storage(key_id), 0);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
/* Shutdown and restart */
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2018-12-03 17:05:18 +01:00
|
|
|
/* Create another key in the same slot */
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_set_key_id(&attributes, key_id);
|
|
|
|
psa_set_key_type(&attributes, second_type);
|
|
|
|
PSA_ASSERT(psa_import_key(&attributes, second_data->x, second_data->len,
|
|
|
|
&returned_key_id));
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_destroy_key(key_id));
|
2019-05-28 14:08:50 +02:00
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
exit:
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_destroy_persistent_key(key_id);
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void persistent_key_import(int owner_id_arg, int key_id_arg, int type_arg,
|
|
|
|
data_t *data, int restart, int expected_status)
|
2018-06-18 18:27:26 +02:00
|
|
|
{
|
2020-07-28 15:06:14 +02:00
|
|
|
mbedtls_svc_key_id_t key_id =
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_svc_key_id_make(owner_id_arg, key_id_arg);
|
2020-08-04 14:58:35 +02:00
|
|
|
mbedtls_svc_key_id_t returned_key_id;
|
2018-06-18 18:27:26 +02:00
|
|
|
psa_key_type_t type = (psa_key_type_t) type_arg;
|
2019-04-19 14:06:53 +02:00
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_set_key_id(&attributes, key_id);
|
|
|
|
psa_set_key_type(&attributes, type);
|
|
|
|
TEST_EQUAL(psa_import_key(&attributes, data->x, data->len, &returned_key_id),
|
|
|
|
expected_status);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
if (expected_status != PSA_SUCCESS) {
|
|
|
|
TEST_ASSERT(mbedtls_svc_key_id_is_null(returned_key_id));
|
|
|
|
TEST_EQUAL(psa_is_key_present_in_storage(key_id), 0);
|
2018-06-18 18:27:26 +02:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_ASSERT(mbedtls_svc_key_id_equal(returned_key_id, key_id));
|
2020-08-04 14:58:35 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
if (restart) {
|
|
|
|
PSA_ASSERT(psa_purge_key(key_id));
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2019-04-19 15:40:00 +02:00
|
|
|
}
|
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_reset_key_attributes(&attributes);
|
|
|
|
PSA_ASSERT(psa_get_key_attributes(key_id, &attributes));
|
|
|
|
TEST_ASSERT(mbedtls_svc_key_id_equal(psa_get_key_id(&attributes),
|
|
|
|
key_id));
|
|
|
|
TEST_EQUAL(psa_get_key_lifetime(&attributes),
|
|
|
|
PSA_KEY_LIFETIME_PERSISTENT);
|
|
|
|
TEST_EQUAL(psa_get_key_type(&attributes), type);
|
|
|
|
TEST_EQUAL(psa_get_key_usage_flags(&attributes), 0);
|
|
|
|
TEST_EQUAL(psa_get_key_algorithm(&attributes), 0);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_destroy_key(key_id));
|
2019-05-28 14:08:50 +02:00
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
exit:
|
2020-11-19 17:55:23 +01:00
|
|
|
/*
|
|
|
|
* Key attributes may have been returned by psa_get_key_attributes()
|
|
|
|
* thus reset them as required.
|
|
|
|
*/
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_reset_key_attributes(&attributes);
|
2020-11-19 17:55:23 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_destroy_persistent_key(key_id);
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void import_export_persistent_key(data_t *data, int type_arg,
|
|
|
|
int expected_bits,
|
|
|
|
int restart, int key_not_exist)
|
2018-06-18 18:27:26 +02:00
|
|
|
{
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make(1, 42);
|
2018-06-18 18:27:26 +02:00
|
|
|
psa_key_type_t type = (psa_key_type_t) type_arg;
|
2020-08-04 14:58:35 +02:00
|
|
|
mbedtls_svc_key_id_t returned_key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
unsigned char *exported = NULL;
|
|
|
|
size_t export_size = data->len;
|
|
|
|
size_t exported_length;
|
2019-04-19 14:06:53 +02:00
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-07-21 12:31:13 +02:00
|
|
|
TEST_CALLOC(exported, export_size);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_set_key_id(&attributes, key_id);
|
|
|
|
psa_set_key_type(&attributes, type);
|
|
|
|
psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_EXPORT);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
/* Import the key */
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_import_key(&attributes, data->x, data->len,
|
|
|
|
&returned_key_id));
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2019-04-19 15:40:00 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
if (restart) {
|
|
|
|
PSA_ASSERT(psa_purge_key(key_id));
|
2019-05-28 15:10:21 +02:00
|
|
|
PSA_DONE();
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
2019-04-19 15:40:00 +02:00
|
|
|
}
|
|
|
|
|
2018-06-18 18:27:26 +02:00
|
|
|
/* Test the key information */
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_reset_key_attributes(&attributes);
|
|
|
|
PSA_ASSERT(psa_get_key_attributes(key_id, &attributes));
|
|
|
|
TEST_ASSERT(mbedtls_svc_key_id_equal(
|
|
|
|
psa_get_key_id(&attributes), key_id));
|
|
|
|
TEST_EQUAL(psa_get_key_lifetime(&attributes),
|
|
|
|
PSA_KEY_LIFETIME_PERSISTENT);
|
|
|
|
TEST_EQUAL(psa_get_key_type(&attributes), type);
|
|
|
|
TEST_EQUAL(psa_get_key_bits(&attributes), (size_t) expected_bits);
|
|
|
|
TEST_EQUAL(psa_get_key_usage_flags(&attributes), PSA_KEY_USAGE_EXPORT);
|
|
|
|
TEST_EQUAL(psa_get_key_algorithm(&attributes), 0);
|
|
|
|
|
|
|
|
TEST_EQUAL(psa_is_key_present_in_storage(key_id), 1);
|
|
|
|
|
|
|
|
if (key_not_exist) {
|
|
|
|
psa_destroy_persistent_key(key_id);
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* Export the key */
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_export_key(key_id, exported, export_size,
|
|
|
|
&exported_length));
|
2018-06-18 18:27:26 +02:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
TEST_MEMORY_COMPARE(data->x, data->len, exported, exported_length);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
/* Destroy the key */
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_destroy_key(key_id));
|
|
|
|
TEST_EQUAL(psa_is_key_present_in_storage(key_id), 0);
|
2018-06-18 18:27:26 +02:00
|
|
|
|
|
|
|
exit:
|
2020-11-19 17:55:23 +01:00
|
|
|
/*
|
|
|
|
* Key attributes may have been returned by psa_get_key_attributes()
|
|
|
|
* thus reset them as required.
|
|
|
|
*/
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_reset_key_attributes(&attributes);
|
2020-11-19 17:55:23 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_free(exported);
|
|
|
|
PSA_DONE();
|
|
|
|
psa_destroy_persistent_key(key_id);
|
2018-06-18 18:27:26 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
2021-04-21 20:09:23 +02:00
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void destroy_nonexistent(int id_arg, int expected_status_arg)
|
2021-04-21 20:09:23 +02:00
|
|
|
{
|
2023-01-11 14:50:10 +01:00
|
|
|
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make(1, id_arg);
|
2021-04-21 20:09:23 +02:00
|
|
|
psa_status_t expected_status = expected_status_arg;
|
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_INIT();
|
2021-04-21 20:09:23 +02:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
TEST_EQUAL(expected_status, psa_destroy_key(id));
|
2021-04-21 20:09:23 +02:00
|
|
|
|
|
|
|
exit:
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_DONE();
|
2021-04-21 20:09:23 +02:00
|
|
|
}
|
|
|
|
/* END_CASE */
|