Skip to content

Commit

Permalink
Remove remaining bignum radix args
Browse files Browse the repository at this point in the history
Functions which are not covered by script, changes made to use radix
16.

Signed-off-by: Werner Lewis <[email protected]>
  • Loading branch information
wernerlewis committed Aug 1, 2022
1 parent 955a0bb commit 3e005f3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
1 change: 0 additions & 1 deletion tests/data_files/mpi_10

This file was deleted.

1 change: 1 addition & 0 deletions tests/data_files/mpi_16
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label_1234567890=1f55332c3a48b910f9942f6c914e58bef37a47ee45cb164a5b6b8d1006bf59a059c21449939ebebfdf517d2e1dbac88010d7b1f141e997bd6801ddaec9d05910f4f2de2b2c4d714e2c14a72fc7f17aa428d59c531627f09
12 changes: 6 additions & 6 deletions tests/suites/test_suite_mpi.data
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Test mpi_write_string #10 (Negative hex with odd number of digits)
mpi_read_write_string:16:"-1":16:"":3:0:MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL

Base test mbedtls_mpi_read_binary #1
mbedtls_mpi_read_binary:"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":"941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424"
mbedtls_mpi_read_binary:"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424"

Base test mbedtls_mpi_read_binary_le #1
mbedtls_mpi_read_binary_le:"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":"24448b952fbbef93f89286ba330e62528b151eac265cc8ce3038519d09e148af89288e91f48b41acad55d9dc5e2b18097c106be4ce132721bf6359eaf403e7ff90623e8866ee5c192320418daa682f144adedf84f25de11f49d1fe009d374109"
Expand All @@ -113,19 +113,19 @@ Test mbedtls_mpi_write_binary_le #2 (Buffer too small)
mbedtls_mpi_write_binary_le:"123123123123123123123123123":"23311223311223311223311223":13:MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL

Base test mbedtls_mpi_read_file #1
mbedtls_mpi_read_file:10:"data_files/mpi_10":"01f55332c3a48b910f9942f6c914e58bef37a47ee45cb164a5b6b8d1006bf59a059c21449939ebebfdf517d2e1dbac88010d7b1f141e997bd6801ddaec9d05910f4f2de2b2c4d714e2c14a72fc7f17aa428d59c531627f09":0
mbedtls_mpi_read_file:"data_files/mpi_16":"01f55332c3a48b910f9942f6c914e58bef37a47ee45cb164a5b6b8d1006bf59a059c21449939ebebfdf517d2e1dbac88010d7b1f141e997bd6801ddaec9d05910f4f2de2b2c4d714e2c14a72fc7f17aa428d59c531627f09":0

Test mbedtls_mpi_read_file #1 (Empty file)
mbedtls_mpi_read_file:10:"data_files/hash_file_4":"":MBEDTLS_ERR_MPI_FILE_IO_ERROR
mbedtls_mpi_read_file:"data_files/hash_file_4":"":MBEDTLS_ERR_MPI_FILE_IO_ERROR

Test mbedtls_mpi_read_file #2 (Illegal input)
mbedtls_mpi_read_file:10:"data_files/hash_file_3":"":0
mbedtls_mpi_read_file:"data_files/hash_file_2":"":0

Test mbedtls_mpi_read_file #3 (Input too big)
mbedtls_mpi_read_file:10:"data_files/mpi_too_big":"":MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL
mbedtls_mpi_read_file:"data_files/mpi_too_big":"":MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL

Base test mbedtls_mpi_write_file #1
mbedtls_mpi_write_file:"941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":16:"data_files/mpi_write"
mbedtls_mpi_write_file:"941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":"data_files/mpi_write"

Test mbedtls_mpi_lsb: 0 (null)
mbedtls_mpi_lsb:"":0
Expand Down
16 changes: 8 additions & 8 deletions tests/suites/test_suite_mpi.function
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ void mbedtls_mpi_read_binary( data_t * buf, char * input_A )

