mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-07 15:09:28 +01:00
- Added rsa random deadlock test
This commit is contained in:
parent
a0f082c574
commit
a665685abf
2 changed files with 44 additions and 0 deletions
|
|
@ -16,6 +16,14 @@ static int myrand( void *rng_state )
|
|||
|
||||
return( rand() );
|
||||
}
|
||||
|
||||
static int badrand( void *rng_state )
|
||||
{
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
END_HEADER
|
||||
|
||||
BEGIN_CASE
|
||||
|
|
@ -281,6 +289,39 @@ rsa_pkcs1_encrypt:message_hex_string:padding_mode:mod:radix_N:input_N:radix_E:in
|
|||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
rsa_pkcs1_encrypt_bad_rng:message_hex_string:padding_mode:mod:radix_N:input_N:radix_E:input_E:result_hex_str:result
|
||||
{
|
||||
unsigned char message_str[1000];
|
||||
unsigned char output[1000];
|
||||
unsigned char output_str[1000];
|
||||
rsa_context ctx;
|
||||
int msg_len;
|
||||
int res;
|
||||
|
||||
rsa_init( &ctx, {padding_mode}, 0, &badrand, NULL );
|
||||
memset( message_str, 0x00, 1000 );
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output_str, 0x00, 1000 );
|
||||
|
||||
ctx.len = {mod} / 8;
|
||||
TEST_ASSERT( mpi_read_string( &ctx.N, {radix_N}, {input_N} ) == 0 );
|
||||
TEST_ASSERT( mpi_read_string( &ctx.E, {radix_E}, {input_E} ) == 0 );
|
||||
|
||||
TEST_ASSERT( rsa_check_pubkey( &ctx ) == 0 );
|
||||
|
||||
msg_len = unhexify( message_str, {message_hex_string} );
|
||||
|
||||
TEST_ASSERT( rsa_pkcs1_encrypt( &ctx, RSA_PUBLIC, msg_len, message_str, output ) == {result} );
|
||||
if( {result} == 0 )
|
||||
{
|
||||
hexify( output_str, output, ctx.len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) output_str, {result_hex_str} ) == 0 );
|
||||
}
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
rsa_pkcs1_decrypt:message_hex_string:padding_mode:mod:radix_P:input_P:radix_Q:input_Q:radix_N:input_N:radix_E:input_E:max_output:result_hex_str:result
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue