BUILD: Update For IAR support

Applied the same change as in mbed-crypto for using this as a sub
project with the IAR toolchain. Use __asm generic ,and avoid empty
enum. Avoid declaration of array with null size. This is a porting
of the original patch contributed to trusted-firmware-m.

Signed-off-by: TTornblom <thomas.tornblom@iar.com>
Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
This commit is contained in:
TTornblom 2020-04-16 13:53:38 +02:00 committed by Antonio de Angelis
parent a4c01dd6e9
commit e4f6d79bbe
3 changed files with 10 additions and 3 deletions

View file

@ -226,7 +226,9 @@ if(CMAKE_COMPILER_IS_CLANG)
endif(CMAKE_COMPILER_IS_CLANG) endif(CMAKE_COMPILER_IS_CLANG)
if(CMAKE_COMPILER_IS_IAR) if(CMAKE_COMPILER_IS_IAR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --warn_about_c_style_casts -Ohz") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --warn_about_c_style_casts")
set(CMAKE_C_FLAGS_RELEASE "-Ohz")
set(CMAKE_C_FLAGS_DEBUG "--debug -On")
endif(CMAKE_COMPILER_IS_IAR) endif(CMAKE_COMPILER_IS_IAR)
if(CMAKE_COMPILER_IS_MSVC) if(CMAKE_COMPILER_IS_MSVC)

View file

@ -78,7 +78,7 @@ static inline uint32_t mbedtls_get_unaligned_volatile_uint32(volatile const unsi
*/ */
uint32_t r; uint32_t r;
#if defined(MBEDTLS_CT_ARM_ASM) #if defined(MBEDTLS_CT_ARM_ASM)
asm volatile ("ldr %0, [%1]" : "=r" (r) : "r" (p) :); __asm volatile ("ldr %0, [%1]" : "=r" (r) : "r" (p) :);
#elif defined(MBEDTLS_CT_AARCH64_ASM) #elif defined(MBEDTLS_CT_AARCH64_ASM)
asm volatile ("ldr %w0, [%1]" : "=r" (r) : MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT(p) :); asm volatile ("ldr %w0, [%1]" : "=r" (r) : MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT(p) :);
#else #else

View file

@ -7049,8 +7049,13 @@ static psa_status_t psa_key_agreement_internal(psa_key_derivation_operation_t *o
size_t peer_key_length) size_t peer_key_length)
{ {
psa_status_t status; psa_status_t status;
#if PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE != 0
uint8_t shared_secret[PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE]; uint8_t shared_secret[PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE];
size_t shared_secret_length = sizeof(shared_secret);
#else
uint8_t *shared_secret = NULL;
size_t shared_secret_length = 0; size_t shared_secret_length = 0;
#endif
psa_algorithm_t ka_alg = PSA_ALG_KEY_AGREEMENT_GET_BASE(operation->alg); psa_algorithm_t ka_alg = PSA_ALG_KEY_AGREEMENT_GET_BASE(operation->alg);
/* Step 1: run the secret agreement algorithm to generate the shared /* Step 1: run the secret agreement algorithm to generate the shared
@ -7059,7 +7064,7 @@ static psa_status_t psa_key_agreement_internal(psa_key_derivation_operation_t *o
private_key, private_key,
peer_key, peer_key_length, peer_key, peer_key_length,
shared_secret, shared_secret,
sizeof(shared_secret), shared_secret_length,
&shared_secret_length); &shared_secret_length);
if (status != PSA_SUCCESS) { if (status != PSA_SUCCESS) {
goto exit; goto exit;