mbedtls/library
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
..
.gitignore
aes.c Merge pull request #3823 from gabor-mezei-arm/3818_MBEDTLS_AES_SETKEY_DEC_ALT_excludes_MBEDTLS_CIPHER_MODE_XTS 2020-11-09 20:44:08 +01:00
aesni.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
arc4.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
aria.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
asn1parse.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
asn1write.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
base64.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
bignum.c mbedtls_mpi_sub_abs: fix buffer overflow in error case 2021-02-01 17:28:03 +01:00
blowfish.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
camellia.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ccm.c Fix additional data length field check for CCM 2020-10-08 12:09:44 +02:00
certs.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
chacha20.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
chachapoly.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
check_crypto_config.h Minor updates to address review comments 2020-11-30 21:06:05 -08:00
cipher.c Fix unused param warnings in auth_xxcrypt_ext() 2020-12-07 10:42:21 +01:00
cipher_wrap.c Do not set IV size for ECB mode ciphers 2020-11-06 09:40:21 +01:00
cmac.c Update comment to only apply to AES-192 2021-01-29 11:09:50 +01:00
CMakeLists.txt psa: Move xxx_load_representation functions to RSA/ECP specific modules 2021-02-02 11:29:08 +01:00
common.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ctr_drbg.c Updated per comments from @gilles-peskine-arm. 2021-01-04 18:14:32 -06:00
debug.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
des.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
dhm.c Merge development into development-restricted 2020-08-20 11:07:12 +01:00
ecdh.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ecdsa.c Apply review feedback 2021-01-26 12:01:22 +01:00
ecjpake.c Skip tests requiring known entropy for ECJPAKE ALT implementations 2021-01-22 14:23:08 +01:00
ecp.c Reworked NO_FALLBACK logic according to review feedback 2021-01-22 09:43:59 +01:00
ecp_curves.c Fix uncaught error if fix_negative fails 2020-12-06 22:32:02 +01:00
entropy.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
entropy_poll.c Fix the build when _GNU_SOURCE is defined to a non-empty value 2020-10-01 11:27:17 +02:00
error.c Simplify conditional guards in error.c 2020-11-16 15:02:16 +01:00
gcm.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
havege.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
hkdf.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
hmac_drbg.c Support set *_drbg reseed interval before seed 2020-11-25 14:25:56 -08:00
Makefile psa: Move xxx_load_representation functions to RSA/ECP specific modules 2021-02-02 11:29:08 +01:00
md.c Merge pull request #3578 from gilles-peskine-arm/md_setup-leak-development 2020-08-21 09:19:12 +02:00
md2.c Merge branch 'development' into development-restricted 2020-12-03 09:59:42 +01:00
md4.c Merge branch 'development' into development-restricted 2020-12-03 09:59:42 +01:00
md5.c Merge branch 'development' into development-restricted 2020-12-03 09:59:42 +01:00
memory_buffer_alloc.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
net_sockets.c Use socklen_t on Android and other POSIX-compliant system 2020-09-30 16:53:37 +08:00
nist_kw.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
oid.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
padlock.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pem.c Remove Extraneous bytes from buffer post pem write 2020-12-07 17:29:42 +00:00
pk.c psa: Move from key handle to key identifier 2020-11-10 16:00:41 +01:00
pk_wrap.c psa: Move from key handle to key identifier 2020-11-10 16:00:41 +01:00
pkcs5.c Merge pull request #731 from gabor-mezei-arm/692_missing_zeroizations_of_sensitive_data 2020-09-18 16:20:13 +02:00
pkcs11.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pkcs12.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pkparse.c fix return code 2020-09-22 11:57:16 +02:00
pkwrite.c adding parentheses to macro definitions, to avoid confusion and possible mistakes in usage. 2021-02-01 14:26:08 +01:00
platform.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
platform_util.c Fixes two _POSIX_C_SOURCE typos. 2020-11-13 09:20:18 +00:00
poly1305.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
psa_crypto.c ECC import: more useful choice of INVALID_ARGUMENT vs NOT_SUPPORTED 2021-02-08 18:43:26 +01:00
psa_crypto_core.h psa: Improve psa_import_key_into_slot() documentation 2021-02-02 11:49:14 +01:00
psa_crypto_driver_wrappers.c Fix coding style issues 2021-02-02 11:38:50 +01:00
psa_crypto_driver_wrappers.h psa: Call export software implementation as a driver 2021-02-02 11:29:08 +01:00
psa_crypto_ecp.c ECC import: more useful choice of INVALID_ARGUMENT vs NOT_SUPPORTED 2021-02-08 18:43:26 +01:00
psa_crypto_ecp.h ECC import: more useful choice of INVALID_ARGUMENT vs NOT_SUPPORTED 2021-02-08 18:43:26 +01:00
psa_crypto_invasive.h Implement MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG 2020-11-23 17:42:54 +01:00
psa_crypto_its.h Update documentation 2020-11-25 13:10:50 +01:00
psa_crypto_random_impl.h Explain the design of mbedtls_psa_get_random better 2021-01-05 16:03:55 +01:00
psa_crypto_rsa.c psa: Add ECP/RSA transparent test driver import_key entry point 2021-02-02 11:29:08 +01:00
psa_crypto_rsa.h psa: Add ECP/RSA transparent test driver import_key entry point 2021-02-02 11:29:08 +01:00
psa_crypto_se.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
psa_crypto_se.h Update documentation 2020-11-25 13:10:50 +01:00
psa_crypto_service_integration.h Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
psa_crypto_slot_management.c Merge pull request #3872 from gabor-mezei-arm/3275_use_PSA_ERROR_DATA_INVALID_where_warranted 2021-02-03 20:54:46 +01:00
psa_crypto_slot_management.h Improve/fix documentation 2020-11-20 13:57:15 +01:00
psa_crypto_storage.c Merge pull request #3872 from gabor-mezei-arm/3275_use_PSA_ERROR_DATA_INVALID_where_warranted 2021-02-03 20:54:46 +01:00
psa_crypto_storage.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
psa_its_file.c psa_its: Annotate file removal after a failed creation 2020-08-25 22:49:19 +02:00
ripemd160.c Merge branch 'development' into development-restricted 2020-12-03 09:59:42 +01:00
rsa.c Fix an incorrect error code if RSA private operation glitched 2021-01-06 18:22:40 +01:00
rsa_internal.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
sha1.c Merge pull request #731 from gabor-mezei-arm/692_missing_zeroizations_of_sensitive_data 2020-09-18 16:20:13 +02:00
sha256.c Merge pull request #731 from gabor-mezei-arm/692_missing_zeroizations_of_sensitive_data 2020-09-18 16:20:13 +02:00
sha512.c Merge branch 'development' into development-restricted 2020-12-03 09:59:42 +01:00
ssl_cache.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl_ciphersuites.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl_cli.c psa: Move from key handle to key identifier 2020-11-10 16:00:41 +01:00
ssl_cookie.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl_invasive.h Merge pull request #736 from mpg/cf-varpos-copy-dev-restricted 2020-08-25 14:35:55 +01:00
ssl_msg.c Merge pull request #781 from mpg/cipher-auth-crypt-restricted 2020-12-07 12:58:36 +00:00
ssl_srv.c Merge pull request #3547 from ronald-cron-arm/psa-openless 2020-11-20 18:48:33 +01:00
ssl_ticket.c Stop using deprecated functions in the library 2020-12-03 12:25:10 +01:00
ssl_tls.c Use size_t instead of uint32_t for ssl I/O buffer lengths 2021-01-11 09:13:58 -05:00
ssl_tls13_keys.c Comment on hardcoding of maximum HKDF key expansion of 255 Bytes 2020-09-16 09:50:17 +01:00
ssl_tls13_keys.h Comment on hardcoding of maximum HKDF key expansion of 255 Bytes 2020-09-16 09:50:17 +01:00
threading.c Fixes two _POSIX_C_SOURCE typos. 2020-11-13 09:20:18 +00:00
timing.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
version.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
version_features.c Add a flag for disabling fallback in ecp.c 2021-01-08 16:43:43 +01:00
x509.c x509.c: Remove one unnecessary cast 2020-09-01 11:04:53 +02:00
x509_create.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
x509_crl.c Merge development into development-restricted 2020-08-20 11:07:12 +01:00
x509_crt.c Merge pull request #773 from paul-elliott-arm/discrepancy_cert 2020-12-03 12:19:39 +01:00
x509_csr.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
x509write_crt.c Mark basic constraints critical as appropriate. 2020-09-21 18:25:35 -07:00
x509write_csr.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
xtea.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00