From 2701005b46953d6f993a57115ceda2d1384c8bd1 Mon Sep 17 00:00:00 2001 From: mohammad1603 Date: Tue, 3 Jul 2018 13:16:15 +0300 Subject: [PATCH] Modifications for psa-crypto in order to integrate with SPM Add required includes in tests and psa_crypto.c file in order to be able to compilef for the SPM solution. Some functions needed to be deprecated from psa_crypto.c since they already implemented in the SPM. --- library/psa_crypto.c | 15 +++++++++++++-- tests/suites/test_suite_psa_crypto.function | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ca461c20e..68fa0ef67 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -27,6 +27,17 @@ #if defined(MBEDTLS_PSA_CRYPTO_C) +//! In case MBEDTLS_PSA_CRYPTO_SPM is defined the code is built for SPM (Secure +//! Partition Manager) integration which separate the code into two parts +//! NSPE (Non-Secure Process Environment) and SPE (Secure Process Environment). +//! In this mode an additional header file should be included. +#if defined(MBEDTLS_PSA_CRYPTO_SPM) +//! PSA_CRYPTO_SECURE means that this file is compiled to the SPE side. +//! some headers will be affected by this flag. +#define PSA_CRYPTO_SECURE 1 +#include "crypto_spe.h" +#endif + #include "psa/crypto.h" #include @@ -2481,7 +2492,7 @@ psa_status_t psa_cipher_abort( psa_cipher_operation_t *operation ) /****************************************************************/ /* Key Policy */ /****************************************************************/ - +#if !defined(MBEDTLS_PSA_CRYPTO_SPM) void psa_key_policy_init( psa_key_policy_t *policy ) { memset( policy, 0, sizeof( *policy ) ); @@ -2504,7 +2515,7 @@ psa_algorithm_t psa_key_policy_get_algorithm( psa_key_policy_t *policy ) { return( policy->alg ); } - +#endif /* !defined(MBEDTLS_PSA_CRYPTO_SPM) */ psa_status_t psa_set_key_policy( psa_key_slot_t key, const psa_key_policy_t *policy ) { diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 9eac29b43..c90447f81 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -1,5 +1,10 @@ /* BEGIN_HEADER */ #include + +#if defined(MBEDTLS_PSA_CRYPTO_SPM) +#include "spm/psa_defs.h" +#endif + #include "mbedtls/asn1write.h" #include "psa/crypto.h"