Change ssl_set_psk() to act on ssl_config

This commit is contained in:
Manuel Pégourié-Gonnard 2015-05-07 17:07:50 +01:00
parent 4b68296626
commit 120fdbdb3d
4 changed files with 16 additions and 16 deletions

View file

@ -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 );

View file

@ -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 );
}

View file

@ -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 )
{

View file

@ -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 )