Better usage of dhm_calc_secret in SSL

This commit is contained in:
Manuel Pégourié-Gonnard 2014-06-23 18:07:11 +02:00 committed by Paul Bakker
parent 8df68632e8
commit dd0c0f33c0
3 changed files with 3 additions and 6 deletions

View file

@ -2055,7 +2055,7 @@ static int ssl_write_client_key_exchange( ssl_context *ssl )
SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->handshake->dhm_ctx.X ); SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->handshake->dhm_ctx.X );
SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->handshake->dhm_ctx.GX ); SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->handshake->dhm_ctx.GX );
ssl->handshake->pmslen = ssl->handshake->dhm_ctx.len; ssl->handshake->pmslen = POLARSSL_PREMASTER_SIZE;
if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx, if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx,
ssl->handshake->premaster, ssl->handshake->premaster,

View file

@ -2743,7 +2743,7 @@ static int ssl_parse_client_key_exchange( ssl_context *ssl )
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );
} }
ssl->handshake->pmslen = ssl->handshake->dhm_ctx.len; ssl->handshake->pmslen = POLARSSL_PREMASTER_SIZE;
if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx, if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx,
ssl->handshake->premaster, ssl->handshake->premaster,

View file

@ -908,10 +908,7 @@ int ssl_psk_derive_premaster( ssl_context *ssl, key_exchange_type_t key_ex )
if( key_ex == POLARSSL_KEY_EXCHANGE_DHE_PSK ) if( key_ex == POLARSSL_KEY_EXCHANGE_DHE_PSK )
{ {
int ret; int ret;
size_t len = ssl->handshake->dhm_ctx.len; size_t len = end - ( p + 2 );
if( end - p < 2 + (int) len )
return( POLARSSL_ERR_SSL_BAD_INPUT_DATA );
/* Write length only when we know the actual value */ /* Write length only when we know the actual value */
if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx, if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx,