mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 16:25:36 +00:00
Fix ret code in pk_sign.c
This commit is contained in:
parent
a0ea01d273
commit
a5236b1dd3
|
@ -30,9 +30,11 @@
|
|||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_printf printf
|
||||
#endif
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_printf printf
|
||||
#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \
|
||||
|
@ -61,6 +63,7 @@ int main( int argc, char *argv[] )
|
|||
{
|
||||
FILE *f;
|
||||
int ret = 1;
|
||||
int exit_code = MBEDTLS_EXIT_FAILURE;
|
||||
mbedtls_pk_context pk;
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
|
@ -134,14 +137,12 @@ int main( int argc, char *argv[] )
|
|||
|
||||
if( ( f = fopen( filename, "wb+" ) ) == NULL )
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( " failed\n ! Could not create %s\n\n", filename );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( fwrite( buf, 1, olen, f ) != olen )
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "failed\n ! fwrite failed\n\n" );
|
||||
fclose( f );
|
||||
goto exit;
|
||||
|
@ -151,13 +152,15 @@ int main( int argc, char *argv[] )
|
|||
|
||||
mbedtls_printf( "\n . Done (created \"%s\")\n\n", filename );
|
||||
|
||||
exit_code = MBEDTLS_EXIT_SUCCESS;
|
||||
|
||||
exit:
|
||||
mbedtls_pk_free( &pk );
|
||||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
if( ret != 0 )
|
||||
if( exit_code != MBEDTLS_EXIT_SUCCESS )
|
||||
{
|
||||
mbedtls_strerror( ret, (char *) buf, sizeof(buf) );
|
||||
mbedtls_printf( " ! Last error was: %s\n", buf );
|
||||
|
@ -169,7 +172,7 @@ exit:
|
|||
fflush( stdout ); getchar();
|
||||
#endif
|
||||
|
||||
return( ret ? EXIT_FAILURE : EXIT_SUCCESS );
|
||||
return( exit_code );
|
||||
}
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C &&
|
||||
MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&
|
||||
|
|
Loading…
Reference in a new issue