From 938dc19ef22e951a06af98979c337e5ea5bc90dd Mon Sep 17 00:00:00 2001 From: Werner Lewis Date: Mon, 15 Aug 2022 12:56:12 +0100 Subject: [PATCH] Add auxiliary ECP comparison function Signed-off-by: Werner Lewis --- tests/suites/test_suite_ecp.function | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function index ae966a25f..0f3e9137d 100644 --- a/tests/suites/test_suite_ecp.function +++ b/tests/suites/test_suite_ecp.function @@ -16,6 +16,44 @@ mbedtls_ecp_point_free( x ); \ mbedtls_ecp_point_init( x ); +/* Auxiliary function to compare two mbedtls_ecp_group objects. */ +inline static int mbedtls_ecp_group_cmp( mbedtls_ecp_group *grp1, + mbedtls_ecp_group *grp2 ) +{ + if( mbedtls_mpi_cmp_mpi( &grp1->P, &grp2->P ) != 0 ) + return 1; + if( mbedtls_mpi_cmp_mpi( &grp1->A, &grp2->A ) != 0 ) + return 1; + if( mbedtls_mpi_cmp_mpi( &grp1->B, &grp2->B ) != 0 ) + return 1; + if( mbedtls_mpi_cmp_mpi( &grp1->N, &grp2->N ) != 0 ) + return 1; + if( mbedtls_ecp_point_cmp( &grp1->G, &grp2->G ) != 0 ) + return 1; + if( grp1->id != grp2->id ) + return 1; + if( grp1->pbits != grp2->pbits ) + return 1; + if( grp1->nbits != grp2->nbits ) + return 1; + if( grp1->h != grp2->h ) + return 1; + if( grp1->modp != grp2->modp ) + return 1; + if( grp1->t_pre != grp2->t_pre ) + return 1; + if( grp1->t_post != grp2->t_post ) + return 1; + if( grp1->t_data != grp2->t_data ) + return 1; + if( grp1->T_size != grp2->T_size ) + return 1; + if( grp1->T != grp2->T ) + return 1; + + return 0; +} + /* END_HEADER */ /* BEGIN_DEPENDENCIES