Update ITS test

pull/9529/head
Oren Cohen 2019-01-24 18:59:31 +02:00
parent 3d3ee3834d
commit 47365d4620
10 changed files with 82 additions and 14057 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,97 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/***********************************************************************************************************************
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Template Version 1.0
* Generated by tools/spm/generate_partition_code.py Version 1.0
**********************************************************************************************************************/
#include "spm_panic.h"
#include "spm_internal.h"
#include "handles_manager.h"
#include "cmsis.h"
#include "psa_test_its_reset_partition.h"
#include "psa_crypto_srv_partition.h"
#include "psa_its_partition.h"
extern const uint32_t crypto_srv_external_sids[4];
spm_partition_t g_partitions[3] = {
{
.partition_id = TEST_ITS_RESET_ID,
.thread_id = 0,
.flags_rot_srv = TEST_ITS_RESET_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = TEST_ITS_RESET_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = TEST_ITS_RESET_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{
.partition_id = CRYPTO_SRV_ID,
.thread_id = 0,
.flags_rot_srv = CRYPTO_SRV_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = CRYPTO_SRV_ROT_SRV_COUNT,
.extern_sids = crypto_srv_external_sids,
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{
.partition_id = ITS_ID,
.thread_id = 0,
.flags_rot_srv = ITS_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = ITS_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = ITS_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
};
/* Check all the defined memory regions for overlapping. */
/* A list of all the memory regions. */
const mem_region_t *mem_regions = NULL;
const uint32_t mem_region_count = 0;
// forward declaration of partition initializers
void test_its_reset_init(spm_partition_t *partition);
void crypto_srv_init(spm_partition_t *partition);
void its_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions)
{
if (NULL == partitions) {
SPM_PANIC("partitions is NULL!\n");
}
test_its_reset_init(&(g_partitions[0]));
crypto_srv_init(&(g_partitions[1]));
its_init(&(g_partitions[2]));
*partitions = g_partitions;
return 3;
}

View File

@ -38,9 +38,6 @@ static void pits_test()
struct psa_its_info_t info = {0, PSA_ITS_FLAG_WRITE_ONCE}; struct psa_its_info_t info = {0, PSA_ITS_FLAG_WRITE_ONCE};
memset(read_buff, 0, TEST_BUFF_SIZE); memset(read_buff, 0, TEST_BUFF_SIZE);
status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
status = psa_its_get_info(5, &info); status = psa_its_get_info(5, &info);
TEST_ASSERT_EQUAL(PSA_ITS_ERROR_UID_NOT_FOUND, status); TEST_ASSERT_EQUAL(PSA_ITS_ERROR_UID_NOT_FOUND, status);
@ -78,9 +75,6 @@ static void pits_write_once_test()
uint8_t read_buff[TEST_BUFF_SIZE] = {0}; uint8_t read_buff[TEST_BUFF_SIZE] = {0};
struct psa_its_info_t info = {0, 0}; struct psa_its_info_t info = {0, 0};
status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
status = psa_its_get_info(5, &info); status = psa_its_get_info(5, &info);
TEST_ASSERT_EQUAL(PSA_ITS_ERROR_UID_NOT_FOUND, status); TEST_ASSERT_EQUAL(PSA_ITS_ERROR_UID_NOT_FOUND, status);
@ -113,60 +107,27 @@ static void pits_write_once_test()
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status); TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
TEST_ASSERT_EQUAL(TEST_BUFF_SIZE, info.size); TEST_ASSERT_EQUAL(TEST_BUFF_SIZE, info.size);
TEST_ASSERT_EQUAL(PSA_ITS_FLAG_WRITE_ONCE, info.flags); TEST_ASSERT_EQUAL(PSA_ITS_FLAG_WRITE_ONCE, info.flags);
status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
} }
static void pits_migrate_version(void) utest::v1::status_t case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)
{ {
uint32_t major = 0; psa_status_t status;
uint32_t minor = 1; status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
int kv_status = 0; TEST_ASSERT_EQUAL(PSA_LIFECYCLE_SUCCESS, status);
struct psa_its_info_t info = {0, PSA_ITS_FLAG_NONE}; return greentea_case_teardown_handler(source, passed, failed, reason);
psa_its_status_t status = test_psa_its_reset(); }
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
// Setting fake ITS old version utest::v1::status_t case_setup_handler(const Case *const source, const size_t index_of_case)
// Expect migration to update to current version {
psa_status_t status;
status = test_psa_its_deinit(); status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status); TEST_ASSERT_EQUAL(PSA_LIFECYCLE_SUCCESS, status);
return greentea_case_setup_handler(source, index_of_case);
status = test_psa_its_set_ver(major, minor);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
status = psa_its_get_info(5, &info);
TEST_ASSERT_EQUAL(PSA_ITS_ERROR_UID_NOT_FOUND, status);
status = test_psa_its_get_ver(&major, &minor);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
TEST_ASSERT_EQUAL(PSA_ITS_API_VERSION_MAJOR, major);
TEST_ASSERT_EQUAL(PSA_ITS_API_VERSION_MINOR, minor);
// De-initializes ITS's KVStore instance with existing version file
// Expects the version to remain at current version
major = 0;
minor = 0;
status = test_psa_its_deinit();
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
status = psa_its_get_info(5, &info);
TEST_ASSERT_EQUAL(PSA_ITS_ERROR_UID_NOT_FOUND, status);
status = test_psa_its_get_ver(&major, &minor);
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
TEST_ASSERT_EQUAL(PSA_ITS_API_VERSION_MAJOR, major);
TEST_ASSERT_EQUAL(PSA_ITS_API_VERSION_MINOR, minor);
status = test_psa_its_reset();
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
} }
Case cases[] = { Case cases[] = {
Case("PSA prot internal storage - Basic", pits_test), Case("PSA prot internal storage - Basic", case_setup_handler, pits_test, case_teardown_handler),
Case("PSA prot internal storage - Write-once", pits_write_once_test), Case("PSA prot internal storage - Write-once", case_setup_handler, pits_write_once_test, case_teardown_handler)
Case("PSA prot internal storage - Version migration", pits_migrate_version),
}; };
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) utest::v1::status_t greentea_test_setup(const size_t number_of_cases)

