Commit 6282acae authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

Add basic tests for ecp_tls_*_point

parent 7e86025f
......@@ -181,6 +181,12 @@ ecp_read_binary:SECP192R1:"0548d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ce
ECP read binary #6 (non-zero, OK)
ecp_read_binary:SECP192R1:"0448d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"48d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc9933":"6ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"01":0
ECP tls write-read point #1
ecp_tls_write_read_point:SECP192R1
ECP tls write-read point #2
ecp_tls_write_read_point:SECP521R1
ECP read params #1 (record too short)
ecp_read_params:"0313":POLARSSL_ERR_ECP_BAD_INPUT_DATA:0
......
......@@ -294,29 +294,44 @@ ecp_read_binary:id:input:x:y:z:ret
END_CASE
BEGIN_CASE
ecp_gen_keypair:id
ecp_tls_write_read_point:id
{
ecp_group grp;
ecp_point Q;
mpi d;
rnd_pseudo_info rnd_info;
ecp_point pt;
unsigned char buf[256];
ecp_group_init( &grp );
ecp_point_init( &Q );
mpi_init( &d );
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
ecp_point_init( &pt );
memset( buf, 0x00, sizeof( buf ) );
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 0 );
TEST_ASSERT( ecp_gen_keypair( &grp, &d, &Q, &rnd_pseudo_rand, &rnd_info )
== 0 );
TEST_ASSERT( mpi_cmp_mpi( &d, &grp.N ) < 0 );
TEST_ASSERT( mpi_cmp_int( &d, 1 ) >= 0 );
TEST_ASSERT( ecp_tls_write_point( &grp, &grp.G,
POLARSSL_ECP_PF_COMPRESSED, buf, 256 ) == 0 );
TEST_ASSERT( ecp_tls_read_point( &grp, &pt, buf, 256 )
== POLARSSL_ERR_ECP_BAD_INPUT_DATA );
TEST_ASSERT( ecp_tls_write_point( &grp, &grp.G,
POLARSSL_ECP_PF_UNCOMPRESSED, buf, 256 ) == 0 );
TEST_ASSERT( ecp_tls_read_point( &grp, &pt, buf, 256 ) == 0 );
TEST_ASSERT( mpi_cmp_mpi( &grp.G.X, &pt.X ) == 0 );
TEST_ASSERT( mpi_cmp_mpi( &grp.G.Y, &pt.Y ) == 0 );
TEST_ASSERT( mpi_cmp_mpi( &grp.G.Z, &pt.Z ) == 0 );
TEST_ASSERT( ecp_set_zero( &pt ) == 0 );
TEST_ASSERT( ecp_tls_write_point( &grp, &pt,
POLARSSL_ECP_PF_COMPRESSED, buf, 256 ) == 0 );
TEST_ASSERT( ecp_tls_read_point( &grp, &pt, buf, 256 ) == 0 );
TEST_ASSERT( ecp_is_zero( &pt ) );
TEST_ASSERT( ecp_set_zero( &pt ) == 0 );
TEST_ASSERT( ecp_tls_write_point( &grp, &pt,
POLARSSL_ECP_PF_UNCOMPRESSED, buf, 256 ) == 0 );
TEST_ASSERT( ecp_tls_read_point( &grp, &pt, buf, 256 ) == 0 );
TEST_ASSERT( ecp_is_zero( &pt ) );
ecp_group_free( &grp );
ecp_point_free( &Q );
mpi_free( &d );
ecp_point_free( &pt );
}
END_CASE
......@@ -342,6 +357,33 @@ ecp_read_params:record:ret:bits
}
END_CASE
BEGIN_CASE
ecp_gen_keypair:id
{
ecp_group grp;
ecp_point Q;
mpi d;
rnd_pseudo_info rnd_info;
ecp_group_init( &grp );
ecp_point_init( &Q );
mpi_init( &d );
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 0 );
TEST_ASSERT( ecp_gen_keypair( &grp, &d, &Q, &rnd_pseudo_rand, &rnd_info )
== 0 );
TEST_ASSERT( mpi_cmp_mpi( &d, &grp.N ) < 0 );
TEST_ASSERT( mpi_cmp_int( &d, 1 ) >= 0 );
ecp_group_free( &grp );
ecp_point_free( &Q );
mpi_free( &d );
}
END_CASE
BEGIN_CASE
ecp_selftest:
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment