diff --git a/TESTS/psa/attestation/main.cpp b/TESTS/psa/attestation/main.cpp index b3265d79fc..e1bc21eb75 100755 --- a/TESTS/psa/attestation/main.cpp +++ b/TESTS/psa/attestation/main.cpp @@ -89,6 +89,8 @@ static void check_initial_attestation_get_token() enum psa_attest_err_t attest_err = PSA_ATTEST_ERR_SUCCESS; uint32_t token_size; + status = psa_crypto_init(); + TEST_ASSERT_EQUAL(status, PSA_SUCCESS); status = psa_attestation_inject_key(private_key_data, sizeof(private_key_data), PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), @@ -139,12 +141,12 @@ int main() { #if (defined(COMPONENT_PSA_SRV_IPC) || defined(MBEDTLS_ENTROPY_NV_SEED)) uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0}; - /* inject some a seed for test*/ + /* inject some seed for test*/ for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) { seed[i] = i; } - /* don't really care if this succeed this is just to make crypto init pass*/ + /* don't really care if this succeeds this is just to make crypto init pass*/ mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE); #endif return !Harness::run(specification); diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c index 3acb8ad26c..37c6a30917 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_boot_status_loader.c @@ -75,12 +75,12 @@ attest_get_boot_data(uint8_t major_type, void *ptr, uint32_t len) { { tlv_entry = (struct shared_data_tlv_entry *)offset; if (GET_MAJOR(tlv_entry->tlv_type) == major_type) { + if (len < ptr_tlv_header->tlv_tot_len + tlv_entry->tlv_len) { + return PSA_ATTEST_ERR_INIT_FAILED; + } memcpy(ptr, (const void *)tlv_entry, tlv_entry->tlv_len); ptr += tlv_entry->tlv_len; ptr_tlv_header->tlv_tot_len += tlv_entry->tlv_len; - if (len < ptr_tlv_header->tlv_tot_len) { - return PSA_ATTEST_ERR_INIT_FAILED; - } } if (tlv_entry->tlv_len == 0) { break; @@ -89,4 +89,4 @@ attest_get_boot_data(uint8_t major_type, void *ptr, uint32_t len) { shared_data_init_done = SHARED_DATA_INITIALZED; return PSA_ATTEST_ERR_SUCCESS; -} \ No newline at end of file +} diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_crypto.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_crypto.c index 2f712f5d6c..4c82369895 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_crypto.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attest_crypto.c @@ -202,7 +202,7 @@ t_cose_crypto_hash_start(struct t_cose_crypto_hash *hash_ctx, * failure. */ cose_ret = check_hash_sizes(); - if (cose_ret) + if (cose_ret != T_COSE_SUCCESS) { return cose_ret; } @@ -239,8 +239,6 @@ void t_cose_crypto_hash_update(struct t_cose_crypto_hash *hash_ctx, psa_hash_ctx->status = psa_hash_update(&psa_hash_ctx->operation, data_to_hash.ptr, data_to_hash.len); - } else { - /* Intentionally do nothing, just computing the size of the token */ } } } diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attestation_bootloader_data.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attestation_bootloader_data.c index 5735177b8b..88091d9d60 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attestation_bootloader_data.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/attestation_bootloader_data.c @@ -18,7 +18,7 @@ #include "attestation_bootloader_data.h" -/* Temporary Boodloader data - conatians temp mandatory claims */ +/* Temporary Boodloader data - contains temp mandatory claims */ __attribute__((aligned(4))) const uint8_t temp_ram_page_data[] = { 0x16, 0x20, 0x8C, 0x00, //shared_data_tlv_header diff --git a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c index 47d05fc65e..b36c64a1c4 100755 --- a/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c +++ b/components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/psa_attestation_stubs.c @@ -28,4 +28,4 @@ attest_check_memory_access(void *addr, return PSA_ATTEST_ERR_INVALID_INPUT; } return PSA_ATTEST_ERR_SUCCESS; -} \ No newline at end of file +}