mbedtls/library
Hanno Becker def9bdc152 Don't store the peer CRT chain twice during renegotiation
Context: During a handshake, the SSL/TLS handshake logic constructs
an instance of ::mbedtls_ssl_session representing the SSL session
being established. This structure contains information such as the
session's master secret, the peer certificate, or the session ticket
issues by the server (if applicable).
During a renegotiation, the new session is constructed aside the existing
one and destroys and replaces the latter only when the renegotiation is
complete. While conceptually clear, this means that during the renegotiation,
large pieces of information such as the peer's CRT or the session ticket
exist twice in memory, even though the original versions are removed
eventually.

This commit removes the simultaneous presence of two peer CRT chains
in memory during renegotiation, in the following way:
- Unlike in the case of SessionTickets handled in the previous commit,
  we cannot simply free the peer's CRT chain from the previous handshake
  before parsing the new one, as we need to verify that the peer's end-CRT
  hasn't changed to mitigate the 'Triple Handshake Attack'.
- Instead, we perform a binary comparison of the original peer end-CRT
  with the one presented during renegotiation, and if it succeeds, we
  avoid re-parsing CRT by moving the corresponding CRT pointer from the
  old to the new session structure.
- The remaining CRTs in the peer's chain are not affected by the triple
  handshake attack protection, and for them we may employ the canonical
  approach of freeing them before parsing the remainder of the new chain.

