test_suite_psa_crypto: add test functions and cases for ECC conversion functions
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 4c08a90..a2d156d 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -6,6 +6,8 @@
#include "mbedtls/oid.h"
#include "common.h"
+#include "mbedtls/psa_util.h"
+
/* For MBEDTLS_CTR_DRBG_MAX_REQUEST, knowing that psa_generate_random()
* uses mbedtls_ctr_drbg internally. */
#include "mbedtls/ctr_drbg.h"
@@ -9480,6 +9482,33 @@
/* END_CASE */
/* BEGIN_CASE */
+void ecc_conversion_functions(int grp_id_arg)
+{
+ mbedtls_ecp_group_id grp_id = grp_id_arg;
+ psa_ecc_family_t ecc_family;
+ size_t bits;
+
+ ecc_family = mbedtls_ecc_group_to_psa(grp_id, &bits);
+ TEST_ASSERT(ecc_family != 0);
+ TEST_EQUAL(grp_id, mbedtls_ecc_group_from_psa(ecc_family, bits));
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void ecc_conversion_functions_fail(void)
+{
+ psa_ecc_family_t ecc_family;
+ size_t bits;
+
+ // Pick an invalid group ID (MBEDTLS_ECP_DP_CURVE448 is the last enum)
+ ecc_family = mbedtls_ecc_group_to_psa(MBEDTLS_ECP_DP_CURVE448 + 1, &bits);
+ TEST_EQUAL(ecc_family, 0);
+
+ TEST_EQUAL(MBEDTLS_ECP_DP_NONE, mbedtls_ecc_group_from_psa(PSA_ECC_FAMILY_SECP_R1, 0));
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
void key_agreement_output(int alg_arg,
int our_key_type_arg, data_t *our_key_data,
data_t *peer_key_data,