Reduce size of buffers in test suites

This commit is contained in:
Manuel Pégourié-Gonnard 2018-05-09 11:21:21 +02:00
parent d6aea18749
commit 528524bf3c
3 changed files with 46 additions and 46 deletions

View file

@ -14,21 +14,21 @@ void chacha20_crypt( char *hex_key_string,
char *hex_src_string,
char *hex_dst_string )
{
unsigned char key_str[100];
unsigned char nonce_str[100];
unsigned char src_str[10000];
unsigned char dst_str[10000];
unsigned char output[10000];
unsigned char key_str[32]; /* size set by the standard */
unsigned char nonce_str[12]; /* size set by the standard */
unsigned char src_str[375]; /* max size of binary input */
unsigned char dst_str[751]; /* hex expansion of the above */
unsigned char output[751];
size_t key_len;
size_t nonce_len;
size_t src_len;
size_t dst_len;
memset(key_str, 0x00, 100);
memset(nonce_str, 0x00, 100);
memset(src_str, 0x00, 10000);
memset(dst_str, 0x00, 10000);
memset(output, 0x00, 10000);
memset( key_str, 0x00, sizeof( key_str ) );
memset( nonce_str, 0x00, sizeof( nonce_str ) );
memset( src_str, 0x00, sizeof( src_str ) );
memset( dst_str, 0x00, sizeof( dst_str ) );
memset( output, 0x00, sizeof( output ) );
key_len = unhexify( key_str, hex_key_string );
nonce_len = unhexify( nonce_str, hex_nonce_string );
@ -52,4 +52,4 @@ void chacha20_self_test()
{
TEST_ASSERT( mbedtls_chacha20_self_test( 0 ) == 0 );
}
/* END_CASE */
/* END_CASE */

View file

@ -10,14 +10,14 @@
/* BEGIN_CASE */
void mbedtls_chachapoly_enc( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
{
unsigned char key_str[32];
unsigned char nonce_str[12];
unsigned char aad_str[10000];
unsigned char input_str[10000];
unsigned char output_str[10000];
unsigned char mac_str[16];
unsigned char output[10000];
unsigned char mac[16];
unsigned char key_str[32]; /* size set by the standard */
unsigned char nonce_str[12]; /* size set by the standard */
unsigned char aad_str[12]; /* max size of test data so far */
unsigned char input_str[265]; /* max size of binary input/output so far */
unsigned char output_str[265];
unsigned char output[265];
unsigned char mac_str[16]; /* size set by the standard */
unsigned char mac[16]; /* size set by the standard */
size_t input_len;
size_t output_len;
size_t aad_len;
@ -26,12 +26,12 @@ void mbedtls_chachapoly_enc( char *hex_key_string, char *hex_nonce_string, char
size_t mac_len;
mbedtls_chachapoly_context ctx;
memset( key_str, 0x00, 32 );
memset( nonce_str, 0x00, 12 );
memset( aad_str, 0x00, 10000 );
memset( input_str, 0x00, 10000 );
memset( output_str, 0x00, 10000 );
memset( mac_str, 0x00, 16 );
memset( key_str, 0x00, sizeof( key_str ) );
memset( nonce_str, 0x00, sizeof( nonce_str ) );
memset( aad_str, 0x00, sizeof( aad_str ) );
memset( input_str, 0x00, sizeof( input_str ) );
memset( output_str, 0x00, sizeof( output_str ) );
memset( mac_str, 0x00, sizeof( mac_str ) );
aad_len = unhexify( aad_str, hex_aad_string );
input_len = unhexify( input_str, hex_input_string );
@ -65,13 +65,13 @@ exit:
/* BEGIN_CASE */
void mbedtls_chachapoly_dec( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
{
unsigned char key_str[32];
unsigned char nonce_str[12];
unsigned char aad_str[10000];
unsigned char input_str[10000];
unsigned char output_str[10000];
unsigned char mac_str[16];
unsigned char output[10000];
unsigned char key_str[32]; /* size set by the standard */
unsigned char nonce_str[12]; /* size set by the standard */
unsigned char aad_str[12]; /* max size of test data so far */
unsigned char input_str[265]; /* max size of binary input/output so far */
unsigned char output_str[265];
unsigned char output[265];
unsigned char mac_str[16]; /* size set by the standard */
size_t input_len;
size_t output_len;
size_t aad_len;
@ -81,12 +81,12 @@ void mbedtls_chachapoly_dec( char *hex_key_string, char *hex_nonce_string, char
int ret;
mbedtls_chachapoly_context ctx;
memset( key_str, 0x00, 32 );
memset( nonce_str, 0x00, 12 );
memset( aad_str, 0x00, 10000 );
memset( input_str, 0x00, 10000 );
memset( output_str, 0x00, 10000 );
memset( mac_str, 0x00, 16 );
memset( key_str, 0x00, sizeof( key_str ) );
memset( nonce_str, 0x00, sizeof( nonce_str ) );
memset( aad_str, 0x00, sizeof( aad_str ) );
memset( input_str, 0x00, sizeof( input_str ) );
memset( output_str, 0x00, sizeof( output_str ) );
memset( mac_str, 0x00, sizeof( mac_str ) );
aad_len = unhexify( aad_str, hex_aad_string );
input_len = unhexify( input_str, hex_input_string );

View file

@ -6,16 +6,16 @@
/* BEGIN_CASE depends_on:MBEDTLS_POLY1305_C */
void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src_string )
{
unsigned char src_str[10000];
unsigned char mac_str[100];
unsigned char key[32];
unsigned char mac[16];
unsigned char src_str[375]; /* max size of binary input */
unsigned char key[32]; /* size set by the standard */
unsigned char mac[16]; /* size set by the standard */
unsigned char mac_str[33]; /* hex expansion of the above */
size_t src_len;
memset(src_str, 0x00, 10000);
memset(mac_str, 0x00, 100);
memset(key, 0x00, 32);
memset(mac, 0x00, 16);
memset( src_str, 0x00, sizeof( src_str ) );
memset( mac_str, 0x00, sizeof( mac_str ) );
memset( key, 0x00, sizeof( key ) );
memset( mac, 0x00, sizeof( mac ) );
src_len = unhexify( src_str, hex_src_string );
unhexify( key, hex_key_string );