mbedtls/include/psa
Gilles Peskine 2fa6b5f503 ECC import: more useful choice of INVALID_ARGUMENT vs NOT_SUPPORTED
Attempting to create an ECC key with a curve specification that is not
valid can plausibly fail with PSA_ERROR_INVALID_ARGUMENT ("this is not
a curve specification at all") or PSA_ERROR_NOT_SUPPORTED ("this may
be a curve specification, but not one I support"). The choice of error
is somewhat subjective.

Before this commit, due to happenstance in the implementation, an
attempt to use a curve that is declared in the PSA API but not
implemented in Mbed TLS returned PSA_ERROR_INVALID_ARGUMENT, whereas
an attempt to use a curve that Mbed TLS supports but for which support
was disabled at compile-time returned PSA_ERROR_NOT_SUPPORTED. This
inconsistency made it difficult to write negative tests that could
work whether the curve is implemented via Mbed TLS code or via a
driver.

After this commit, any attempt to use parameters that are not
recognized fails with NOT_SUPPORTED, whether a curve with the
specified size might plausibly exist or not, because "might plausibly
exist" is not something Mbed TLS can determine.

To keep returning INVALID_ARGUMENT when importing an ECC key with an
explicit "bits" attribute that is inconsistent with the size of the
key material, this commit changes the way mbedtls_ecc_group_of_psa()
works: it now works on a size in bits rather than bytes, with an extra
flag indicating whether the bit-size must be exact or not.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-08 18:43:26 +01:00
..
crypto.h Merge pull request #3872 from gabor-mezei-arm/3275_use_PSA_ERROR_DATA_INVALID_where_warranted 2021-02-03 20:54:46 +01:00
crypto_compat.h Merge pull request #3872 from gabor-mezei-arm/3275_use_PSA_ERROR_DATA_INVALID_where_warranted 2021-02-03 20:54:46 +01:00
crypto_config.h PSA_KEY_TYPE_DERIVE is always available 2021-02-01 13:19:26 +01:00
crypto_driver_common.h Remove old-style accelerator and entropy driver interfaces 2020-11-30 17:37:14 +01:00
crypto_extra.h ECC import: more useful choice of INVALID_ARGUMENT vs NOT_SUPPORTED 2021-02-08 18:43:26 +01:00
crypto_platform.h Minor documentation improvements 2021-01-04 21:00:53 +01:00
crypto_se_driver.h Fix possible error codes in the documentation 2021-01-26 13:48:26 +01:00
crypto_sizes.h Fix documentation 2021-01-28 14:33:10 +01:00
crypto_struct.h Rename unnamespaced identifiers 2021-01-20 17:42:25 +01:00
crypto_types.h Merge pull request #3576 from gilles-peskine-arm/psa-lifetime-persistence-indicator-tweaks 2020-12-15 10:17:39 +01:00
crypto_values.h Merge pull request #3872 from gabor-mezei-arm/3275_use_PSA_ERROR_DATA_INVALID_where_warranted 2021-02-03 20:54:46 +01:00