Note that this commit intends to not change any observable behavior
of the stack. In particular:
- The peer's CRT chain is still verified during renegotiation.
- The tail of the peer's CRT chain may change during renegotiation.
2019-02-08 14:26:41 +00:00
..
.gitignore
aes.c Fix off-by-one in iv_off check and add tests 2018-12-18 12:22:40 +01:00
aesni.c Warn if using a memory sanitizer on AESNI 2018-04-05 15:37:38 +02:00
arc4.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
aria.c Implement parameter validation for ARIA module 2018-12-19 12:51:00 +00:00
asn1parse.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
asn1write.c Merge remote-tracking branch 'upstream-public/pr/2101' into development 2018-12-07 16:15:31 +00:00
base64.c Add comment to integer overflow fix in base64.c 2017-02-15 23:31:07 +02:00
bignum.c Merge remote-tracking branch 'origin/pr/2214' into development 2019-01-30 15:08:25 +00:00
blowfish.c Implement parameter validation for Blowfish module 2018-12-19 12:52:59 +00:00
camellia.c Minor improvements to Camellia module and documentation 2018-12-19 13:42:05 +00:00
ccm.c Improve details of CCM parameter validation and documentation 2018-12-19 19:02:39 +01:00
certs.c Update hardcoded certificates in library/certs.c 2018-11-02 10:52:38 +00:00
chacha20.c Implement parameter validation for ChaCha/Poly modules 2018-12-18 15:30:30 +00:00
chachapoly.c Fix wrong conditional in free() functions 2018-12-18 15:30:30 +00:00
cipher_wrap.c Fix after PR comments 2018-07-23 18:18:32 +01:00
cipher.c Remove unnecessary parameter validation from the Cipher module 2018-12-19 17:34:58 +01:00
cmac.c Merge remote-tracking branch 'public/pr/1390' into development 2018-06-27 10:51:47 +01:00
CMakeLists.txt Use CMAKE_BUILD_TYPE to do Asan builds 2019-01-09 22:35:57 +01:00
ctr_drbg.c Merge remote-tracking branch 'origin/pr/2055' into development 2019-01-30 13:23:03 +00:00
debug.c Merge remote-tracking branch 'origin/pr/1551' into development 2019-01-30 13:24:55 +00:00
des.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
dhm.c Merge remote-tracking branch 'public/pr/1721' into development-restricted 2018-12-20 12:37:13 +00:00
ecdh.c Minor fixes to parameter validation in ECDH module 2018-12-18 23:32:42 +00:00
ecdsa.c Return error code of underlying function. 2019-01-10 10:47:42 +02:00
ecjpake.c Fix #2370, minor typos and spelling mistakes 2019-01-24 10:37:40 +01:00
ecp_curves.c Implement parameter validation for ECP module 2018-12-18 13:00:48 +00:00
ecp.c Fix mbedtls_ecp_curve_info_from_name() for NULL input 2018-12-19 08:52:05 +00:00
entropy_poll.c Add missing bracket 2018-11-06 13:12:47 +00:00
entropy.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
error.c Fix #2370, minor typos and spelling mistakes 2019-01-24 10:37:40 +01:00
gcm.c Improve parameter validation in mbedtls_gcm_free() 2018-12-19 17:32:19 +01:00
havege.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
hkdf.c Fix issue if salt = NULL and salt_len !=0 in mbedtls_hkdf_extract() 2018-07-23 10:34:47 -07:00
hmac_drbg.c Streamline mbedtls_xxx_drbg_update_seed_file 2018-11-26 19:26:22 +01:00
Makefile Fix #2370, minor typos and spelling mistakes 2019-01-24 10:37:40 +01:00
md2.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
md4.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
md5.c Fix Lucky 13 cache attack on MD/SHA padding 2018-07-05 10:47:00 +02:00
md_wrap.c New MD API: rename functions from _ext to _ret 2018-01-22 11:54:42 +01:00
md.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
memory_buffer_alloc.c Fix braces in mbedtls_memory_buffer_alloc_status() 2018-06-12 16:56:04 +01:00
net_sockets.c Merge remote-tracking branch 'public/pr/1198' into development 2018-07-24 17:20:17 +01:00
nist_kw.c Remove faulty cipher_finish calls from nist_kw 2018-12-20 12:15:40 +01:00
oid.c pkcs5v2: add support for additional hmacSHA algorithms 2018-02-08 17:18:15 +08:00
padlock.c
pem.c Clear pk context and other minor changes in *_free() procedures 2018-06-12 18:25:09 +03:00
pk_wrap.c Fix or improve some comments (and whitespace) 2018-10-15 15:27:49 +02:00
pk.c Merge remote-tracking branch 'public/pr/1721' into development-restricted 2018-12-20 12:37:13 +00:00
pkcs5.c Guard mbedtls_pkcs5_pbes2() by MBEDTLS_ASN1_PARSE_C 2018-10-16 13:39:40 +01:00
pkcs11.c
pkcs12.c Make PBE-related parts of PKCS12 depend on MBEDTLS_ASN1_PARSE_C 2018-10-16 13:39:40 +01:00
pkparse.c pk_parse*keyfile: explicitly validate path=NULL 2018-12-19 17:37:02 +01:00
pkwrite.c PK parse/write: support keylen=0 correctly 2018-12-19 17:03:28 +01:00
platform_util.c Remove the library provided function of MBEDTLS_PARAM_FAILED 2018-12-11 12:28:56 +01:00
platform.c Merge remote-tracking branch 'origin/pr/1551' into development 2019-01-30 13:24:55 +00:00
poly1305.c Fix wrong conditional in free() functions 2018-12-18 15:30:30 +00:00
ripemd160.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
rsa_internal.c Bignum: Deprecate mbedtls_mpi_is_prime() 2018-10-09 16:36:53 +01:00
rsa.c Merge remote-tracking branch 'public/pr/1721' into development-restricted 2018-12-20 12:37:13 +00:00
sha1.c Move SHA1_VALIDATE[_RET] outside of MBEDTLS_SHA1_ALT guard 2018-12-20 10:18:05 +00:00
sha256.c Move SHA256_VALIDATE[_RET] outside of MBEDTLS_SHA256_ALT guard 2018-12-20 10:24:29 +00:00
sha512.c Move SHA512_VALIDATE[_RET] outside of MBEDTLS_SHA512_ALT guard 2018-12-20 10:24:00 +00:00
ssl_cache.c Address PR review comments 2017-10-29 17:53:52 +02:00
ssl_ciphersuites.c Merge remote-tracking branch 'upstream-public/pr/1378' into development 2018-08-10 10:59:53 +01:00
ssl_cli.c SSL/TLS client: Remove old session ticket on renegotiation 2019-02-08 14:26:41 +00:00
ssl_cookie.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
ssl_srv.c Fix #2370, minor typos and spelling mistakes 2019-01-24 10:37:40 +01:00
ssl_ticket.c Indentation fix 2018-10-25 16:07:16 +01:00
ssl_tls.c Don't store the peer CRT chain twice during renegotiation 2019-02-08 14:26:41 +00:00
threading.c Don't declare and define gmtime()-mutex on Windows platforms 2018-09-06 12:09:56 +01:00
timing.c Merge remote-tracking branch 'public/pr/1777' into development-proposed 2018-11-04 18:51:36 +00:00
version_features.c Merge remote-tracking branch 'origin/pr/1551' into development 2019-01-30 13:24:55 +00:00
version.c Fix missing void argument declarations #678 2016-11-04 23:05:56 +01:00
x509_create.c Break overly long line in library/x509_create.c 2018-11-02 10:52:38 +00:00
x509_crl.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
x509_crt.c Add a new X.509 API call for copy-less parsing of CRTs 2019-02-08 14:24:58 +00:00
x509_csr.c Fix CSR parsing header call 2018-10-07 17:48:37 +01:00
x509.c Fix #2370, minor typos and spelling mistakes 2019-01-24 10:37:40 +01:00
x509write_crt.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
x509write_csr.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00
xtea.c Rename mbedtls_zeroize to mbedtls_platform_zeroize 2018-04-17 10:00:21 -05:00