mbedtls/programs/pkey
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
..
CMakeLists.txt Build: Add MBEDTLS_TARGET_PREFIX 2020-10-20 13:44:44 +01:00
dh_client.c Catch failures of AES or DES operations 2021-09-29 20:40:31 +02:00
dh_genprime.c Merge pull request #3574 from makise-homura/e2k_support 2020-08-25 09:46:36 +02:00
dh_prime.txt - Changed saved value to RCF 3526 2048 MODP group 2012-10-03 19:50:54 +00:00
dh_server.c Catch failures of AES or DES operations 2021-09-29 20:40:31 +02:00
ecdh_curve25519.c Merge pull request #3525 from HowJMay/typo 2020-09-10 12:39:25 +01:00
ecdsa.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
gen_key.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
key_app_writer.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
key_app.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
mpi_demo.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pk_decrypt.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pk_encrypt.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pk_sign.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
pk_verify.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_decrypt.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_encrypt.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_genkey.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_priv.txt Normalize line endings 2020-05-27 21:55:08 +02:00
rsa_pub.txt Normalize line endings 2020-05-27 21:55:08 +02:00
rsa_sign_pss.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_sign.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_verify_pss.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
rsa_verify.c Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00