From 9175c21b724d46268c750f38dba2aff180d0a1c9 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 24 Jul 2019 11:47:22 +0100 Subject: [PATCH] tinyCrypt: Move key buffers to end of mbedtls_ssl_handshake_params This saves considerable amount of code on Thumb due to single-instruction load/stores for fields preceding these buffers. --- include/mbedtls/ssl_internal.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/mbedtls/ssl_internal.h b/include/mbedtls/ssl_internal.h index 19d1fd364..e8f7b7100 100644 --- a/include/mbedtls/ssl_internal.h +++ b/include/mbedtls/ssl_internal.h @@ -392,11 +392,6 @@ struct mbedtls_ssl_handshake_params defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) uint16_t curve_tls_id; /*!< TLS ID of EC for ECDHE. */ #endif -#if defined(MBEDTLS_USE_TINYCRYPT) - uint8_t ecdh_privkey[NUM_ECC_BYTES]; - uint8_t ecdh_ownpubkey[2*NUM_ECC_BYTES]; - uint8_t ecdh_peerkey[2*NUM_ECC_BYTES]; -#endif /* MBEDTLS_USE_TINYCRYPT */ #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) unsigned char *psk; /*!< PSK from the callback */ size_t psk_len; /*!< Length of PSK from callback */ @@ -554,6 +549,12 @@ struct mbedtls_ssl_handshake_params * The library does not use it internally. */ void *user_async_ctx; #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + +#if defined(MBEDTLS_USE_TINYCRYPT) + uint8_t ecdh_privkey[NUM_ECC_BYTES]; + uint8_t ecdh_ownpubkey[2*NUM_ECC_BYTES]; + uint8_t ecdh_peerkey[2*NUM_ECC_BYTES]; +#endif /* MBEDTLS_USE_TINYCRYPT */ }; /*