mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
DHM: new functions to query the length of the modulus
Add two functions mbedtls_dhm_get_len() and mbedtls_dhm_get_bitlen() to query the length of the modulus in bytes or bits. Remove the len field: the cost of calling mbedtls_dhm_get_len() each time it's needed is negligible, and this improves the abstraction of the DHM module. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -254,14 +254,14 @@ int main( void )
|
||||
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
|
||||
n = dhm.MBEDTLS_PRIVATE(len);
|
||||
n = mbedtls_dhm_get_len( &dhm );
|
||||
if( ( ret = mbedtls_net_recv( &client_fd, buf, n ) ) != (int) n )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( ( ret = mbedtls_dhm_read_public( &dhm, buf, dhm.MBEDTLS_PRIVATE(len) ) ) != 0 )
|
||||
if( ( ret = mbedtls_dhm_read_public( &dhm, buf, n ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_dhm_read_public returned %d\n\n", ret );
|
||||
goto exit;
|
||||
|
Reference in New Issue
Block a user