mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:15:38 +01:00
Adapt uses of mbedtls_rsa_complete
to removed PRNG argument
This commit is contained in:
parent
f9e184b9df
commit
7f25f850ac
@ -540,7 +540,7 @@ static int pk_get_rsapubkey( unsigned char **p,
|
||||
|
||||
*p += len;
|
||||
|
||||
if( ( ret = mbedtls_rsa_complete( rsa, NULL, NULL ) ) != 0 )
|
||||
if( ( ret = mbedtls_rsa_complete( rsa ) ) != 0 )
|
||||
return( MBEDTLS_ERR_PK_INVALID_PUBKEY );
|
||||
|
||||
if( *p != end )
|
||||
@ -745,7 +745,7 @@ static int pk_parse_key_pkcs1_der( mbedtls_rsa_context *rsa,
|
||||
p += len;
|
||||
|
||||
/* Complete the RSA private key */
|
||||
if( ( ret = mbedtls_rsa_complete( rsa, NULL, NULL ) ) != 0 )
|
||||
if( ( ret = mbedtls_rsa_complete( rsa ) ) != 0 )
|
||||
goto cleanup;
|
||||
|
||||
/* Check optional parameters */
|
||||
|
@ -2549,7 +2549,7 @@ int mbedtls_rsa_self_test( int verbose )
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &K, 16, RSA_E ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_rsa_import( &rsa, NULL, NULL, NULL, NULL, &K ) );
|
||||
|
||||
MBEDTLS_MPI_CHK( mbedtls_rsa_complete( &rsa, NULL, NULL ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_rsa_complete( &rsa ) );
|
||||
|
||||
if( verbose != 0 )
|
||||
mbedtls_printf( " RSA key validation: " );
|
||||
|
@ -149,8 +149,7 @@ int main( void )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( ( ret = mbedtls_rsa_complete( &rsa, mbedtls_ctr_drbg_random,
|
||||
&ctr_drbg ) ) != 0 )
|
||||
if( ( ret = mbedtls_rsa_complete( &rsa ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
|
||||
ret );
|
||||
|
@ -142,8 +142,7 @@ int main( int argc, char *argv[] )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( ( return_val = mbedtls_rsa_complete( &rsa, mbedtls_ctr_drbg_random,
|
||||
&ctr_drbg ) ) != 0 )
|
||||
if( ( return_val = mbedtls_rsa_complete( &rsa ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
|
||||
return_val );
|
||||
|
@ -115,7 +115,7 @@ int main( int argc, char *argv[] )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( ( ret = mbedtls_rsa_complete( &rsa, NULL, NULL ) ) != 0 )
|
||||
if( ( ret = mbedtls_rsa_complete( &rsa ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
|
||||
ret );
|
||||
|
@ -361,7 +361,7 @@ void pk_rsa_decrypt_test_vec( char *cipher_hex, int mod,
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_import( rsa, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( rsa ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( rsa, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( rsa ) == 0 );
|
||||
|
||||
/* decryption test */
|
||||
memset( output, 0, sizeof( output ) );
|
||||
|
@ -86,7 +86,7 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char *input_P,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
unhexify( message_str, message_hex_string );
|
||||
@ -142,7 +142,7 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char *input_P, int radix_Q,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
msg_len = unhexify( message_str, message_hex_string );
|
||||
|
@ -87,7 +87,7 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char *input_P,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
unhexify( message_str, message_hex_string );
|
||||
@ -143,7 +143,7 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char *input_P, int radix_Q,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
msg_len = unhexify( message_str, message_hex_string );
|
||||
|
@ -47,7 +47,7 @@ void mbedtls_rsa_pkcs1_sign( char *message_hex_string, int padding_mode, int dig
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
msg_len = unhexify( message_str, message_hex_string );
|
||||
@ -146,7 +146,7 @@ void rsa_pkcs1_sign_raw( char *message_hex_string, char *hash_result_string,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
unhexify( message_str, message_hex_string );
|
||||
@ -363,7 +363,7 @@ void mbedtls_rsa_pkcs1_decrypt( char *message_hex_string, int padding_mode, int
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
unhexify( message_str, message_hex_string );
|
||||
@ -471,7 +471,7 @@ void mbedtls_rsa_private( char *message_hex_string, int mod, int radix_P, char *
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||
|
||||
unhexify( message_str, message_hex_string );
|
||||
@ -916,9 +916,7 @@ void mbedtls_rsa_import( int radix_N, char *input_N,
|
||||
have_E ? &E : NULL ) == 0 );
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx,
|
||||
mbedtls_ctr_drbg_random,
|
||||
&ctr_drbg ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == result );
|
||||
|
||||
/* On expected success, perform some public and private
|
||||
* key operations to check if the key is working properly. */
|
||||
@ -1029,7 +1027,7 @@ void mbedtls_rsa_export( int radix_N, char *input_N,
|
||||
strlen( input_D ) ? &D : NULL,
|
||||
strlen( input_E ) ? &E : NULL ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
|
||||
/*
|
||||
* Export parameters and compare to original ones.
|
||||
@ -1220,7 +1218,7 @@ void mbedtls_rsa_export_raw( char *input_N, char *input_P,
|
||||
have_D ? bufD : NULL, lenD,
|
||||
have_E ? bufE : NULL, lenE ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx, NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
|
||||
|
||||
/*
|
||||
* Export parameters and compare to original ones.
|
||||
@ -1382,9 +1380,7 @@ void mbedtls_rsa_import_raw( char *input_N,
|
||||
( lenE > 0 ) ? bufE : NULL, lenE ) == 0 );
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx,
|
||||
mbedtls_ctr_drbg_random,
|
||||
&ctr_drbg ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == result );
|
||||
|
||||
/* On expected success, perform some public and private
|
||||
* key operations to check if the key is working properly. */
|
||||
|
Loading…
Reference in New Issue
Block a user