1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Fix bug in DHE-PSK PMS computation

This commit is contained in:
Manuel Pégourié-Gonnard
2014-06-23 17:56:08 +02:00
committed by Paul Bakker
parent 5c1f032653
commit 8df68632e8
2 changed files with 8 additions and 3 deletions

View File

@@ -913,14 +913,16 @@ int ssl_psk_derive_premaster( ssl_context *ssl, key_exchange_type_t key_ex )
if( end - p < 2 + (int) len )
return( POLARSSL_ERR_SSL_BAD_INPUT_DATA );
*(p++) = (unsigned char)( len >> 8 );
*(p++) = (unsigned char)( len );
/* Write length only when we know the actual value */
if( ( ret = dhm_calc_secret( &ssl->handshake->dhm_ctx,
p, &len, ssl->f_rng, ssl->p_rng ) ) != 0 )
p + 2, &len,
ssl->f_rng, ssl->p_rng ) ) != 0 )
{
SSL_DEBUG_RET( 1, "dhm_calc_secret", ret );
return( ret );
}
*(p++) = (unsigned char)( len >> 8 );
*(p++) = (unsigned char)( len );
p += len;
SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K );