TEST_ASSERT( mbedtls_mpi_read_binary( &X, buf->x, buf->len ) == 0 );
TEST_ASSERT( sign_is_valid( &X ) );
TEST_ASSERT( mbedtls_mpi_write_string( &X, radix_A, str, sizeof( str ), &len ) == 0 );
TEST_ASSERT( strcmp( (char *) str, input_A ) == 0 );
TEST_ASSERT( mbedtls_mpi_write_string( &X, 16, str, sizeof( str ), &len ) == 0 );
TEST_ASSERT( strcasecmp( (char *) str, input_A ) == 0 );

exit:
mbedtls_mpi_free( &X );
Expand All @@ -423,8 +423,8 @@ void mbedtls_mpi_read_binary_le( data_t * buf, char * input_A )

TEST_ASSERT( mbedtls_mpi_read_binary_le( &X, buf->x, buf->len ) == 0 );
TEST_ASSERT( sign_is_valid( &X ) );
TEST_ASSERT( mbedtls_mpi_write_string( &X, radix_A, str, sizeof( str ), &len ) == 0 );
TEST_ASSERT( strcmp( (char *) str, input_A ) == 0 );
TEST_ASSERT( mbedtls_mpi_write_string( &X, 16, str, sizeof( str ), &len ) == 0 );
TEST_ASSERT( strcasecmp( (char *) str, input_A ) == 0 );

exit:
mbedtls_mpi_free( &X );
Expand Down Expand Up @@ -511,7 +511,7 @@ void mbedtls_mpi_read_file( char * input_file,

file = fopen( input_file, "r" );
TEST_ASSERT( file != NULL );
ret = mbedtls_mpi_read_file( &X, radix_X, file );
ret = mbedtls_mpi_read_file( &X, 16, file );
fclose(file);
TEST_ASSERT( ret == result );

Expand All @@ -532,7 +532,7 @@ exit:
/* END_CASE */

/* BEGIN_CASE depends_on:MBEDTLS_FS_IO */
void mbedtls_mpi_write_file( char * input_X, int output_radix,
void mbedtls_mpi_write_file( char * input_X,
char * output_file )
{
mbedtls_mpi X, Y;
Expand All @@ -545,13 +545,13 @@ void mbedtls_mpi_write_file( char * input_X, int output_radix,

file_out = fopen( output_file, "w" );
TEST_ASSERT( file_out != NULL );
ret = mbedtls_mpi_write_file( NULL, &X, output_radix, file_out );
ret = mbedtls_mpi_write_file( NULL, &X, 16, file_out );
fclose(file_out);
TEST_ASSERT( ret == 0 );

file_in = fopen( output_file, "r" );
TEST_ASSERT( file_in != NULL );
ret = mbedtls_mpi_read_file( &Y, output_radix, file_in );
ret = mbedtls_mpi_read_file( &Y, 16, file_in );
fclose(file_in);
TEST_ASSERT( ret == 0 );

Expand Down
12 changes: 6 additions & 6 deletions tests/suites/test_suite_rsa.function
Original file line number Diff line number Diff line change
Expand Up @@ -1089,9 +1089,9 @@ void mbedtls_rsa_check_privkey( int mod, char * input_P,
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.QP, input_QP ) == 0 );
}
#else
((void) radix_DP); ((void) input_DP);
((void) radix_DQ); ((void) input_DQ);
((void) radix_QP); ((void) input_QP);
((void) input_DP);
((void) input_DQ);
((void) input_QP);
#endif

TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == result );
Expand Down Expand Up @@ -1162,9 +1162,9 @@ void rsa_check_pubpriv( int mod, char * input_Npub,
TEST_ASSERT( mbedtls_test_read_mpi( &prv.QP, input_QP ) == 0 );
}
#else
((void) radix_DP); ((void) input_DP);
((void) radix_DQ); ((void) input_DQ);
((void) radix_QP); ((void) input_QP);
((void) input_DP);
((void) input_DQ);
((void) input_QP);
#endif

TEST_ASSERT( mbedtls_rsa_check_pub_priv( &pub, &prv ) == result );
Expand Down

0 comments on commit 3e005f3

Please sign in to comment.