Add basic tests for ecp_tls_*_point
This commit is contained in:
parent
7e86025f32
commit
6282acaec2
@ -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
|
||||
|
||||
|
@ -293,6 +293,70 @@ ecp_read_binary:id:input:x:y:z:ret
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_tls_write_read_point:id
|
||||
{
|
||||
ecp_group grp;
|
||||
ecp_point pt;
|
||||
unsigned char buf[256];
|
||||
|
||||
ecp_group_init( &grp );
|
||||
ecp_point_init( &pt );
|
||||
memset( buf, 0x00, sizeof( buf ) );
|
||||
|
||||
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 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( &pt );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_read_params:record:ret:bits
|
||||
{
|
||||
ecp_group grp;
|
||||
unsigned char buf[10];
|
||||
int len, ret;
|
||||
|
||||
ecp_group_init( &grp );
|
||||
memset( buf, 0x00, sizeof( buf ) );
|
||||
|
||||
len = unhexify( buf, {record} );
|
||||
|
||||
ret = ecp_tls_read_group( &grp, buf, len );
|
||||
|
||||
TEST_ASSERT( ret == {ret} );
|
||||
if( ret == 0)
|
||||
TEST_ASSERT( mpi_msb( &grp.P ) == {bits} );
|
||||
|
||||
ecp_group_free( &grp );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_gen_keypair:id
|
||||
{
|
||||
@ -320,28 +384,6 @@ ecp_gen_keypair:id
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_read_params:record:ret:bits
|
||||
{
|
||||
ecp_group grp;
|
||||
unsigned char buf[10];
|
||||
int len, ret;
|
||||
|
||||
ecp_group_init( &grp );
|
||||
memset( buf, 0x00, sizeof( buf ) );
|
||||
|
||||
len = unhexify( buf, {record} );
|
||||
|
||||
ret = ecp_tls_read_group( &grp, buf, len );
|
||||
|
||||
TEST_ASSERT( ret == {ret} );
|
||||
if( ret == 0)
|
||||
TEST_ASSERT( mpi_msb( &grp.P ) == {bits} );
|
||||
|
||||
ecp_group_free( &grp );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_selftest:
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user