mbedtls/library
Gilles Peskine 377a310da4 Catch failures of AES or DES operations
Declare all AES and DES functions that return int as needing to have
their result checked, and do check the result in our code.

A DES or AES block operation can fail in alternative implementations of
mbedtls_internal_aes_encrypt() (under MBEDTLS_AES_ENCRYPT_ALT),
mbedtls_internal_aes_decrypt() (under MBEDTLS_AES_DECRYPT_ALT),
mbedtls_des_crypt_ecb() (under MBEDTLS_DES_CRYPT_ECB_ALT),
mbedtls_des3_crypt_ecb() (under MBEDTLS_DES3_CRYPT_ECB_ALT).
A failure can happen if the accelerator peripheral is in a bad state.
Several block modes were not catching the error.

This commit does the following code changes, grouped together to avoid
having an intermediate commit where the build fails:

* Add MBEDTLS_CHECK_RETURN to all functions returning int in aes.h and des.h.
* Fix all places where this causes a GCC warning, indicating that our code
  was not properly checking the result of an AES operation:
    * In library code: on failure, goto exit and return ret.
    * In pkey programs: goto exit.
    * In the benchmark program: exit (not ideal since there's no error
      message, but it's what the code currently does for failures).
    * In test code: TEST_ASSERT.
* Changelog entry.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-29 20:40:31 +02:00
..
.gitignore Split libs with make + general make cleanups 2015-06-25 10:59:56 +02:00
aes.c Catch failures of AES or DES operations 2021-09-29 20:40:31 +02: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 ARIA: add missing context init/free 2021-05-25 18:45:04 +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 Code style fixups 2021-03-04 14:34:50 +00:00
bignum.c Replace _RR with prec_RR to prevent reserved identifier clashes 2021-07-14 14:30:34 +01:00
blowfish.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
camellia.c CAMELLIA: add missing context init/free 2021-05-25 18:45:04 +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 psa: config: Add CAMELLIA to the list of possible CMAC ciphers 2021-03-25 14:25:46 +01: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 Allow skipping 3DES in CMAC self-test when ALT implemented 2021-04-30 10:09:52 +02:00
CMakeLists.txt Bump SO version for libmbedcrypto 2021-07-02 14:59:26 +01:00
common.h Move MBEDTLS_ERR_ADD macro and functions to error.* 2021-04-13 15:21:43 +01:00
ctr_drbg.c Document mutex invariant for CTR_DRBG 2021-02-22 19:24:03 +01:00
debug.c Add missing parentheses 2021-06-07 21:42:15 +02:00
des.c Catch failures of AES or DES operations 2021-09-29 20:40:31 +02:00
dhm.c DHM: add notes about leading zeros 2021-06-02 21:39:31 +02:00
ecdh.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ecdsa.c avoid "maybe-uninitialized" and "free-nonheap-object" errors/warnings with gcc11 2021-05-12 09:37:00 -04:00
ecjpake.c ecjpake_zkp_read() now returns ...BAD_INPUT_DATA when r len == 0 and test follows that 2021-03-17 11:36:31 +01:00
ecp.c Fix unused parameter warning 2021-06-25 15:36:55 +01:00
ecp_curves.c Add prefix to BYTES_TO_T_UINT_* 2021-06-25 14:59:15 +01:00
ecp_invasive.h Move mbedtls_mpi_random to the bignum module 2021-06-02 21:31:24 +02:00
entropy.c Merge pull request #3616 from militant-daos/bug_3175 2021-03-30 17:33:08 +02:00
entropy_poll.c Merge pull request #4110 from gilles-peskine-arm/psa-external-random-in-mbedtls 2021-02-22 14:47:29 +00:00
error.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
gcm.c Allow GCM selftest to skip non-12-byte IVs for ALT implementations 2021-02-10 15:34:52 +01: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 Document mutex invariant for HMAC_DRBG 2021-02-22 19:24:03 +01:00
Makefile Bump SO version for libmbedcrypto 2021-07-02 14:59:26 +01:00
md.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
md2.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
md4.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
md5.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
memory_buffer_alloc.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
mps_common.h Capitalise MPS trace macros 2021-04-07 12:45:35 +01:00
mps_error.h Fix Doxygen headers for MPS files 2021-03-29 14:20:18 +01:00
mps_reader.c Capitalise MPS trace macros 2021-04-07 12:45:35 +01:00
mps_reader.h Fix Doxygen headers for MPS files 2021-03-29 14:20:18 +01:00
mps_trace.c Capitalise MPS trace macros 2021-04-07 12:45:35 +01:00
mps_trace.h Capitalise MPS trace macros 2021-04-07 12:45:35 +01:00
net_sockets.c Fix fd range for select on Windows 2021-06-20 23:17:39 +02:00
nist_kw.c Fix null pointer arithmetic in error case 2021-06-01 11:57:18 +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 Apply MBEDTLS_ERROR_ADD to library 2021-04-15 11:19:47 +01:00
pk.c pk.c: Ensure hash_len equals hash in pk_hashlen_helper 2021-06-29 09:31:06 -04:00
pk_wrap.c psa: Move from key handle to key identifier 2020-11-10 16:00:41 +01:00
pkcs5.c Apply MBEDTLS_ERROR_ADD to library 2021-04-15 11:19:47 +01:00
pkcs11.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pkcs12.c Apply MBEDTLS_ERROR_ADD to library 2021-04-15 11:19:47 +01:00
pkparse.c Remove dead code from pk_parse_key_pkcs8_unencrypted_der 2021-04-28 14:12:07 +01: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 Merge pull request #4182 from gabor-mezei-arm/3258_implement_one-shot_MAC_and_cipher 2021-06-30 17:04:11 +01:00
psa_crypto_aead.c Update all uses of old AEAD output size macros 2021-04-15 17:32:06 +02:00
psa_crypto_aead.h psa: aead: Move AEAD driver entry points to psa_crypto_aead.c 2021-04-07 16:03:31 +02:00
psa_crypto_cipher.c Remove obsolete comment 2021-06-30 10:34:28 +02:00
psa_crypto_cipher.h Remove invalid buffer overflow check 2021-06-29 16:39:49 +02:00
psa_crypto_client.c Move the inclusion of crypto_spe.h to psa/crypto_platform.h 2021-06-23 14:45:17 +02:00
psa_crypto_core.h Merge pull request #4357 from gabor-mezei-arm/3267_Implement_psa_sign_message_and_verify 2021-05-17 10:14:46 +02:00
psa_crypto_driver_wrappers.c Fix possible unreachable code 2021-06-25 15:50:35 +02:00
psa_crypto_driver_wrappers.h Dispatch cipher functions through the driver interface 2021-06-24 16:57:29 +02:00
psa_crypto_ecp.c Move mbedtls_md_info_from_psa into the mbedtls hash driver 2021-03-15 12:14:40 +01:00
psa_crypto_ecp.h psa: Rework ECDSA sign/verify support in the transparent test driver 2021-02-18 15:45:12 +01:00
psa_crypto_hash.c psa: hash: Fix is_hash_accelerated signature 2021-04-01 10:50:03 +02:00
psa_crypto_hash.h psa: include: Merge crypto_builtin_hash.h and crypto_builtin_cipher.h 2021-04-01 16:54:30 +02:00
psa_crypto_invasive.h Rework MAC algorithm / key type validation 2021-03-03 19:58:02 +01:00
psa_crypto_its.h Update documentation 2020-11-25 13:10:50 +01:00
psa_crypto_mac.c psa: mac: Add MAC compute builtin implementation 2021-06-22 13:43:13 +02:00
psa_crypto_mac.h Move is_sign and mac_size checking back to PSA core scope 2021-05-11 18:56:01 +02:00
psa_crypto_random_impl.h Work around MSVC bug with duplicate static declarations 2021-02-16 18:55:05 +01:00
psa_crypto_rsa.c Improve psa_rsa_decode_md_type() 2021-06-22 12:57:05 +02:00
psa_crypto_rsa.h psa: Add RSA sign/verify hash support to the transparent test driver 2021-02-18 15:45:06 +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_slot_management.c Merge pull request #4605 from gabor-mezei-arm/3267_sign_verify_key_policies 2021-06-30 14:51:03 +01:00
psa_crypto_slot_management.h psa: Fix error code when creating/registering a key with invalid id 2021-04-01 14:05:41 +02:00
psa_crypto_storage.c Move the inclusion of crypto_spe.h to psa/crypto_platform.h 2021-06-23 14:45:17 +02:00
psa_crypto_storage.h Rename PSA_KEY_SLOT_COUNT to MBEDTLS_PSA_KEY_SLOT_COUNT 2021-02-15 14:26:44 +01:00
psa_its_file.c Correct fix for potential truncation 2021-03-10 17:00:32 +00:00
ripemd160.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
rsa.c Fix misc issues with unused parameters and check-names.sh 2021-04-13 15:26:59 +01:00
rsa_internal.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
sha1.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
sha256.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
sha512.c Revert "Remove deprecated things from hashing modules" 2021-04-15 12:28:15 +02:00
ssl_cache.c Don't check ciphersuite and compression in SSL session cache lookup 2021-05-19 05:09:56 +01:00
ssl_ciphersuites.c Fix dependencies on SHA384 cipher suites 2021-05-19 16:58:08 +02:00
ssl_cli.c TLS UNSUPPORTED_EXTENSION error code changes 2021-06-29 15:21:44 +01:00
ssl_cookie.c Improve documentation for error code checking 2021-04-22 15:28:56 +01: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 Fix misuse of MD API in SSL constant-flow HMAC 2021-05-19 10:40:02 +02:00
ssl_srv.c Don't check ciphersuite and compression in SSL session cache lookup 2021-05-19 05:09:56 +01:00
ssl_ticket.c Stop using deprecated functions in the library 2020-12-03 12:25:10 +01:00
ssl_tls.c Fix TLS alert codes 2021-06-29 09:45:08 +01: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 Explain the usage of is_valid in pthread mutexes 2021-02-22 19:24:03 +01: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 Implement support for MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS 2021-04-15 15:04:26 +02:00
x509.c Apply MBEDTLS_ERROR_ADD to library 2021-04-15 11:19:47 +01:00
x509_create.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
x509_crl.c Apply MBEDTLS_ERROR_ADD to library 2021-04-15 11:19:47 +01:00
x509_crt.c Document more precisely what goes into the default profile 2021-06-07 21:24:26 +02:00
x509_csr.c Apply MBEDTLS_ERROR_ADD to library 2021-04-15 11:19:47 +01:00
x509write_crt.c avoid "maybe-uninitialized" and "free-nonheap-object" errors/warnings with gcc11 2021-05-12 09:37:00 -04:00
x509write_csr.c avoid "maybe-uninitialized" and "free-nonheap-object" errors/warnings with gcc11 2021-05-12 09:37:00 -04:00
xtea.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00