- Added rsa random deadlock test

This commit is contained in:
Paul Bakker 2010-07-18 19:47:14 +00:00
parent a0f082c574
commit a665685abf
2 changed files with 44 additions and 0 deletions

View file

@ -274,5 +274,8 @@ rsa_gen_key:128:2:POLARSSL_ERR_RSA_BAD_INPUT_DATA
RSA Generate Key RSA Generate Key
rsa_gen_key:1024:3:0 rsa_gen_key:1024:3:0
RSA PKCS1 Encrypt Bad RNG
rsa_pkcs1_encrypt_bad_rng:"4E636AF98E40F3ADCFCCB698F4E80B9F":RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":POLARSSL_ERR_RSA_RNG_FAILED
RSA Selftest RSA Selftest
rsa_selftest: rsa_selftest:

View file

@ -16,6 +16,14 @@ static int myrand( void *rng_state )
return( rand() ); return( rand() );
} }
static int badrand( void *rng_state )
{
if( rng_state != NULL )
rng_state = NULL;
return( 0 );
}
END_HEADER END_HEADER
BEGIN_CASE BEGIN_CASE
@ -281,6 +289,39 @@ rsa_pkcs1_encrypt:message_hex_string:padding_mode:mod:radix_N:input_N:radix_E:in
} }
END_CASE 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 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 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
{ {