Skip to content

Commit 17d77aa

Browse files
committed
mbedtls: use one AES table per direction
MBEDTLS_AES_FEWER_TABLES keeps one 1 KB table per direction and rotates its entries at run time instead of storing four rotated copies. Firmware size: Feather ESP32-C6 -5,648 bytes, Pico W -5,928 bytes, Pico 2 W -6,144 bytes. On ESP32 the TLS traffic is encrypted by the AES peripheral, so only mbedtls's software paths use the tables. On a PicoPad (RP2040), where TLS runs software AES, a 1 MB HTTPS download ran at 320 kB/s with the change and 316 kB/s without (medians), and the handshake took the same 3.8 s.
1 parent 7639c09 commit 17d77aa

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

‎lib/mbedtls_config/tf_psa_crypto_config.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void m_tracked_free(void *ptr);
4545
// Size/speed tradeoffs ///////////////////////////////////////////////////////
4646

4747
#define MBEDTLS_AES_ROM_TABLES
48+
#define MBEDTLS_AES_FEWER_TABLES
4849
#define MBEDTLS_SHA256_SMALLER
4950
#define MBEDTLS_ECP_NIST_OPTIM
5051

‎ports/espressif/esp-idf-config/sdkconfig.defaults‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
121121
# CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set
122122
# CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM is not set
123123
CONFIG_MBEDTLS_ERROR_STRINGS=y
124+
CONFIG_MBEDTLS_AES_FEWER_TABLES=y
124125
# end of mbedTLS
125126

126127
#

0 commit comments

Comments
 (0)