View File

@ -1,97 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/***********************************************************************************************************************
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Template Version 1.0
* Generated by tools/spm/generate_partition_code.py Version 1.0
**********************************************************************************************************************/
#include "spm_panic.h"
#include "spm_internal.h"
#include "handles_manager.h"
#include "cmsis.h"
#include "psa_test_its_reset_partition.h"
#include "psa_crypto_srv_partition.h"
#include "psa_its_partition.h"
extern const uint32_t crypto_srv_external_sids[4];
spm_partition_t g_partitions[3] = {
{
.partition_id = TEST_ITS_RESET_ID,
.thread_id = 0,
.flags_rot_srv = TEST_ITS_RESET_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = TEST_ITS_RESET_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = TEST_ITS_RESET_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{
.partition_id = CRYPTO_SRV_ID,
.thread_id = 0,
.flags_rot_srv = CRYPTO_SRV_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = CRYPTO_SRV_ROT_SRV_COUNT,
.extern_sids = crypto_srv_external_sids,
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{
.partition_id = ITS_ID,
.thread_id = 0,
.flags_rot_srv = ITS_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = ITS_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = ITS_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
};
/* Check all the defined memory regions for overlapping. */
/* A list of all the memory regions. */
const mem_region_t *mem_regions = NULL;
const uint32_t mem_region_count = 0;
// forward declaration of partition initializers
void test_its_reset_init(spm_partition_t *partition);
void crypto_srv_init(spm_partition_t *partition);
void its_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions)
{
if (NULL == partitions) {
SPM_PANIC("partitions is NULL!\n");
}
test_its_reset_init(&(g_partitions[0]));
crypto_srv_init(&(g_partitions[1]));
its_init(&(g_partitions[2]));
*partitions = g_partitions;
return 3;
}

View File

@ -29,11 +29,12 @@
#include "cmsis.h" #include "cmsis.h"
#include "psa_client_tests_part1_partition.h" #include "psa_client_tests_part1_partition.h"
#include "psa_crypto_srv_partition.h" #include "psa_crypto_srv_partition.h"
#include "psa_platform_partition.h"
#include "psa_its_partition.h" #include "psa_its_partition.h"
extern const uint32_t crypto_srv_external_sids[4]; extern const uint32_t crypto_srv_external_sids[4];
spm_partition_t g_partitions[3] = { spm_partition_t g_partitions[4] = {
{ {
.partition_id = CLIENT_TESTS_PART1_ID, .partition_id = CLIENT_TESTS_PART1_ID,
.thread_id = 0, .thread_id = 0,
@ -56,6 +57,17 @@ spm_partition_t g_partitions[3] = {
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT, .extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL, .irq_mapper = NULL,
}, },
{
.partition_id = PLATFORM_ID,
.thread_id = 0,
.flags_rot_srv = PLATFORM_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = PLATFORM_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = PLATFORM_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{ {
.partition_id = ITS_ID, .partition_id = ITS_ID,
.thread_id = 0, .thread_id = 0,
@ -79,6 +91,7 @@ const uint32_t mem_region_count = 0;
// forward declaration of partition initializers // forward declaration of partition initializers
void client_tests_part1_init(spm_partition_t *partition); void client_tests_part1_init(spm_partition_t *partition);
void crypto_srv_init(spm_partition_t *partition); void crypto_srv_init(spm_partition_t *partition);
void platform_init(spm_partition_t *partition);
void its_init(spm_partition_t *partition); void its_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions) uint32_t init_partitions(spm_partition_t **partitions)
@ -89,9 +102,10 @@ uint32_t init_partitions(spm_partition_t **partitions)
client_tests_part1_init(&(g_partitions[0])); client_tests_part1_init(&(g_partitions[0]));
crypto_srv_init(&(g_partitions[1])); crypto_srv_init(&(g_partitions[1]));
its_init(&(g_partitions[2])); platform_init(&(g_partitions[2]));
its_init(&(g_partitions[3]));
*partitions = g_partitions; *partitions = g_partitions;
return 3; return 4;
} }

View File

@ -30,12 +30,13 @@
#include "psa_server_test_part1_partition.h" #include "psa_server_test_part1_partition.h"
#include "psa_server_test_part2_partition.h" #include "psa_server_test_part2_partition.h"
#include "psa_crypto_srv_partition.h" #include "psa_crypto_srv_partition.h"
#include "psa_platform_partition.h"
#include "psa_its_partition.h" #include "psa_its_partition.h"
extern const uint32_t server_test_part1_external_sids[2]; extern const uint32_t server_test_part1_external_sids[2];
extern const uint32_t crypto_srv_external_sids[4]; extern const uint32_t crypto_srv_external_sids[4];
spm_partition_t g_partitions[4] = { spm_partition_t g_partitions[5] = {
{ {
.partition_id = SERVER_TEST_PART1_ID, .partition_id = SERVER_TEST_PART1_ID,
.thread_id = 0, .thread_id = 0,
@ -69,6 +70,17 @@ spm_partition_t g_partitions[4] = {
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT, .extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL, .irq_mapper = NULL,
}, },
{
.partition_id = PLATFORM_ID,
.thread_id = 0,
.flags_rot_srv = PLATFORM_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = PLATFORM_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = PLATFORM_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{ {
.partition_id = ITS_ID, .partition_id = ITS_ID,
.thread_id = 0, .thread_id = 0,
@ -93,6 +105,7 @@ const uint32_t mem_region_count = 0;
void server_test_part1_init(spm_partition_t *partition); void server_test_part1_init(spm_partition_t *partition);
void server_test_part2_init(spm_partition_t *partition); void server_test_part2_init(spm_partition_t *partition);
void crypto_srv_init(spm_partition_t *partition); void crypto_srv_init(spm_partition_t *partition);
void platform_init(spm_partition_t *partition);
void its_init(spm_partition_t *partition); void its_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions) uint32_t init_partitions(spm_partition_t **partitions)
@ -104,9 +117,10 @@ uint32_t init_partitions(spm_partition_t **partitions)
server_test_part1_init(&(g_partitions[0])); server_test_part1_init(&(g_partitions[0]));
server_test_part2_init(&(g_partitions[1])); server_test_part2_init(&(g_partitions[1]));
crypto_srv_init(&(g_partitions[2])); crypto_srv_init(&(g_partitions[2]));
its_init(&(g_partitions[3])); platform_init(&(g_partitions[3]));
its_init(&(g_partitions[4]));
*partitions = g_partitions; *partitions = g_partitions;
return 4; return 5;
} }

View File

@ -29,11 +29,12 @@
#include "cmsis.h" #include "cmsis.h"
#include "psa_smoke_test_part1_partition.h" #include "psa_smoke_test_part1_partition.h"
#include "psa_crypto_srv_partition.h" #include "psa_crypto_srv_partition.h"
#include "psa_platform_partition.h"
#include "psa_its_partition.h" #include "psa_its_partition.h"
extern const uint32_t crypto_srv_external_sids[4]; extern const uint32_t crypto_srv_external_sids[4];
spm_partition_t g_partitions[3] = { spm_partition_t g_partitions[4] = {
{ {
.partition_id = SMOKE_TEST_PART1_ID, .partition_id = SMOKE_TEST_PART1_ID,
.thread_id = 0, .thread_id = 0,
@ -56,6 +57,17 @@ spm_partition_t g_partitions[3] = {
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT, .extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL, .irq_mapper = NULL,
}, },
{
.partition_id = PLATFORM_ID,
.thread_id = 0,
.flags_rot_srv = PLATFORM_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = PLATFORM_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = PLATFORM_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{ {
.partition_id = ITS_ID, .partition_id = ITS_ID,
.thread_id = 0, .thread_id = 0,
@ -79,6 +91,7 @@ const uint32_t mem_region_count = 0;
// forward declaration of partition initializers // forward declaration of partition initializers
void smoke_test_part1_init(spm_partition_t *partition); void smoke_test_part1_init(spm_partition_t *partition);
void crypto_srv_init(spm_partition_t *partition); void crypto_srv_init(spm_partition_t *partition);
void platform_init(spm_partition_t *partition);
void its_init(spm_partition_t *partition); void its_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions) uint32_t init_partitions(spm_partition_t **partitions)
@ -89,9 +102,10 @@ uint32_t init_partitions(spm_partition_t **partitions)
smoke_test_part1_init(&(g_partitions[0])); smoke_test_part1_init(&(g_partitions[0]));
crypto_srv_init(&(g_partitions[1])); crypto_srv_init(&(g_partitions[1]));
its_init(&(g_partitions[2])); platform_init(&(g_partitions[2]));
its_init(&(g_partitions[3]));
*partitions = g_partitions; *partitions = g_partitions;
return 3; return 4;
} }

View File

@ -28,12 +28,13 @@
#include "handles_manager.h" #include "handles_manager.h"
#include "cmsis.h" #include "cmsis.h"
#include "psa_crypto_srv_partition.h" #include "psa_crypto_srv_partition.h"
#include "psa_platform_partition.h"
#include "psa_its_partition.h" #include "psa_its_partition.h"
extern const uint32_t crypto_srv_external_sids[4]; extern const uint32_t crypto_srv_external_sids[4];
__attribute__((weak)) __attribute__((weak))
spm_partition_t g_partitions[2] = { spm_partition_t g_partitions[3] = {
{ {
.partition_id = CRYPTO_SRV_ID, .partition_id = CRYPTO_SRV_ID,
.thread_id = 0, .thread_id = 0,
@ -45,6 +46,17 @@ spm_partition_t g_partitions[2] = {
.extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT, .extern_sids_count = CRYPTO_SRV_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL, .irq_mapper = NULL,
}, },
{
.partition_id = PLATFORM_ID,
.thread_id = 0,
.flags_rot_srv = PLATFORM_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = PLATFORM_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = PLATFORM_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{ {
.partition_id = ITS_ID, .partition_id = ITS_ID,
.thread_id = 0, .thread_id = 0,
@ -69,6 +81,7 @@ const uint32_t mem_region_count = 0;
// forward declaration of partition initializers // forward declaration of partition initializers
void crypto_srv_init(spm_partition_t *partition); void crypto_srv_init(spm_partition_t *partition);
void platform_init(spm_partition_t *partition);
void its_init(spm_partition_t *partition); void its_init(spm_partition_t *partition);
__attribute__((weak)) __attribute__((weak))
@ -79,9 +92,10 @@ uint32_t init_partitions(spm_partition_t **partitions)
} }
crypto_srv_init(&(g_partitions[0])); crypto_srv_init(&(g_partitions[0]));
its_init(&(g_partitions[1])); platform_init(&(g_partitions[1]));
its_init(&(g_partitions[2]));
*partitions = g_partitions; *partitions = g_partitions;
return 2; return 3;
} }