mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-30 00:04:14 +01:00
Basic tests for ECDH primitive
This commit is contained in:
parent
6545ca7bed
commit
61ce13b728
@ -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)
|
||||
|
15
tests/suites/test_suite_ecdh.data
Normal file
15
tests/suites/test_suite_ecdh.data
Normal file
@ -0,0 +1,15 @@
|
||||
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
|
||||
|
39
tests/suites/test_suite_ecdh.function
Normal file
39
tests/suites/test_suite_ecdh.function
Normal file
@ -0,0 +1,39 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user