From 0241f81cbc059d0b3b1541db19212142476c8c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20J=C3=A4=C3=A4sk=C3=B6?= Date: Fri, 15 Jan 2021 17:02:37 +0200 Subject: [PATCH] AES: masked config: increase total transfer speed by 5% by removing zeroing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On MBEDTLS_AES_128_BIT_MASKED config the overall DTLS transfer speed can be increased by 3..5% or so on a Cortex-M4 by removing 472 bytes worth of buffer zeroing done on each block {en|de}cryption. The buffer zeroings were done before overwriting them on in masking code. Signed-off-by: Tero Jääskö --- library/aes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/aes.c b/library/aes.c index 50f970227..061b6fd59 100644 --- a/library/aes.c +++ b/library/aes.c @@ -1421,9 +1421,9 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, uint8_t round_ctrl_table[( 14 + AES_SCA_CM_ROUNDS + 2 )]; #if defined MBEDTLS_AES_128_BIT_MASKED - uint32_t rk_masked[MBEDTLS_AES_128_EXPANDED_KEY_SIZE_IN_WORDS] = {0}; - uint8_t sbox_masked[256] = {0}; - uint32_t mask[10] = {0}; + uint32_t rk_masked[MBEDTLS_AES_128_EXPANDED_KEY_SIZE_IN_WORDS]; + uint8_t sbox_masked[256]; + uint32_t mask[10]; #endif #if defined(MBEDTLS_VALIDATE_AES_KEYS_INTEGRITY)