diff --git a/include/mbedtls/ssl_internal.h b/include/mbedtls/ssl_internal.h index fb8c23fee..1e58ca3eb 100644 --- a/include/mbedtls/ssl_internal.h +++ b/include/mbedtls/ssl_internal.h @@ -945,6 +945,8 @@ static inline int mbedtls_ssl_get_psk( const mbedtls_ssl_context *ssl, else { + *psk = NULL; + *psk_len = 0; return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); } diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 6dabd3409..4a8686cc4 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -1848,7 +1848,7 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch { unsigned char *p = ssl->handshake->premaster; unsigned char *end = p + sizeof( ssl->handshake->premaster ); - const unsigned char *psk; + const unsigned char *psk = NULL; size_t psk_len = 0; if( mbedtls_ssl_get_psk( ssl, &psk, &psk_len )