From 5677b386afda6907907ae93bb32f69165cad5ac3 Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Thu, 7 Mar 2019 22:29:35 +0200 Subject: [PATCH 1/2] Reset ITS before the test start --- TESTS/psa/attestation/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/TESTS/psa/attestation/main.cpp b/TESTS/psa/attestation/main.cpp index a6a92b1f41..5002051c36 100755 --- a/TESTS/psa/attestation/main.cpp +++ b/TESTS/psa/attestation/main.cpp @@ -23,6 +23,7 @@ #include "greentea-client/test_env.h" #include "unity/unity.h" #include "utest/utest.h" +#include "psa/lifecycle.h" #include "psa_initial_attestation_api.h" #include "psa_attest_inject_key.h" #include @@ -126,11 +127,6 @@ utest::v1::status_t case_teardown_handler(const Case *const source, const size_t return greentea_case_teardown_handler(source, passed, failed, reason); } -utest::v1::status_t case_setup_handler(const Case *const source, const size_t index_of_case) -{ - return greentea_case_setup_handler(source, index_of_case); -} - Case cases[] = { Case("PSA attestation get token", check_initial_attestation_get_token, case_teardown_handler), }; @@ -139,6 +135,8 @@ Specification specification(greentea_test_setup, cases); int main() { + psa_status_t status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST); + TEST_ASSERT_EQUAL(PSA_LIFECYCLE_SUCCESS, status); #if (defined(COMPONENT_PSA_SRV_IPC) || defined(MBEDTLS_ENTROPY_NV_SEED)) uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0}; /* inject some seed for test*/ From d0021b5de77c991a19260ff4325e416f2f5b4e9e Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Thu, 7 Mar 2019 22:31:42 +0200 Subject: [PATCH 2/2] Fix error codes for psa_attestation_inject_key --- .../attestation/COMPONENT_PSA_SRV_IPC/psa_attest_inject_key.c | 4 ---- .../attestation/COMPONENT_SPE/psa_attestation_partition.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IPC/psa_attest_inject_key.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IPC/psa_attest_inject_key.c index 5189ab3be3..0291dc2599 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IPC/psa_attest_inject_key.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IPC/psa_attest_inject_key.c @@ -51,9 +51,5 @@ psa_attestation_inject_key(const uint8_t *key_data, call_error = psa_call(handle, in_vec, 2, out_vec, 2); psa_close(handle); - - if (call_error < 0) { - call_error = PSA_ERROR_COMMUNICATION_FAILURE; - } return call_error; } diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_SPE/psa_attestation_partition.c b/components/TARGET_PSA/services/attestation/COMPONENT_SPE/psa_attestation_partition.c index 65e428271e..66cedca666 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_SPE/psa_attestation_partition.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_SPE/psa_attestation_partition.c @@ -175,7 +175,7 @@ static void psa_attest_inject_key(void) uint32_t bytes_read = 0; if (msg.in_size[0] != sizeof(psa_key_type_t)) { - status = PSA_ERROR_COMMUNICATION_FAILURE; + status = PSA_ERROR_INVALID_ARGUMENT; break; }