mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-29 02:37:13 +01:00
Avoid in-out length in dhm_calc_secret()
This commit is contained in:
parent
f79b425226
commit
3335205a21
9 changed files with 20 additions and 28 deletions
|
|
@ -243,8 +243,7 @@ int main( void )
|
|||
mbedtls_printf( "\n . Shared secret: " );
|
||||
fflush( stdout );
|
||||
|
||||
n = dhm.len;
|
||||
if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, &n,
|
||||
if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &n,
|
||||
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret );
|
||||
|
|
|
|||
|
|
@ -228,7 +228,6 @@ int main( void )
|
|||
fflush( stdout );
|
||||
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
n = dhm.len;
|
||||
|
||||
if( ( ret = mbedtls_net_recv( &client_fd, buf, n ) ) != (int) n )
|
||||
{
|
||||
|
|
@ -248,7 +247,7 @@ int main( void )
|
|||
mbedtls_printf( "\n . Shared secret: " );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, &n,
|
||||
if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &n,
|
||||
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret );
|
||||
|
|
|
|||
|
|
@ -646,15 +646,13 @@ int main( int argc, char *argv[] )
|
|||
|
||||
mbedtls_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] );
|
||||
TIME_PUBLIC( title, "handshake",
|
||||
olen = sizeof( buf );
|
||||
ret |= mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len,
|
||||
myrand, NULL );
|
||||
ret |= mbedtls_dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) );
|
||||
ret |= mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &olen, myrand, NULL ) );
|
||||
|
||||
mbedtls_snprintf( title, sizeof( title ), "DH-%d", dhm_sizes[i] );
|
||||
TIME_PUBLIC( title, "handshake",
|
||||
olen = sizeof( buf );
|
||||
ret |= mbedtls_dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) );
|
||||
ret |= mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &olen, myrand, NULL ) );
|
||||
|
||||
mbedtls_dhm_free( &dhm );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue