Fix check for format supported by PSA
For non-Weierstrass curves there's only one format and it's supported.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/library/pkparse.c b/library/pkparse.c
index 820c8d1..b429951 100644
--- a/library/pkparse.c
+++ b/library/pkparse.c
@@ -302,8 +302,10 @@
#if defined(MBEDTLS_PK_USE_PSA_EC_DATA)
/* Load the key */
- if (*pub == 0x04) {
- /* Uncompressed format, directly supported by PSA */
+ if (!PSA_ECC_FAMILY_IS_WEIERSTRASS(pk->ec_family) || *pub == 0x04) {
+ /* Format directly supported by PSA:
+ * - non-Weierstrass curves that only have one format;
+ * - uncompressed format for Weierstrass curves. */
if (pub_len > sizeof(pk->pub_raw)) {
return MBEDTLS_ERR_PK_BUFFER_TOO_SMALL;
}