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