Add test for dhm_parse_dhmfile

This commit is contained in:
Manuel Pégourié-Gonnard
2014-03-29 16:42:38 +01:00
parent 66dfc5a689
commit 3fec220a33
5 changed files with 34 additions and 0 deletions

View File

@@ -97,6 +97,29 @@ void dhm_do_dhm( int radix_P, char *input_P,
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_FS_IO */
void dhm_file( char *filename, char *p, char *g, int len )
{
dhm_context ctx;
mpi P, G;
memset( &ctx, 0, sizeof ctx );
mpi_init( &P ); mpi_init( &G );
TEST_ASSERT( mpi_read_string( &P, 16, p ) == 0 );
TEST_ASSERT( mpi_read_string( &G, 16, g ) == 0 );
TEST_ASSERT( dhm_parse_dhmfile( &ctx, filename ) == 0 );
TEST_ASSERT( ctx.len == (size_t) len );
TEST_ASSERT( mpi_cmp_mpi( &ctx.P, &P ) == 0 );
TEST_ASSERT( mpi_cmp_mpi( &ctx.G, &G ) == 0 );
mpi_free( &P ); mpi_free( &G );
dhm_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */
void dhm_selftest()
{