generate key ext: skip driver invocation with non-default method

In the driver wrapper for psa_generate_key() and psa_generate_key_ext():

* Invoke the built-in code if using a non-default method, even if there
  might be an accelerator. This is ok because we only support non-default
  methods for RSA and we don't support driver-only RSA, therefore a
  non-default method will always have built-in code behind it.
* Return NOT_SUPPORTED if trying to use a non-default method with an opaque
  driver.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 3c328c4..d84d101 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -6025,7 +6025,7 @@
 
 static const psa_key_generation_method_t default_method = PSA_KEY_GENERATION_METHOD_INIT;
 
-static int psa_key_generation_method_is_default(
+int psa_key_generation_method_is_default(
     const psa_key_generation_method_t *method,
     size_t method_data_length)
 {
diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h
index 3a9b02d..965db94 100644
--- a/library/psa_crypto_core.h
+++ b/library/psa_crypto_core.h
@@ -396,6 +396,18 @@
     const uint8_t *key_buffer, size_t key_buffer_size,
     uint8_t *data, size_t data_size, size_t *data_length);
 
+/** Whether a key generation method is the default.
+ *
+ * Calls to a key generation driver with a non-default method
+ * require a driver supporting custom methods.
+ *
+ * \param[in] method            The key generation method to check.
+ * \param method_data_length    Size of `method.data` in bytes.
+ */
+int psa_key_generation_method_is_default(
+    const psa_key_generation_method_t *method,
+    size_t method_data_length);
+
 /**
  * \brief Generate a key.
  *