Skip to content

Commit

Permalink
BUILD: Update For IAR support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
TTornblom authored and adeaarm committed Aug 16, 2023
1 parent 7740eaf commit ac9e340
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ if(CMAKE_COMPILER_IS_CLANG)
endif(CMAKE_COMPILER_IS_CLANG)

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)

if(CMAKE_COMPILER_IS_MSVC)
Expand Down
7 changes: 6 additions & 1 deletion library/psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -4948,8 +4948,13 @@ static psa_status_t psa_key_agreement_internal(psa_key_derivation_operation_t *o
size_t peer_key_length)
{
psa_status_t status;
#if PSA_KEY_AGREEMENT_MAX_SHARED_SECRET_SIZE != 0
uint8_t shared_secret[PSA_KEY_AGREEMENT_MAX_SHARED_SECRET_SIZE];
size_t shared_secret_length = sizeof(shared_secret);
#else
uint8_t *shared_secret = NULL;
size_t shared_secret_length = 0;
#endif
psa_algorithm_t ka_alg = PSA_ALG_KEY_AGREEMENT_GET_BASE(operation->alg);

/* Step 1: run the secret agreement algorithm to generate the shared
Expand All @@ -4958,7 +4963,7 @@ static psa_status_t psa_key_agreement_internal(psa_key_derivation_operation_t *o
private_key,
peer_key, peer_key_length,
shared_secret,
sizeof(shared_secret),
shared_secret_length,
&shared_secret_length);
if (status != PSA_SUCCESS) {
goto exit;
Expand Down

0 comments on commit ac9e340

Please sign in to comment.