Added ecp_read_binary().

This commit is contained in:
Manuel Pégourié-Gonnard 2012-11-24 16:19:42 +01:00 committed by Paul Bakker
parent 37d218a8e3
commit 5e402d88ea
4 changed files with 106 additions and 1 deletions

View file

@ -257,6 +257,44 @@ ecp_write_binary:id:x:y:z:format:out:blen:ret
}
END_CASE
BEGIN_CASE
ecp_read_binary:id:input:format:x:y:z:ret
{
ecp_group grp;
ecp_point P;
mpi X, Y, Z;
int 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} );
#define POLARSSL_ECP_PF_UNKNOWN -1
TEST_ASSERT( ecp_read_binary( &grp, &P, POLARSSL_ECP_PF_{format},
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_selftest:
{