mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-23 20:20:59 +00:00
Added missing MPI_CHK around mpi functions
This commit is contained in:
parent
243d61894c
commit
7890e62a1f
|
@ -85,7 +85,7 @@ int asn1_write_mpi( unsigned char **p, unsigned char *start, mpi *X )
|
|||
return( POLARSSL_ERR_ASN1_BUF_TOO_SMALL );
|
||||
|
||||
(*p) -= len;
|
||||
mpi_write_binary( X, *p, len );
|
||||
MPI_CHK( mpi_write_binary( X, *p, len ) );
|
||||
|
||||
// DER format assumes 2s complement for numbers, so the leftmost bit
|
||||
// should be 0 for positive numbers and 1 for negative numbers.
|
||||
|
@ -102,7 +102,10 @@ int asn1_write_mpi( unsigned char **p, unsigned char *start, mpi *X )
|
|||
ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) );
|
||||
ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_INTEGER ) );
|
||||
|
||||
return( len );
|
||||
ret = (int) len;
|
||||
|
||||
cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
int asn1_write_null( unsigned char **p, unsigned char *start )
|
||||
|
|
|
@ -75,8 +75,9 @@ static int dhm_check_range( const mpi *param, const mpi *P )
|
|||
int ret = POLARSSL_ERR_DHM_BAD_INPUT_DATA;
|
||||
|
||||
mpi_init( &L ); mpi_init( &U );
|
||||
mpi_lset( &L, 2 );
|
||||
mpi_sub_int( &U, P, 2 );
|
||||
|
||||
MPI_CHK( mpi_lset( &L, 2 ) );
|
||||
MPI_CHK( mpi_sub_int( &U, P, 2 ) );
|
||||
|
||||
if( mpi_cmp_mpi( param, &L ) >= 0 &&
|
||||
mpi_cmp_mpi( param, &U ) <= 0 )
|
||||
|
@ -84,8 +85,8 @@ static int dhm_check_range( const mpi *param, const mpi *P )
|
|||
ret = 0;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
mpi_free( &L ); mpi_free( &U );
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
@ -139,7 +140,7 @@ int dhm_make_params( dhm_context *ctx, int x_size,
|
|||
mpi_fill_random( &ctx->X, x_size, f_rng, p_rng );
|
||||
|
||||
while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
|
||||
mpi_shift_r( &ctx->X, 1 );
|
||||
MPI_CHK( mpi_shift_r( &ctx->X, 1 ) );
|
||||
|
||||
if( count++ > 10 )
|
||||
return( POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED );
|
||||
|
@ -225,7 +226,7 @@ int dhm_make_public( dhm_context *ctx, int x_size,
|
|||
mpi_fill_random( &ctx->X, x_size, f_rng, p_rng );
|
||||
|
||||
while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
|
||||
mpi_shift_r( &ctx->X, 1 );
|
||||
MPI_CHK( mpi_shift_r( &ctx->X, 1 ) );
|
||||
|
||||
if( count++ > 10 )
|
||||
return( POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED );
|
||||
|
|
|
@ -1424,6 +1424,7 @@ static int myrand( void *rng_state, unsigned char *output, size_t len )
|
|||
*/
|
||||
int rsa_self_test( int verbose )
|
||||
{
|
||||
int ret = 0;
|
||||
size_t len;
|
||||
rsa_context rsa;
|
||||
unsigned char rsa_plaintext[PT_LEN];
|
||||
|
@ -1436,14 +1437,14 @@ int rsa_self_test( int verbose )
|
|||
rsa_init( &rsa, RSA_PKCS_V15, 0 );
|
||||
|
||||
rsa.len = KEY_LEN;
|
||||
mpi_read_string( &rsa.N , 16, RSA_N );
|
||||
mpi_read_string( &rsa.E , 16, RSA_E );
|
||||
mpi_read_string( &rsa.D , 16, RSA_D );
|
||||
mpi_read_string( &rsa.P , 16, RSA_P );
|
||||
mpi_read_string( &rsa.Q , 16, RSA_Q );
|
||||
mpi_read_string( &rsa.DP, 16, RSA_DP );
|
||||
mpi_read_string( &rsa.DQ, 16, RSA_DQ );
|
||||
mpi_read_string( &rsa.QP, 16, RSA_QP );
|
||||
MPI_CHK( mpi_read_string( &rsa.N , 16, RSA_N ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.E , 16, RSA_E ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.D , 16, RSA_D ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.P , 16, RSA_P ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.Q , 16, RSA_Q ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.DP, 16, RSA_DP ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.DQ, 16, RSA_DQ ) );
|
||||
MPI_CHK( mpi_read_string( &rsa.QP, 16, RSA_QP ) );
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( " RSA key validation: " );
|
||||
|
@ -1523,9 +1524,9 @@ int rsa_self_test( int verbose )
|
|||
printf( "passed\n\n" );
|
||||
#endif /* POLARSSL_SHA1_C */
|
||||
|
||||
cleanup:
|
||||
rsa_free( &rsa );
|
||||
|
||||
return( 0 );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue