Commit 61ce13b7 authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

Basic tests for ECDH primitive

parent 6545ca7b
......@@ -46,6 +46,7 @@ add_test_suite(debug)
add_test_suite(des)
add_test_suite(dhm)
add_test_suite(ecp)
add_test_suite(ecdh)
add_test_suite(error)
add_test_suite(gcm gcm.encrypt)
add_test_suite(gcm gcm.decrypt)
......
ECDH primitive agreement #1
ecdh_primitive_agreement:SECP192R1
ECDH primitive agreement #2
ecdh_primitive_agreement:SECP224R1
ECDH primitive agreement #3
ecdh_primitive_agreement:SECP256R1
ECDH primitive agreement #4
ecdh_primitive_agreement:SECP384R1
ECDH primitive agreement #5
ecdh_primitive_agreement:SECP521R1
BEGIN_HEADER
#include <polarssl/ecdh.h>
END_HEADER
BEGIN_DEPENDENCIES
depends_on:POLARSSL_ECDH_C:POLARSSL_ECP_C:POLARSSL_BIGNUM_C
END_DEPENDENCIES
BEGIN_CASE
ecdh_primitive_agreement:id
{
ecp_group grp;
ecp_point qA, qB;
mpi dA, dB, zA, zB;
rnd_pseudo_info rnd_info;
ecp_group_init( &grp );
ecp_point_init( &qA ); ecp_point_init( &qB );
mpi_init( &dA ); mpi_init( &dB );
mpi_init( &zA ); mpi_init( &zB );
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 0 );
TEST_ASSERT( ecdh_gen_public( &grp, &dA, &qA, &rnd_pseudo_rand, &rnd_info )
== 0 );
TEST_ASSERT( ecdh_gen_public( &grp, &dB, &qB, &rnd_pseudo_rand, &rnd_info )
== 0 );
TEST_ASSERT( ecdh_compute_shared( &grp, &zA, &qB, &dA ) == 0 );
TEST_ASSERT( ecdh_compute_shared( &grp, &zB, &qA, &dB ) == 0 );
TEST_ASSERT( mpi_cmp_mpi( &zA, &zB ) == 0 );
ecp_group_free( &grp );
ecp_point_free( &qA ); ecp_point_free( &qB );
mpi_free( &dA ); mpi_free( &dB );
mpi_free( &zA ); mpi_free( &zB );
}
END_CASE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment