Add Montgomery points to ecp_point_read_binary
The library is able to perform computations and cryptographic schemes on
curves with x coordinate ladder representation. Here we add the
capability to import such points.
diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function
index 606ddd2..58361db 100644
--- a/tests/suites/test_suite_ecp.function
+++ b/tests/suites/test_suite_ecp.function
@@ -760,8 +760,23 @@
if( ret == 0 )
{
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.X, &X ) == 0 );
- TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.Y, &Y ) == 0 );
- TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.Z, &Z ) == 0 );
+ /*
+ * At the time of writing, the following condition is equivalent with
+ * if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY )
+ * but has the advantage of not using internal symbols.
+ */
+ if( grp.G.Y.p == NULL )
+ {
+ TEST_ASSERT( mbedtls_mpi_cmp_int( &Y, 0 ) == 0 );
+ TEST_ASSERT( P.Y.p == NULL );
+ TEST_ASSERT( mbedtls_mpi_cmp_int( &Z, 1 ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_cmp_int( &P.Z, 1 ) == 0 );
+ }
+ else
+ {
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.Y, &Y ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.Z, &Z ) == 0 );
+ }
}
exit: