Fix ret code in dh_client.c

This commit is contained in:
Andres Amaya Garcia 2018-04-29 19:23:39 +01:00
parent 4c47df6f3f
commit 898841dc71

View file

@ -29,9 +29,12 @@
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_printf printf
#define mbedtls_time_t time_t
#endif
#include <stdlib.h>
#define mbedtls_printf printf
#define mbedtls_time_t time_t
#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */
#if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \
defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \
@ -71,7 +74,8 @@ int main( void )
{
FILE *f;
int ret;
int ret = 1;
int exit_code = MBEDTLS_EXIT_FAILURE;
size_t n, buflen;
mbedtls_net_context server_fd;
@ -115,7 +119,6 @@ int main( void )
if( ( f = fopen( "rsa_pub.txt", "rb" ) ) == NULL )
{
ret = 1;
mbedtls_printf( " failed\n ! Could not open rsa_pub.txt\n" \
" ! Please run rsa_genkey first\n\n" );
goto exit;
@ -191,7 +194,6 @@ int main( void )
if( dhm.len < 64 || dhm.len > 512 )
{
ret = 1;
mbedtls_printf( " failed\n ! Invalid DHM modulus size\n\n" );
goto exit;
}
@ -286,6 +288,8 @@ int main( void )
buf[16] = '\0';
mbedtls_printf( "\n . Plaintext is \"%s\"\n\n", (char *) buf );
exit_code = MBEDTLS_EXIT_SUCCESS;
exit:
mbedtls_net_free( &server_fd );
@ -301,7 +305,7 @@ exit:
fflush( stdout ); getchar();
#endif
return( ret );
return( exit_code );
}
#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&