32 #define WRITE_DATA "THE_FIVE_BOXING_WIZARDS_JUMP_QUICKLY"
33 #define WRITE_DATA_SIZE (sizeof(WRITE_DATA) - 1)
34 #define READ_DATA "############################################"
35 #define RESULT_DATA ("####" WRITE_DATA "####")
66 static struct test_t interface_tests[] = {
67 {&tfm_ps_test_4001,
"TFM_PS_TEST_4001",
68 "Check PS area version when NV counters 1/2/3 have the same value", {
TEST_PASSED}},
69 {&tfm_ps_test_4002,
"TFM_PS_TEST_4002",
70 "Check PS area version when it is different from NV counters 1/2/3", {
TEST_PASSED}},
71 {&tfm_ps_test_4003,
"TFM_PS_TEST_4003",
72 "Check PS area version when NV counters 1 and 2 are equals, 3 is "
73 "different, and PS area version match NV counters 1 and 2", {
TEST_PASSED}},
74 {&tfm_ps_test_4004,
"TFM_PS_TEST_4004",
75 "Check PS area version when NV counters 2 and 3 are equals, 1 is "
76 "different and PS area version match NV counter 2 and 3", {
TEST_PASSED}},
77 {&tfm_ps_test_4005,
"TFM_PS_TEST_4005",
78 "Check PS area version when NV counters 2 and 3 are equals, 1 is "
79 "different and PS area version match NV counter 1", {
TEST_PASSED}},
80 {&tfm_ps_test_4006,
"TFM_PS_TEST_4006",
81 "Check PS area version when NV counters 1, 2 and 3 have different values "
82 "and PS area version match NV counter 1 value", {
TEST_PASSED}},
83 {&tfm_ps_test_4007,
"TFM_PS_TEST_4007",
84 "Check PS area version when NV counters 1, 2 and 3 have different values "
85 "and PS area version match NV counter 2 value", {
TEST_PASSED}},
86 {&tfm_ps_test_4008,
"TFM_PS_TEST_4008",
87 "Check PS area version when NV counters 1, 2 and 3 have different values "
88 "and PS area version match NV counter 3 value", {
TEST_PASSED}},
89 {&tfm_ps_test_4009,
"TFM_PS_TEST_4009",
90 "Check PS area version when NV counter 1 cannot be incremented", {
TEST_PASSED}},
95 uint32_t list_size = (
sizeof(interface_tests) /
sizeof(interface_tests[0]));
97 set_testsuite(
"PS rollback protection tests (TFM_PS_TEST_4XXX)",
98 interface_tests, list_size, p_test_suite);
112 const uint32_t offset = 0;
113 uint32_t old_nvc_1, nvc_1, nvc_2, nvc_3;
116 size_t read_data_len = 0;
119 status =
psa_ps_set(uid, data_len, write_data, flags);
121 TEST_FAIL(
"Set should not fail with valid UID");
133 status =
psa_ps_set(uid, data_len, write_data, flags);
135 TEST_FAIL(
"Set should not fail with valid UID");
153 if (nvc_1 != (old_nvc_1 + 1)) {
154 TEST_FAIL(
"NV counter 1 has been increased more than 1 unit");
165 if (nvc_1 != nvc_2) {
166 TEST_FAIL(
"NV counter 1 and 2 should have the same value");
177 if (nvc_2 != nvc_3) {
178 TEST_FAIL(
"NV counter 2 and 3 should have the same value");
204 TEST_FAIL(
"The data should not have changed");
211 TEST_FAIL(
"Remove should not fail with valid UID");
231 status =
psa_ps_set(uid, data_len, write_data, flags);
233 TEST_FAIL(
"Set should not fail with valid UID");
264 TEST_FAIL(
"PS system prepare should fail as version is old");
300 TEST_FAIL(
"PS system prepare should not fail");
307 TEST_FAIL(
"Remove should not fail with valid UID");
326 const uint32_t offset = 0;
329 size_t read_data_len = 0;
332 status =
psa_ps_set(uid, data_len, write_data, flags);
334 TEST_FAIL(
"Set should not fail with valid UID");
355 TEST_FAIL(
"PS system prepare should not fail");
369 TEST_FAIL(
"The data should not have changed");
376 TEST_FAIL(
"Remove should not fail with valid UID");
396 const uint32_t offset = 0;
399 size_t read_data_len = 0;
402 status =
psa_ps_set(uid, data_len, write_data, flags);
404 TEST_FAIL(
"Set should not fail with valid UID");
425 TEST_FAIL(
"PS system prepare should not fail");
439 TEST_FAIL(
"The data should not have changed");
446 TEST_FAIL(
"Remove should not fail with valid UID");
466 const uint32_t offset = 0;
469 size_t read_data_len = 0;
472 status =
psa_ps_set(uid, data_len, write_data, flags);
474 TEST_FAIL(
"Set should not fail with valid UID");
500 TEST_FAIL(
"PS system prepare should not fail");
514 TEST_FAIL(
"The data should not have changed");
521 TEST_FAIL(
"Remove should not fail with valid UID");
538 const uint32_t offset = 0;
541 size_t read_data_len = 0;
544 status =
psa_ps_set(uid, data_len, write_data, flags);
546 TEST_FAIL(
"Set should not fail with valid UID");
578 TEST_FAIL(
"PS system prepare should not fail");
592 TEST_FAIL(
"The data should not have changed");
599 TEST_FAIL(
"Remove should not fail with valid UID");
619 status =
psa_ps_set(uid, data_len, write_data, flags);
621 TEST_FAIL(
"Set should not fail with valid UID");
648 TEST_FAIL(
"PS system prepare should fail");
678 TEST_FAIL(
"PS system prepare should not fail");
685 TEST_FAIL(
"Remove should not fail with valid UID");
705 status =
psa_ps_set(uid, data_len, write_data, flags);
707 TEST_FAIL(
"Set should not fail with valid UID");
776 TEST_FAIL(
"PS system prepare should not fail");
783 TEST_FAIL(
"Remove should not fail with valid UID");
808 status =
psa_ps_set(uid, data_len, write_data, flags);
810 TEST_FAIL(
"Set should fail as the non-volatile counters can not be"
psa_status_t psa_ps_get(psa_storage_uid_t uid, size_t data_offset, size_t data_size, void *p_data, size_t *p_data_length)
Retrieve data associated with a provided uid.
#define TEST_FAIL(info_msg)
enum test_suite_err_t set_testsuite(const char *name, struct test_t *test_list, uint32_t size, struct test_suite_t *p_ts)
Sets test suite parameters.
psa_status_t psa_ps_set(psa_storage_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
Create a new, or modify an existing, uid/value pair.
#define TFM_PS_NV_COUNTER_1
#define PSA_ERROR_GENERIC_ERROR
#define TFM_PS_NV_COUNTER_3
psa_status_t test_ps_decrement_nv_counter(enum tfm_nv_counter_t counter_id)
Decrements the given non-volatile (NV) counter.
psa_status_t test_ps_read_nv_counter(enum tfm_nv_counter_t counter_id, uint32_t *val)
Reads the given non-volatile (NV) counter.
psa_status_t tfm_ps_test_system_prepare(void)
Requests the PS Test Service to call ps_system_prepare().
psa_status_t test_ps_increment_nv_counter(enum tfm_nv_counter_t counter_id)
Increments the given non-volatile (NV) counter.
psa_status_t psa_ps_remove(psa_storage_uid_t uid)
Remove the provided uid and its associated data from the storage.
#define HALF_PADDING_SIZE
void test_ps_enable_increment_nv_counter(void)
Enables PS increment nv counter function to work normally.
void test_ps_disable_increment_nv_counter(void)
Disables PS increment nv counter function to force PSA_ERROR_GENERIC_ERROR return value as an indicat...
uint64_t psa_storage_uid_t
__STATIC_INLINE int tfm_memcmp(const void *ptr1, const void *ptr2, size_t num)
void register_testsuite_s_rollback_protection(struct test_suite_t *p_test_suite)
Register testsuite for the ps rollback protection tests.
#define TFM_PS_NV_COUNTER_2
#define PSA_STORAGE_FLAG_NONE
uint32_t psa_storage_create_flags_t
int32_t psa_status_t
Function return status.