Add a few tests for ecp_tls_read_point
This commit is contained in:
parent
46106a9d75
commit
8c16f96259
2 changed files with 48 additions and 0 deletions
|
@ -181,6 +181,18 @@ ecp_read_binary:SECP192R1:"0548d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ce
|
|||
ECP read binary #6 (non-zero, OK)
|
||||
ecp_read_binary:SECP192R1:"0448d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"48d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc9933":"6ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"01":0
|
||||
|
||||
ECP tls read point #1 (zero, invalid length byte)
|
||||
ecp_tls_read_point:SECP192R1:"0200":"01":"01":"00":POLARSSL_ERR_ECP_BAD_INPUT_DATA
|
||||
|
||||
ECP tls read point #2 (zero, OK)
|
||||
ecp_tls_read_point:SECP192R1:"0100":"01":"01":"00":0
|
||||
|
||||
ECP tls read point #3 (non-zero, invalid length byte)
|
||||
ecp_tls_read_point:SECP192R1:"300448d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"48d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc9933":"6ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"01":POLARSSL_ERR_ECP_BAD_INPUT_DATA
|
||||
|
||||
ECP tls read point #4 (non-zero, OK)
|
||||
ecp_tls_read_point:SECP192R1:"310448d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"48d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc9933":"6ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"01":0
|
||||
|
||||
ECP tls write-read point #1
|
||||
ecp_tls_write_read_point:SECP192R1
|
||||
|
||||
|
|
|
@ -293,6 +293,42 @@ ecp_read_binary:id:input:x:y:z:ret
|
|||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_tls_read_point:id:input:x:y:z:ret
|
||||
{
|
||||
ecp_group grp;
|
||||
ecp_point P;
|
||||
mpi X, Y, Z;
|
||||
size_t ilen;
|
||||
unsigned char buf[256];
|
||||
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
|
||||
ecp_group_init( &grp ); ecp_point_init( &P );
|
||||
mpi_init( &X ); mpi_init( &Y ); mpi_init( &Z );
|
||||
|
||||
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 0 );
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, 16, {x} ) == 0 );
|
||||
TEST_ASSERT( mpi_read_string( &Y, 16, {y} ) == 0 );
|
||||
TEST_ASSERT( mpi_read_string( &Z, 16, {z} ) == 0 );
|
||||
|
||||
ilen = unhexify( buf, {input} );
|
||||
|
||||
TEST_ASSERT( ecp_tls_read_point( &grp, &P, buf, ilen ) == {ret} );
|
||||
|
||||
if( {ret} == 0 )
|
||||
{
|
||||
TEST_ASSERT( mpi_cmp_mpi( &P.X, &X ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &P.Y, &Y ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &P.Z, &Z ) == 0 );
|
||||
}
|
||||
|
||||
ecp_group_free( &grp ); ecp_point_free( &P );
|
||||
mpi_free( &X ); mpi_free( &Y ); mpi_free( &Z );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
ecp_tls_write_read_point:id
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue