Skip to content

Commit bb051fa

Browse files
committed
Rely on the public PSA API to reset security state
1 parent 8c0459e commit bb051fa

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

atecc608a/main.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
#if defined(ATCA_HAL_I2C)
2424
#include "psa/crypto.h"
25+
#include "psa/lifecycle.h"
2526
#include "atecc608a_se.h"
2627
#include "atecc608a_utils.h"
2728
#include "atca_helpers.h"
2829
#include "atecc508a_config_dev.h"
29-
#include "psa_crypto_storage.h"
3030
/** This macro checks if the result of an `expression` is equal to an
3131
* `expected` value and sets a `status` variable of type `psa_status_t` to
3232
* `PSA_SUCCESS`. If they are not equal, the `status` is set to
@@ -76,19 +76,6 @@
7676
"the slot now behaves according to the policies set by the associated\n"\
7777
"configuration zone’s values. [y/n]: "
7878

79-
static void psa_purge_keys(void)
80-
{
81-
psa_key_id_t id;
82-
printf("Clearing persistent key data\n");
83-
/* Clear slots 0-15 of persistent storage. These numbers are equal to
84-
* physical slots available on the device. */
85-
for (id = 0; id < 16; id++) {
86-
psa_destroy_persistent_key(id);
87-
}
88-
/* Purge the transaction file. */
89-
psa_crypto_stop_transaction();
90-
}
91-
9279
/* Data used by tests */
9380
psa_key_slot_number_t atecc608a_private_key_slot = 1;
9481
psa_key_slot_number_t atecc608a_public_key_slot = 9;
@@ -370,7 +357,7 @@ psa_status_t run_tests()
370357
psa_key_attributes_t private_key_attributes = PSA_KEY_ATTRIBUTES_INIT;
371358
psa_key_handle_t private_handle;
372359

373-
psa_purge_keys();
360+
mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
374361

375362
setup_key_attributes(&public_key_attributes,
376363
atecc608a_public_key_slot, 0);
@@ -391,7 +378,7 @@ psa_status_t run_tests()
391378

392379
/* Purge, so that we can test driver behaviour with a key that is registered,
393380
* not generated. */
394-
psa_purge_keys();
381+
mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
395382
ASSERT_SUCCESS_PSA(mbedtls_psa_register_se_key(&private_key_attributes));
396383

397384
ASSERT_SUCCESS_PSA(test_export_import(&private_handle,
@@ -604,7 +591,7 @@ int main(void)
604591
bool exit_application = false;
605592

606593
print_device_info();
607-
psa_destroy_se_persistent_data(PSA_ATECC608A_LIFETIME);
594+
mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
608595
ASSERT_SUCCESS_PSA(psa_register_se_driver(PSA_ATECC608A_LIFETIME, &atecc608a_drv_info));
609596

610597
ASSERT_SUCCESS_PSA(psa_crypto_init());

0 commit comments

Comments
 (0)