mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-24 18:28:37 +00:00
Fix ret code in rsa_sign_pss.c
This commit is contained in:
parent
1a66056c77
commit
3c41e564f8
1 changed files with 10 additions and 7 deletions
|
@ -29,9 +29,12 @@
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
#else
|
#else
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define mbedtls_snprintf snprintf
|
#include <stdlib.h>
|
||||||
#define mbedtls_printf printf
|
#define mbedtls_snprintf snprintf
|
||||||
#endif
|
#define mbedtls_printf printf
|
||||||
|
#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS
|
||||||
|
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||||
|
#endif /* MBEDTLS_PLATFORM_C */
|
||||||
|
|
||||||
#if !defined(MBEDTLS_MD_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
#if !defined(MBEDTLS_MD_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
||||||
!defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \
|
!defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \
|
||||||
|
@ -61,6 +64,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;
|
||||||
|
@ -101,7 +105,6 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
if( ( ret = mbedtls_pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 )
|
if( ( ret = mbedtls_pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 )
|
||||||
{
|
{
|
||||||
ret = 1;
|
|
||||||
mbedtls_printf( " failed\n ! Could not read key from '%s'\n", argv[1] );
|
mbedtls_printf( " failed\n ! Could not read key from '%s'\n", argv[1] );
|
||||||
mbedtls_printf( " ! mbedtls_pk_parse_public_keyfile returned %d\n\n", ret );
|
mbedtls_printf( " ! mbedtls_pk_parse_public_keyfile returned %d\n\n", ret );
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -109,7 +112,6 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
if( !mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA ) )
|
if( !mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA ) )
|
||||||
{
|
{
|
||||||
ret = 1;
|
|
||||||
mbedtls_printf( " failed\n ! Key is not an RSA key\n" );
|
mbedtls_printf( " failed\n ! Key is not an RSA key\n" );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +147,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +162,8 @@ 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 );
|
||||||
|
@ -171,7 +174,7 @@ exit:
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( ret );
|
return( exit_code );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C &&
|
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_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