From 6d50173d9c651ec58fefac520de646d983d2ef99 Mon Sep 17 00:00:00 2001 From: oberon-sk Date: Mon, 13 Feb 2023 12:13:20 +0100 Subject: [PATCH 1/2] Handle Edwards curves similar to Montgomery curves wrt key export length. Signed-off-by: Stephan Koch --- tests/src/psa_exercise_key.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index ecd1ec4cd..6c04c3b54 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -778,6 +778,10 @@ int mbedtls_test_psa_exported_key_sanity_check( /* The representation of an ECC Montgomery public key is * the raw compressed point */ TEST_EQUAL(PSA_BITS_TO_BYTES(bits), exported_length); + } else if(PSA_KEY_TYPE_ECC_GET_FAMILY(type) == PSA_ECC_FAMILY_TWISTED_EDWARDS) { + /* The representation of an ECC Edwards public key is + * the raw compressed point */ + TEST_EQUAL(PSA_BITS_TO_BYTES(bits + 1), exported_length); } else { /* The representation of an ECC Weierstrass public key is: * - The byte 0x04; From 6eb73113b184a6935a624aee9de67ccc26140c2d Mon Sep 17 00:00:00 2001 From: Stephan Koch Date: Fri, 3 Mar 2023 17:48:40 +0100 Subject: [PATCH 2/2] Fix codestyle with uncrustify. Signed-off-by: Stephan Koch --- tests/src/psa_exercise_key.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index 6c04c3b54..5f9f767e7 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -778,10 +778,10 @@ int mbedtls_test_psa_exported_key_sanity_check( /* The representation of an ECC Montgomery public key is * the raw compressed point */ TEST_EQUAL(PSA_BITS_TO_BYTES(bits), exported_length); - } else if(PSA_KEY_TYPE_ECC_GET_FAMILY(type) == PSA_ECC_FAMILY_TWISTED_EDWARDS) { + } else if (PSA_KEY_TYPE_ECC_GET_FAMILY(type) == PSA_ECC_FAMILY_TWISTED_EDWARDS) { /* The representation of an ECC Edwards public key is * the raw compressed point */ - TEST_EQUAL(PSA_BITS_TO_BYTES(bits + 1), exported_length); + TEST_EQUAL(PSA_BITS_TO_BYTES(bits + 1), exported_length); } else { /* The representation of an ECC Weierstrass public key is: * - The byte 0x04;