Skip to content

Commit c32b524

Browse files
mniestrojcfriedt
authored andcommitted
mbedtls: support configuration of PSK maximum length via Kconfig
So far maximum PSK length was configured by mbedTLS as 32 bytes. Introduce Kconfig option that will configure it instead of relying on default value from mbedTLS library, so that user can easily adjust that value to application needs. Signed-off-by: Marcin Niestroj <[email protected]>
1 parent c2524a0 commit c32b524

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

modules/mbedtls/Kconfig.tls-generic

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ config MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
7373
config MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
7474
bool "Enable the RSA-PSK based ciphersuite modes"
7575

76+
config MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED
77+
bool
78+
default y if MBEDTLS_KEY_EXCHANGE_PSK_ENABLED || \
79+
MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED || \
80+
MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED || \
81+
MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
82+
83+
config MBEDTLS_PSK_MAX_LEN
84+
int "Max size of TLS pre-shared keys"
85+
default 32
86+
depends on MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED
87+
help
88+
Max size of TLS pre-shared keys, in bytes.
89+
7690
config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
7791
bool "Enable the RSA-only based ciphersuite modes"
7892
default y if !NET_L2_OPENTHREAD

modules/mbedtls/configs/config-tls-generic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
8787
#endif
8888

89+
#if defined(CONFIG_MBEDTLS_PSK_MAX_LEN)
90+
#define MBEDTLS_PSK_MAX_LEN CONFIG_MBEDTLS_PSK_MAX_LEN
91+
#endif
92+
8993
#if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
9094
#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
9195
#endif

0 commit comments

Comments
 (0)