Added ecp_write_binary().

This commit is contained in:
Manuel Pégourié-Gonnard 2012-11-24 14:10:14 +01:00 committed by Paul Bakker
parent 1c33057a63
commit e19feb5b46
4 changed files with 96 additions and 0 deletions

View file

@ -224,6 +224,39 @@ ecp_fast_mod:id:N
}
END_CASE
BEGIN_CASE
ecp_write_binary:id:x:y:z:out:blen:ret
{
ecp_group grp;
ecp_point P;
unsigned char buf[256], str[512];
size_t olen;
memset( buf, 0, sizeof( buf ) );
memset( str, 0, sizeof( str ) );
ecp_group_init( &grp ); ecp_point_init( &P );
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 0 );
TEST_ASSERT( mpi_read_string( &P.X, 16, {x} ) == 0 );
TEST_ASSERT( mpi_read_string( &P.Y, 16, {y} ) == 0 );
TEST_ASSERT( mpi_read_string( &P.Z, 16, {z} ) == 0 );
TEST_ASSERT( ecp_write_binary( &grp, &P, &olen, buf, {blen} ) == {ret} );
if( {ret} == 0 )
{
TEST_ASSERT( olen == strlen({out}) / 2 );
hexify( str, buf, {blen} );
TEST_ASSERT( strcasecmp( (char *) str, {out} ) == 0 );
}
ecp_group_free( &grp ); ecp_point_free( &P );
}
END_CASE
BEGIN_CASE
ecp_selftest:
{