From c4afef7f46c796070aa4766b954bf16be122648c Mon Sep 17 00:00:00 2001 From: Werner Lewis Date: Thu, 25 Aug 2022 10:29:19 +0100 Subject: [PATCH] Use spec values as-is for test data Spec values are now always used for test data, and conversion to internal representation is done in the test function. Signed-off-by: Werner Lewis --- tests/suites/test_suite_ecp.data | 4 ++-- tests/suites/test_suite_ecp.function | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_ecp.data b/tests/suites/test_suite_ecp.data index c190fbe8c..10137ba16 100644 --- a/tests/suites/test_suite_ecp.data +++ b/tests/suites/test_suite_ecp.data @@ -355,11 +355,11 @@ mbedtls_ecp_group_metadata:MBEDTLS_ECP_DP_BP512R1:512:MBEDTLS_ECP_TYPE_SHORT_WEI Check ECP group metadata #12 curve25519 (RFC 7748) depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED -mbedtls_ecp_group_metadata:MBEDTLS_ECP_DP_CURVE25519:256:MBEDTLS_ECP_TYPE_MONTGOMERY:"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed":"1db42":"":"9":"":"1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed":29 +mbedtls_ecp_group_metadata:MBEDTLS_ECP_DP_CURVE25519:256:MBEDTLS_ECP_TYPE_MONTGOMERY:"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed":"76d06":"":"9":"":"1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed":29 Check ECP group metadata #13 curve448 (RFC 7748) depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED -mbedtls_ecp_group_metadata:MBEDTLS_ECP_DP_CURVE448:448:MBEDTLS_ECP_TYPE_MONTGOMERY:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff":"98aa":"":"5":"":"3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3":30 +mbedtls_ecp_group_metadata:MBEDTLS_ECP_DP_CURVE448:448:MBEDTLS_ECP_TYPE_MONTGOMERY:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff":"262a6":"":"5":"":"3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3":30 ECP tls read group #1 (record too short) mbedtls_ecp_tls_read_group:"0313":MBEDTLS_ERR_ECP_BAD_INPUT_DATA:0:0 diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function index 025f3f83a..586c26c00 100644 --- a/tests/suites/test_suite_ecp.function +++ b/tests/suites/test_suite_ecp.function @@ -825,6 +825,13 @@ void mbedtls_ecp_group_metadata( int id, int bit_size, int crv_type, TEST_EQUAL( mbedtls_test_read_mpi( &exp_B, B ), 0 ); TEST_EQUAL( mbedtls_test_read_mpi( &exp_G_y, G_y ), 0 ); + // Convert exp_A to internal representation (A+2)/4 + if( crv_type == MBEDTLS_ECP_TYPE_MONTGOMERY ) + { + TEST_EQUAL( mbedtls_mpi_add_int( &exp_A, &exp_A, 2 ), 0 ); + TEST_EQUAL( mbedtls_mpi_div_int( &exp_A, NULL, &exp_A, 4 ), 0 ); + } + // Load group TEST_EQUAL( mbedtls_ecp_group_load( &grp, id ), 0 );