Reduce stack usage of test_suite_pk
Reduce the stack usage of the `test_suite_pk` by reducing the
size of the buffers used in the tests, to a reasonable big enough size.
@@ -664,7 +664,7 @@ void pk_rsa_verify_test_vec( data_t * message_str, int digest, int mod,
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 *rsa;
mbedtls_pk_context pk;
mbedtls_pk_restart_ctx *rs_ctx = NULL;
@@ -679,7 +679,7 @@ void pk_rsa_verify_test_vec( data_t * message_str, int digest, int mod,
mbedtls_pk_init( &pk );
- memset( hash_result, 0x00, 1000 );
+ memset( hash_result, 0x00, MBEDTLS_MD_MAX_SIZE );
TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 );
rsa = mbedtls_pk_rsa( pk );
@@ -713,7 +713,7 @@ void pk_rsa_verify_ext_test_vec( data_t * message_str, int digest,
data_t * result_str, int pk_type,
int mgf1_hash_id, int salt_len, int result )
{
- unsigned char hash_result[1000];
+ unsigned char hash_result[MBEDTLS_MD_MAX_SIZE];
mbedtls_rsa_context *rsa;
mbedtls_pk_context pk;
mbedtls_pk_rsassa_pss_options pss_opts;
@@ -722,7 +722,7 @@ void pk_rsa_verify_ext_test_vec( data_t * message_str, int digest,
mbedtls_pk_init( &pk );
- memset( hash_result, 0x00, 1000 );
+ memset( hash_result, 0x00, sizeof( hash_result ) );
TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 );
rsa = mbedtls_pk_rsa( pk );
@@ -976,7 +976,7 @@ void pk_rsa_encrypt_test_vec( data_t * message, int mod, int radix_N,
char * input_N, int radix_E, char * input_E,
data_t * result, int ret )
{
- unsigned char output[1000];
+ unsigned char output[300];
rnd_pseudo_info rnd_info;
mbedtls_rsa_context *rsa;
mbedtls_pk_context pk;
@@ -1011,7 +1011,7 @@ void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
int radix_N, char * input_N, int radix_E,
char * input_E, data_t * clear, int ret )
{
- unsigned char output[1000];
+ unsigned char output[256];
rnd_pseudo_info rnd_info;
mbedtls_mpi N, P, Q, E;
mbedtls_rsa_context *rsa;
@@ -1136,8 +1136,8 @@ void pk_rsa_alt( )
mbedtls_rsa_context raw;
mbedtls_pk_context rsa, alt;
mbedtls_pk_debug_item dbg_items[10];
- unsigned char hash[50], sig[1000];
- unsigned char msg[50], ciph[1000], test[1000];
+ unsigned char hash[50], sig[64];
+ unsigned char msg[50], ciph[64], test[50];
size_t sig_len, ciph_len, test_len;
int ret = MBEDTLS_ERR_PK_TYPE_MISMATCH;
