From ada61f05b370f588c06371c4977be0267a800ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20J=C3=A4=C3=A4sk=C3=B6?= Date: Mon, 18 Jan 2021 17:53:48 +0200 Subject: [PATCH] AES: masked config: remove 176 bytes of zeroing on each AES finalize round MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On MBEDTLS_AES_128_BIT_MASKED+FI_COUNTERMEASURES config the rk_mask array was unconditionally zeroed on each dummy finalization round even though it will be zeroed after the loop too. Remove the repeated zeroing to increase overall transfer speed on DTLS session by 17..20% on a Cortex-M4. Signed-off-by: Tero Jääskö --- library/aes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/aes.c b/library/aes.c index 061b6fd59..72cfc104d 100644 --- a/library/aes.c +++ b/library/aes.c @@ -1560,8 +1560,6 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, { flow_control++; } - //Cleanup the masked key - mbedtls_platform_memset( rk_masked, 0, sizeof(rk_masked) ); #else aes_fround_final( aes_data_ptr->rk_ptr, &aes_data_ptr->xy_values[0],