From 21e98b411483008af877d2e85f20ee4d8bcb8393 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 23 Oct 2018 15:26:40 +0100 Subject: [PATCH] Skip PMS generation on client if opaque PSK is used For opaque PSKs, the PSK-to-MS expansion is performed atomatically on the PSA-side. --- library/ssl_cli.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 90cafebe8..3f91d4f5b 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -3165,6 +3165,17 @@ ecdh_calc_secret: return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } +#if defined(MBEDTLS_USE_PSA_CRYPTO) && \ + defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK && + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && + ssl_conf_has_raw_psk( ssl->conf ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "skip PMS generation for opaque PSK" ) ); + } + else +#endif /* MBEDTLS_USE_PSA_CRYPTO && + MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, ciphersuite_info->key_exchange ) ) != 0 ) {