mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 00:05:36 +01:00
Reduce stack usage of test_suite_rsa
Reduce the stack usage of the `test_suite_rsa` by reducing the size of the buffers used in the tests, to a reasonable big enough size, and change the data size to decrypt in the data file.
This commit is contained in:
parent
5533f4aff1
commit
e4c5fa74b8
@ -264,7 +264,7 @@ mbedtls_rsa_pkcs1_encrypt:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_RSA_PKCS_V1
|
||||
|
||||
RSA PKCS1 Decrypt #1 (Verify)
|
||||
depends_on:MBEDTLS_PKCS1_V15
|
||||
mbedtls_rsa_pkcs1_decrypt:"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":1000:"4E636AF98E40F3ADCFCCB698F4E80B9F":0
|
||||
mbedtls_rsa_pkcs1_decrypt:"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":32:"4E636AF98E40F3ADCFCCB698F4E80B9F":0
|
||||
|
||||
RSA PKCS1 Encrypt #2 (Data too large)
|
||||
depends_on:MBEDTLS_PKCS1_V15
|
||||
@ -272,7 +272,7 @@ mbedtls_rsa_pkcs1_encrypt:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c
|
||||
|
||||
RSA PKCS1 Decrypt #2 (Data too small)
|
||||
depends_on:MBEDTLS_PKCS1_V15
|
||||
mbedtls_rsa_pkcs1_decrypt:"deadbeafcafedeadbeeffedcba9876":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":1000:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_ERR_RSA_PRIVATE_FAILED + MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
mbedtls_rsa_pkcs1_decrypt:"deadbeafcafedeadbeeffedcba9876":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":32:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_ERR_RSA_PRIVATE_FAILED + MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
RSA PKCS1 Decrypt #4 (Output buffer too small)
|
||||
depends_on:MBEDTLS_PKCS1_V15
|
||||
|
@ -472,8 +472,8 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode,
|
||||
char * input_N, int radix_E, char * input_E,
|
||||
data_t * result_hex_str, int result )
|
||||
{
|
||||
unsigned char hash_result[1000];
|
||||
unsigned char output[1000];
|
||||
unsigned char hash_result[MBEDTLS_MD_MAX_SIZE];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
rnd_pseudo_info rnd_info;
|
||||
@ -482,8 +482,8 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode,
|
||||
mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
|
||||
mbedtls_rsa_init( &ctx, padding_mode, 0 );
|
||||
|
||||
memset( hash_result, 0x00, 1000 );
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( hash_result, 0x00, sizeof( hash_result ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
|
||||
@ -522,14 +522,14 @@ void mbedtls_rsa_pkcs1_verify( data_t * message_str, int padding_mode,
|
||||
char * input_N, int radix_E, char * input_E,
|
||||
data_t * result_str, int result )
|
||||
{
|
||||
unsigned char hash_result[1000];
|
||||
unsigned char hash_result[MBEDTLS_MD_MAX_SIZE];
|
||||
mbedtls_rsa_context ctx;
|
||||
|
||||
mbedtls_mpi N, E;
|
||||
|
||||
mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
|
||||
mbedtls_rsa_init( &ctx, padding_mode, 0 );
|
||||
memset( hash_result, 0x00, 1000 );
|
||||
memset( hash_result, 0x00, sizeof( hash_result ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
|
||||
@ -557,7 +557,7 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
|
||||
int radix_N, char * input_N, int radix_E,
|
||||
char * input_E, data_t * result_hex_str )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
rnd_pseudo_info rnd_info;
|
||||
@ -566,7 +566,7 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
|
||||
mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
|
||||
mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
|
||||
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
|
||||
@ -593,7 +593,7 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
|
||||
if( padding_mode == MBEDTLS_RSA_PKCS_V15 )
|
||||
{
|
||||
int res;
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output) );
|
||||
|
||||
res = mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx,
|
||||
&rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE,
|
||||
@ -627,7 +627,7 @@ void rsa_pkcs1_verify_raw( data_t * hash_result,
|
||||
char * input_N, int radix_E, char * input_E,
|
||||
data_t * result_str, int correct )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
|
||||
mbedtls_mpi N, E;
|
||||
@ -688,7 +688,7 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode,
|
||||
int radix_E, char * input_E,
|
||||
data_t * result_hex_str, int result )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
rnd_pseudo_info rnd_info;
|
||||
|
||||
@ -698,7 +698,7 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode,
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
|
||||
mbedtls_rsa_init( &ctx, padding_mode, 0 );
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
|
||||
@ -729,14 +729,14 @@ void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode,
|
||||
int radix_E, char * input_E,
|
||||
data_t * result_hex_str, int result )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
|
||||
mbedtls_mpi N, E;
|
||||
|
||||
mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
|
||||
mbedtls_rsa_init( &ctx, padding_mode, 0 );
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
|
||||
@ -769,7 +769,7 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode,
|
||||
int max_output, data_t * result_hex_str,
|
||||
int result )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[32];
|
||||
mbedtls_rsa_context ctx;
|
||||
size_t output_len;
|
||||
rnd_pseudo_info rnd_info;
|
||||
@ -780,7 +780,7 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode,
|
||||
|
||||
mbedtls_rsa_init( &ctx, padding_mode, 0 );
|
||||
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
|
||||
|
||||
@ -815,7 +815,7 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N,
|
||||
char * input_N, int radix_E, char * input_E,
|
||||
data_t * result_hex_str, int result )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */
|
||||
|
||||
mbedtls_mpi N, E;
|
||||
@ -823,7 +823,7 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N,
|
||||
mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
|
||||
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 );
|
||||
mbedtls_rsa_init( &ctx2, MBEDTLS_RSA_PKCS_V15, 0 );
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
|
||||
@ -847,7 +847,7 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx2 ) == 0 );
|
||||
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
TEST_ASSERT( mbedtls_rsa_public( &ctx2, message_str->x, output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
@ -869,7 +869,7 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
|
||||
char * input_E, data_t * result_hex_str,
|
||||
int result )
|
||||
{
|
||||
unsigned char output[1000];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
rnd_pseudo_info rnd_info;
|
||||
@ -896,7 +896,7 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
|
||||
/* repeat three times to test updating of blinding values */
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
TEST_ASSERT( mbedtls_rsa_private( &ctx, rnd_pseudo_rand, &rnd_info,
|
||||
message_str->x, output ) == result );
|
||||
if( result == 0 )
|
||||
@ -913,7 +913,7 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx2 ) == 0 );
|
||||
|
||||
memset( output, 0x00, 1000 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
TEST_ASSERT( mbedtls_rsa_private( &ctx2, rnd_pseudo_rand, &rnd_info,
|
||||
message_str->x, output ) == result );
|
||||
if( result == 0 )
|
||||
@ -1577,11 +1577,11 @@ void mbedtls_rsa_export_raw( data_t *input_N, data_t *input_P,
|
||||
int successive )
|
||||
{
|
||||
/* Exported buffers */
|
||||
unsigned char bufNe[1000];
|
||||
unsigned char bufPe[1000];
|
||||
unsigned char bufQe[1000];
|
||||
unsigned char bufDe[1000];
|
||||
unsigned char bufEe[1000];
|
||||
unsigned char bufNe[256];
|
||||
unsigned char bufPe[128];
|
||||
unsigned char bufQe[128];
|
||||
unsigned char bufDe[256];
|
||||
unsigned char bufEe[1];
|
||||
|
||||
mbedtls_rsa_context ctx;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user