From 599aff024b333d23cdc0a49447afc8a1c7266eb3 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Wed, 6 Jul 2022 03:26:55 -0400 Subject: [PATCH] [nrf fromtree] Clarify the need for calling mbedtls_ssl_derive_keys after extension parsing Use a more straightforward condition to note that session resumption is happening. Co-authored-by: Ronald Cron Signed-off-by: Andrzej Kurek Signed-off-by: Georgios Vasilakis (cherry picked from commit 21b50808cdc379cee4533c4b4bddd75a56a246e5) --- library/ssl_cli.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index b17dea0a86..c28da61e4f 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -2368,7 +2368,12 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) } } - if( ssl->state == MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC ) + /* + * mbedtls_ssl_derive_keys() has to be called after the parsing of the + * extensions. It sets the transform data for the resumed session which in + * case of DTLS includes the server CID extracted from the CID extension. + */ + if( ssl->handshake->resume ) { if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) {