Skip to content

crypto/mbedtls: Allow a minimal crypto-only configuration. - #3848

Merged
acassis merged 2 commits into
apache:masterfrom
railab:mbedtls-minimal
Oct 16, 2026
Merged

acassis merged 2 commits into
apache:masterfrom
railab:mbedtls-minimal

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

Summary

Mbed TLS defaults suit full TLS stacks. Libraries that only need a few primitives, such as NimBLE, still build every cipher and curve, and the generic cipher layer links them all.

Add MBEDTLS_MINIMAL, which turns all optional module defaults off so only selected or explicitly enabled options are built. Make the modules that were always defined in mbedtls_config.h configurable, defaulting to enabled unless MBEDTLS_MINIMAL is set. Add options for MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH, MBEDTLS_AES_FEWER_TABLES and MBEDTLS_BLOCK_CIPHER_NO_DECRYPT.

Without MBEDTLS_MINIMAL the configuration is unchanged.

Impact

mbedtls is required for new nimble, but without size optimization it takes huge amount of memory

Testing

Tested: nrf54l15-tag NimBLE mesh build; the linked Mbed TLS for NimBLE shrinks from 57 KB flash and 9 KB RAM to about 21 KB flash and no RAM.

cederom
cederom previously approved these changes Oct 14, 2026

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THank you @raiden00pl :-)

Mbed TLS defaults suit full TLS stacks. Libraries that only need a few
primitives, such as NimBLE, still build every cipher and curve, and the
generic cipher layer links them all.

Add MBEDTLS_MINIMAL, which turns all optional module defaults off so
only selected or explicitly enabled options are built. Make the modules
that were always defined in mbedtls_config.h configurable, defaulting
to enabled unless MBEDTLS_MINIMAL is set. Add options for
MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH, MBEDTLS_AES_FEWER_TABLES and
MBEDTLS_BLOCK_CIPHER_NO_DECRYPT.

Without MBEDTLS_MINIMAL the configuration is unchanged.

Tested: nrf54l15-tag NimBLE mesh build; the linked Mbed TLS for NimBLE
shrinks from 57 KB flash and 9 KB RAM to about 21 KB flash and no RAM.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: raiden00pl <[email protected]>
fix codespell issue

Signed-off-by: raiden00pl <[email protected]>
@jerpelea

Copy link
Copy Markdown
Contributor

Thanks for this addition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants