diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index e098bc9b5..86b061da4 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1590,7 +1590,7 @@ int mbedtls_ssl_set_own_cert( mbedtls_ssl_context *ssl, mbedtls_x509_crt *own_ce * \note This is mainly useful for clients. Servers will usually * want to use \c mbedtls_ssl_set_psk_cb() instead. * - * \param ssl SSL context + * \param conf SSL configuration * \param psk pointer to the pre-shared key * \param psk_len pre-shared key length * \param psk_identity pointer to the pre-shared key identity @@ -1598,7 +1598,7 @@ int mbedtls_ssl_set_own_cert( mbedtls_ssl_context *ssl, mbedtls_x509_crt *own_ce * * \return 0 if successful or MBEDTLS_ERR_SSL_MALLOC_FAILED */ -int mbedtls_ssl_set_psk( mbedtls_ssl_context *ssl, +int mbedtls_ssl_set_psk( mbedtls_ssl_config *conf, const unsigned char *psk, size_t psk_len, const unsigned char *psk_identity, size_t psk_identity_len ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index d3ec5dcf5..1d2593b78 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5362,7 +5362,7 @@ int mbedtls_ssl_set_own_cert( mbedtls_ssl_context *ssl, mbedtls_x509_crt *own_ce #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) -int mbedtls_ssl_set_psk( mbedtls_ssl_context *ssl, +int mbedtls_ssl_set_psk( mbedtls_ssl_config *conf, const unsigned char *psk, size_t psk_len, const unsigned char *psk_identity, size_t psk_identity_len ) { @@ -5372,25 +5372,25 @@ int mbedtls_ssl_set_psk( mbedtls_ssl_context *ssl, if( psk_len > MBEDTLS_PSK_MAX_LEN ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - if( ssl->conf->psk != NULL || ssl->conf->psk_identity != NULL ) + if( conf->psk != NULL || conf->psk_identity != NULL ) { - mbedtls_free( ssl->conf->psk ); - mbedtls_free( ssl->conf->psk_identity ); + mbedtls_free( conf->psk ); + mbedtls_free( conf->psk_identity ); } - if( ( ssl->conf->psk = mbedtls_malloc( psk_len ) ) == NULL || - ( ssl->conf->psk_identity = mbedtls_malloc( psk_identity_len ) ) == NULL ) + if( ( conf->psk = mbedtls_malloc( psk_len ) ) == NULL || + ( conf->psk_identity = mbedtls_malloc( psk_identity_len ) ) == NULL ) { - mbedtls_free( ssl->conf->psk ); - ssl->conf->psk = NULL; + mbedtls_free( conf->psk ); + conf->psk = NULL; return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); } - ssl->conf->psk_len = psk_len; - ssl->conf->psk_identity_len = psk_identity_len; + conf->psk_len = psk_len; + conf->psk_identity_len = psk_identity_len; - memcpy( ssl->conf->psk, psk, ssl->conf->psk_len ); - memcpy( ssl->conf->psk_identity, psk_identity, ssl->conf->psk_identity_len ); + memcpy( conf->psk, psk, conf->psk_len ); + memcpy( conf->psk_identity, psk_identity, conf->psk_identity_len ); return( 0 ); } diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 0181a2fe5..494fa72cd 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1173,7 +1173,7 @@ int main( int argc, char *argv[] ) #endif #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) - if( ( ret = mbedtls_ssl_set_psk( &ssl, psk, psk_len, + if( ( ret = mbedtls_ssl_set_psk( &conf, psk, psk_len, (const unsigned char *) opt.psk_identity, strlen( opt.psk_identity ) ) ) != 0 ) { diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 12614c128..f4c206ece 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1705,7 +1705,7 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) if( strlen( opt.psk ) != 0 && strlen( opt.psk_identity ) != 0 ) { - ret = mbedtls_ssl_set_psk( &ssl, psk, psk_len, + ret = mbedtls_ssl_set_psk( &conf, psk, psk_len, (const unsigned char *) opt.psk_identity, strlen( opt.psk_identity ) ); if( ret != 0 )