From 863fe9b50bb137c24cf72d3d35cb5398644530e0 Mon Sep 17 00:00:00 2001 From: mariemC Date: Thu, 21 Mar 2024 17:54:25 +0100 Subject: [PATCH 1/2] sys/include/net/sock: add Macros for dtls extensions --- sys/include/net/sock/dtls.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/include/net/sock/dtls.h b/sys/include/net/sock/dtls.h index 9daa432a9fc5..f3729c23b799 100644 --- a/sys/include/net/sock/dtls.h +++ b/sys/include/net/sock/dtls.h @@ -573,6 +573,20 @@ extern "C" { */ #define SOCK_DTLS_HANDSHAKE (EXDEV) +/** + * @brief Force extended master secret extension + */ +#ifndef CONFIG_DTLS_FORCE_EXTENDED_MASTER_SECRET +#define CONFIG_DTLS_FORCE_EXTENDED_MASTER_SECRET 1 +#endif + +/** + * @brief Force renegotiation info extension + */ +#ifndef CONFIG_DTLS_FORCE_RENEGOTIATION_INFO +#define CONFIG_DTLS_FORCE_RENEGOTIATION_INFO 1 +#endif + /** * @brief DTLS version number * @anchor sock_dtls_prot_version From 208e757d33cd2725e866a4d36f3f511ea1d3fb19 Mon Sep 17 00:00:00 2001 From: mariemC Date: Thu, 21 Mar 2024 17:55:44 +0100 Subject: [PATCH 2/2] pkg/tinydtls/contrib: add get user params --- pkg/tinydtls/contrib/sock_dtls.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/tinydtls/contrib/sock_dtls.c b/pkg/tinydtls/contrib/sock_dtls.c index 960c30a4302f..42c503fd11b8 100644 --- a/pkg/tinydtls/contrib/sock_dtls.c +++ b/pkg/tinydtls/contrib/sock_dtls.c @@ -59,7 +59,8 @@ static int _read(struct dtls_context_t *ctx, session_t *session, uint8_t *buf, size_t len); static int _event(struct dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code); - +static void _get_user_parameters(struct dtls_context_t *ctx, + session_t *session, dtls_user_parameters_t *user_parameters); static void _session_to_ep(const session_t *session, sock_udp_ep_t *ep); static void _ep_to_session(const sock_udp_ep_t *ep, session_t *session); static uint32_t _update_timeout(uint32_t start, uint32_t timeout); @@ -68,6 +69,7 @@ static dtls_handler_t _dtls_handler = { .event = _event, .write = _write, .read = _read, + .get_user_parameters = _get_user_parameters, #ifdef CONFIG_DTLS_PSK .get_psk_info = _get_psk_info, #endif /* CONFIG_DTLS_PSK */ @@ -175,6 +177,15 @@ static int _event(struct dtls_context_t *ctx, session_t *session, return 0; } +static void _get_user_parameters(struct dtls_context_t *ctx, + session_t *session, dtls_user_parameters_t *user_parameters) { + (void) ctx; + (void) session; + + user_parameters->force_extended_master_secret = CONFIG_DTLS_FORCE_EXTENDED_MASTER_SECRET; + user_parameters->force_renegotiation_info = CONFIG_DTLS_FORCE_RENEGOTIATION_INFO; +} + #ifdef CONFIG_DTLS_PSK static int _get_psk_info(struct dtls_context_t *ctx, const session_t *session, dtls_credentials_type_t type,