Mbed TLS is now part of TrustedFirmware.org.

Bugs in example program dh_server.c

Oct 13, 2017 22:24

The code is not updating the n variable to the correct size prior to attempting to get the client's public value.

The following code change fixes this issue. /* * 6. Get the client's public value: Yc = G ^ Xc mod P */ n=dhm.len; // <<<<<<<<<<<<<<<<<<<<<<<<<< Set n to the correct length >>>>>>>>>>>>>>>>>>

mbedtls_printf( "\n  . Receive the client's public value of length=%ld", n );
fflush( stdout );
memset( buf, 0, sizeof( buf ) );

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;
Oct 15, 2017 13:55
Ron Eldor

Hi Marty,
Thank you for reporting this issue!
As you can see in this PR, this issue was already raised and fixed, and pending full review and merging to the repository.
Thanks again for your alertness and interest in Mbed TLS!
Mbed TLS Team member