mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-25 09:19:20 +00:00
39 lines
1.1 KiB
Text
39 lines
1.1 KiB
Text
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
|