mbedtls/library
Manuel Pégourié-Gonnard 0771d41584 Fix missing length check
There was a check against the remaining size of the buffer, which used
to be correct, but was broken two commits ago when we started not just
copying the input but also adding to it.

Replace it with a check that the input length is not greater that what's
expected for this step. This guarantees we won't overflow the internal
buffer.

While at it, add an explicit cast to uint8_t when writing the length to
the buffer, so silence an MSVC warning. This cast is safe because we
checked that the length is no larger than 65 or 32 (depending on the
step), so in any case is fits in one byte.

This was found because some lengths had not been adjusted in the test
suite, and instead of failing cleanly, library code performed buffer
overflows. I'll fix the tests in the next commit.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-06 09:30:34 +02:00
..
.gitignore
aes.c Re-introduce ENUM validation in aes.c 2022-08-31 10:14:57 +01:00
aesni.c Refactor AES context to be shallow-copyable 2022-06-29 16:17:50 +01:00
aesni.h
aria.c
asn1parse.c
asn1write.c Fix bug whereby 0 was written as 0200 rather than 020100 2022-06-10 20:13:33 +02:00
base64.c
bignum.c Update name of mbedtls_mpi_montg_init() 2022-09-15 15:05:59 +01:00
bignum_core.c Correct the aliasing requirements in doc for mbedtls_mpi_core_montmul(), and test them 2022-09-29 14:40:21 +01:00
bignum_core.h Fix doc regarding aliasing of modulus input to mbedtls_mpi_core_montmul() 2022-09-29 17:20:18 +01:00
bignum_mod.c Improve documentation 2022-08-19 13:11:22 +01:00
bignum_mod.h Improve documentation 2022-08-19 13:11:22 +01:00
bignum_mod_raw.c Fix typos 2022-08-22 09:08:04 +01:00
bignum_mod_raw.h Fix typos 2022-08-22 09:08:04 +01:00
bn_mul.h Merge pull request #6090 from hanno-arm/fix_bnmul_arm_v7a 2022-08-18 08:48:03 +01:00
camellia.c Re-introduce ENUM validation in camellia.c 2022-08-31 10:14:57 +01:00
ccm.c Fix typos in documentation and constants with typo finding tool 2022-05-18 14:15:33 -04:00
chacha20.c Remove NULL pointer validation in chacha20.c 2022-08-31 10:14:57 +01:00
chachapoly.c Remove NULL pointer validation in chachapoly.c 2022-08-31 10:18:14 +01:00
check_crypto_config.h Define ECJPAKE_TO_PMS in config_psa only if SHA_256 is available 2022-09-14 14:57:51 -04:00
cipher.c Re-introduce ENUM validation in cipher.c 2022-08-31 10:14:57 +01:00
cipher_wrap.c
cipher_wrap.h
cmac.c
CMakeLists.txt Add PSA PAKE buildin implementation 2022-08-31 10:49:18 +02:00
common.h
constant_time.c Merge pull request #6095 from gabor-mezei-arm/6016_add_new_modulus_and_residue_structures 2022-08-23 09:02:43 +01:00
constant_time_internal.h Fix typos 2022-08-22 09:08:04 +01:00
constant_time_invasive.h
ctr_drbg.c ctr_drbg: remove mbedtls_aes_init call from mbedtls_ctr_drbg_seed 2022-08-11 16:38:45 +08:00
debug.c
des.c
dhm.c Remove NULL pointer validation in dhm.c 2022-08-31 10:15:59 +01:00
ecdh.c Reintroduce enum validation ecdh.c 2022-07-27 14:43:38 +01:00
ecdsa.c Remove NULL pointer validations in ecdsa.c 2022-07-27 14:28:20 +01:00
ecjpake.c Merge pull request #5871 from superna9999/4153-psa-expose-ec-j-pake 2022-09-15 09:25:55 +02:00
ecp.c Broke 2 long lines 2022-07-28 10:31:16 +01:00
ecp_curves.c Remove bignum_internal.h, moving contents to bignum_core.h 2022-08-23 12:01:39 +01:00
ecp_internal_alt.h
ecp_invasive.h
entropy.c Call setbuf when reading or writing files: library 2022-06-30 17:03:40 +02:00
entropy_poll.c Call setbuf when reading or writing files: library 2022-06-30 17:03:40 +02:00
entropy_poll.h
gcm.c Re-introduce ENUM validation in gcm.c 2022-08-31 10:14:57 +01:00
hash_info.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
hash_info.h hash_info.h: add MBEDTLS_MAX_HASH_SIZE macro 2022-09-06 14:18:39 +02:00
hkdf.c
hmac_drbg.c Call setbuf when reading or writing files: library 2022-06-30 17:03:40 +02:00
Makefile Add PSA PAKE buildin implementation 2022-08-31 10:49:18 +02:00
md.c Call setbuf when reading or writing files: library 2022-06-30 17:03:40 +02:00
md5.c
md_wrap.h
memory_buffer_alloc.c Redo of PR#5345. Fixed spelling and typographical errors found by CodeSpell. 2022-05-11 21:25:51 +01:00
mps_common.h Fix typos in documentation and constants with typo finding tool 2022-05-18 14:15:33 -04:00
mps_error.h
mps_reader.c
mps_reader.h
mps_trace.c
mps_trace.h
net_sockets.c Add a missing guard for time.h in net_sockets.c 2022-03-04 05:07:45 -05:00
nist_kw.c
oid.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
padlock.c Add fallback when rk unaligned with padlock 2022-07-05 11:55:15 +01:00
padlock.h
pem.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
pk.c Remove extra spacings 2022-08-31 10:14:25 +01:00
pk_wrap.c Merge pull request #6142 from tom-cosgrove-arm/fix-comments-in-docs-and-comments 2022-07-29 12:59:05 +01:00
pk_wrap.h Guard pk_opaque_rsa_decrypt() with PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 2022-05-04 11:02:37 +02:00
pkcs5.c pkcs5: improve error handling 2022-09-02 04:15:34 -04:00
pkcs12.c Make use of MBEDTLS_MAX_HASH_SIZE macro 2022-09-06 14:18:45 +02:00
pkparse.c Remove extra spacings 2022-08-31 10:14:25 +01:00
pkwrite.c Remove extra spacings 2022-08-31 10:14:25 +01:00
pkwrite.h Rename max sizes of RSA & EC DER keys defines 2022-03-01 10:03:21 +01:00
platform.c Fix code formatting 2022-07-01 16:43:25 +01:00
platform_util.c Add comment 2022-05-12 09:45:03 +01:00
poly1305.c Remove NULL pointer validation in poly1305.c 2022-08-31 10:18:14 +01:00
psa_crypto.c Merge pull request #6115 from AndrzejKurek/ecjpake-kdf-tls-1-2 2022-09-28 09:47:32 +02:00
psa_crypto_aead.c
psa_crypto_aead.h Redo of PR#5345. Fixed spelling and typographical errors found by CodeSpell. 2022-05-11 21:25:51 +01:00
psa_crypto_cipher.c Use double quotes to include private header file psa_crypto_cipher.h 2022-08-02 12:44:35 +02:00
psa_crypto_cipher.h
psa_crypto_client.c
psa_crypto_core.h
psa_crypto_driver_wrappers.h Merge pull request #5292 from mprse/asym_encrypt 2022-03-10 20:07:38 +01:00
psa_crypto_ecp.c Rm now-duplicate helper function 2022-07-18 21:28:38 +02:00
psa_crypto_ecp.h
psa_crypto_hash.c Rm now-duplicate helper function 2022-07-18 21:28:38 +02:00
psa_crypto_hash.h Rm now-duplicate helper function 2022-07-18 21:28:38 +02:00
psa_crypto_invasive.h
psa_crypto_its.h
psa_crypto_mac.c
psa_crypto_mac.h
psa_crypto_pake.c Fix missing length check 2022-10-06 09:30:34 +02:00
psa_crypto_random_impl.h
psa_crypto_rsa.c Rm now-duplicate helper function 2022-07-18 21:28:38 +02:00
psa_crypto_rsa.h
psa_crypto_se.c
psa_crypto_se.h
psa_crypto_slot_management.c
psa_crypto_slot_management.h
psa_crypto_storage.c Erase secrets in allocated memory before freeing said memory 2022-02-25 11:14:59 +01:00
psa_crypto_storage.h
psa_its_file.c Call setbuf when reading or writing files: library 2022-06-30 17:03:40 +02:00
ripemd160.c
rsa.c Merge pull request #6138 from Zaya-dyno/validation_remove_change_key_agree 2022-09-23 17:04:20 +02:00
rsa_alt_helpers.c
rsa_alt_helpers.h
sha1.c Remove NULL pointer validation in sha1.c 2022-08-31 10:15:25 +01:00
sha256.c Re-introduce ENUM validation in sha256.c 2022-08-31 10:15:25 +01:00
sha512.c Re-introduce ENUM validation in sha512.c 2022-08-31 10:15:25 +01:00
ssl_cache.c Merge remote-tracking branch 'mbedtls-restricted/development-restricted' into mbedtls-3.2.0rc0-pr 2022-07-11 10:22:37 +02:00
ssl_ciphersuites.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
ssl_client.c Rename functions and add test messages 2022-07-21 15:30:04 +02:00
ssl_client.h Mark internal int SSL functions CHECK_RETURN_CRITICAL 2022-06-20 21:12:55 +02:00
ssl_cookie.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
ssl_debug_helpers.h add named group debug helper 2022-05-09 15:49:00 +08:00
ssl_misc.h Merge pull request #6180 from yuhaoth/pr/add-tls13-multiple-session-tickets 2022-09-23 15:48:33 +01:00
ssl_msg.c Add check_return flag 2022-07-20 11:07:29 +08:00
ssl_ticket.c Add explicit cast to satisfy compiler 2022-08-17 16:57:26 +01:00
ssl_tls.c Merge pull request #6180 from yuhaoth/pr/add-tls13-multiple-session-tickets 2022-09-23 15:48:33 +01:00
ssl_tls12_client.c Make use of MBEDTLS_MAX_HASH_SIZE macro 2022-09-06 14:18:45 +02:00
ssl_tls12_server.c Make more use of MBEDTLS_MAX_HASH_SIZE macro 2022-09-13 12:57:05 +02:00
ssl_tls13_client.c Improve message logs and test cases description in psk 2022-09-28 02:07:54 +00:00
ssl_tls13_generic.c Merge pull request #6051 from mprse/permissions_2b_v2 2022-09-28 09:50:04 +02:00
ssl_tls13_invasive.h Merge remote-tracking branch 'mbedtls-restricted/development-restricted' into mbedtls-3.2.0rc0-pr 2022-07-11 10:22:37 +02:00
ssl_tls13_keys.c Replace md translation function 2022-09-16 16:32:27 +08:00
ssl_tls13_keys.h Merge pull request #6167 from yuhaoth/pr/finalize-tls13-session-tickets 2022-09-18 21:18:13 +02:00
ssl_tls13_server.c Merge pull request #6051 from mprse/permissions_2b_v2 2022-09-28 09:50:04 +02:00
threading.c Fix typo "phtreads" to "pthreads" 2022-03-29 17:43:56 +02:00
timing.c Remove the dependency on MBEDTLS_HAVE_TIME from MBEDTLS_TIMING_C 2022-04-08 04:41:42 -04:00
version.c
x509.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
x509_create.c
x509_crl.c Do not include time.h without MBEDTLS_HAVE_TIME 2022-03-04 05:07:45 -05:00
x509_crt.c Make more use of MBEDTLS_MAX_HASH_SIZE macro 2022-09-13 12:57:05 +02:00
x509_csr.c
x509write_crt.c Make legacy_or_psa.h public. 2022-09-16 12:02:48 +02:00
x509write_csr.c Make more use of MBEDTLS_MAX_HASH_SIZE macro 2022-09-13 12:57:05 +02:00