Fix some preprocessor guards

Fix the build in some configurations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/library/pk.c b/library/pk.c
index f623af9..28663a8 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -784,8 +784,7 @@
             size_t from_bits = 0;
             psa_ecc_family_t from_family = mbedtls_ecc_group_to_psa(ec->grp.id,
                                                                     &from_bits);
-            psa_key_type_t to_type = psa_get_key_type(attributes);
-            if (to_type != PSA_KEY_TYPE_ECC_PUBLIC_KEY(from_family)) {
+            if (psa_type != PSA_KEY_TYPE_ECC_PUBLIC_KEY(from_family)) {
                 return MBEDTLS_ERR_PK_TYPE_MISMATCH;
             }
             int ret = mbedtls_ecp_write_public_key(
diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function
index 5d0ee1a..7671364 100644
--- a/tests/suites/test_suite_pk.function
+++ b/tests/suites/test_suite_pk.function
@@ -114,11 +114,6 @@
 
 #if defined(MBEDTLS_TEST_PSA_ECC_ONE_FAMILY)
 #define MBEDTLS_TEST_PSA_ECC_AT_LEAST_ONE_CURVE
-#else
-/* Always define the macros so that we can use them in test data. */
-#define MBEDTLS_TEST_PSA_ECC_ONE_FAMILY 0
-#define MBEDTLS_PSA_ECC_ONE_CURVE_BITS 0
-#define MBEDTLS_TEST_ECP_DP_ONE_CURVE 0
 #endif
 
 /* Pick a second curve, for tests that need two supported curves of the
@@ -136,13 +131,20 @@
 #define MBEDTLS_TEST_PSA_ECC_ANOTHER_FAMILY PSA_ECC_FAMILY_SECP_K1
 #define MBEDTLS_PSA_ECC_ONE_CURVE_BITS 256
 #define MBEDTLS_TEST_PSA_ECC_HAVE_TWO_FAMILIES
-#else
-/* Always define the macros so that we can use them in test data. */
-#define MBEDTLS_TEST_PSA_ECC_ANOTHER_FAMILY 0
 #endif
 
 #endif /* defined(MBEDTLS_PSA_CRYPTO_C) && defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY) */
 
+/* Always define the macros so that we can use them in test data. */
+#if !defined(MBEDTLS_TEST_PSA_ECC_ONE_FAMILY)
+#define MBEDTLS_TEST_PSA_ECC_ONE_FAMILY 0
+#define MBEDTLS_PSA_ECC_ONE_CURVE_BITS 0
+#define MBEDTLS_TEST_ECP_DP_ONE_CURVE 0
+#endif
+#if !defined(MBEDTLS_TEST_PSA_ECC_ANOTHER_FAMILY)
+#define MBEDTLS_TEST_PSA_ECC_ANOTHER_FAMILY 0
+#endif
+
 #if defined(MBEDTLS_PK_USE_PSA_EC_DATA)
 static int pk_genkey_ec(mbedtls_pk_context *pk, mbedtls_ecp_group_id grp_id)
 {
diff --git a/tests/suites/test_suite_pkparse.function b/tests/suites/test_suite_pkparse.function
index 6c904a3..3227ce9 100644
--- a/tests/suites/test_suite_pkparse.function
+++ b/tests/suites/test_suite_pkparse.function
@@ -14,7 +14,7 @@
 #define HAVE_mbedtls_pk_parse_key_pkcs8_encrypted_der
 #endif
 
-#if defined(MBEDTLS_PSA_CRYPTO_C)
+#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_FS_IO)
 static int test_psa_bridge(const mbedtls_pk_context *ctx,
                            psa_key_usage_t usage_flag)
 {
@@ -62,6 +62,7 @@
     return ok;
 }
 
+#if defined(MBEDTLS_PK_HAVE_ECC_KEYS)
 /* Whether a pk key can do ECDSA. Opaque keys are not supported since this
  * test suite does not create opaque keys. */
 static int pk_can_ecdsa(const mbedtls_pk_context *ctx)
@@ -80,7 +81,8 @@
     return 0;
 #endif
 }
-#endif /* MBEDTLS_PSA_CRYPTO_C */
+#endif /* MBEDTLS_PK_HAVE_ECC_KEYS */
+#endif /* MBEDTLS_PSA_CRYPTO_C &&  && MBEDTLS_FS_IO */
 
 /* END_HEADER */