boringssl/ssl
David Benjamin 16285ea800 Rewrite DTLS handshake message sending logic.
This fixes a number of bugs with the original logic:

- If handshake messages are fragmented and writes need to be retried, frag_off
  gets completely confused.

- The BIO_flush call didn't set rwstate, so it wasn't resumable at that point.

- The msg_callback call gets garbage because the fragment header would get
  scribbled over the handshake buffer.

The original logic was also extremely confusing with how it handles init_off.
(init_off gets rewound to make room for the fragment header.  Depending on
where you pause, resuming may or may not have already been rewound.)

For simplicity, just allocate a new buffer to assemble the fragment in and
avoid clobbering the old one. I don't think it's worth the complexity to
optimize that. If we want to optimize this sort of thing, not clobbering seems
better anyway because the message may need to be retransmitted. We could avoid
doing a copy when buffering the outgoing message for retransmission later.

We do still need to track how far we are in sending the current message via
init_off, so I haven't opted to disconnect this function from
init_{buf,off,num} yet.

Test the fix to the retry + fragment case by having the splitHandshake option
to the state machine tests, in DTLS, also clamp the MTU to force handshake
fragmentation.

Change-Id: I66f634d6c752ea63649db8ed2f898f9cc2b13908
Reviewed-on: https://boringssl-review.googlesource.com/6421
Reviewed-by: Adam Langley <agl@google.com>
2015-11-06 21:43:32 +00:00
..
pqueue Add a run_tests target to run all tests. 2015-10-26 20:33:44 +00:00
test Rewrite DTLS handshake message sending logic. 2015-11-06 21:43:32 +00:00
CMakeLists.txt Fix shared library build on OS X. 2015-10-26 23:39:47 +00:00
custom_extensions.c
d1_both.c Rewrite DTLS handshake message sending logic. 2015-11-06 21:43:32 +00:00
d1_clnt.c Add missing state to DTLS state machine. 2015-11-06 20:34:48 +00:00
d1_lib.c Separate CCS and handshake writing in DTLS. 2015-11-04 00:11:14 +00:00
d1_meth.c Ditch remaining filename comments from public headers and ssl/ 2015-10-20 18:40:05 +00:00
d1_pkt.c Don't use ssl3_write_pending in DTLS. 2015-11-02 23:17:24 +00:00
d1_srtp.c Fix a missing initializer that only Clang warns about. 2015-10-30 17:24:03 -07:00
d1_srvr.c Add server-side support for asynchronous RSA decryption. 2015-10-26 20:26:20 +00:00
dtls_record.c
internal.h Add SSL_CIPHER_get_min_version and tidy up SSL_TLSV1_2 logic. 2015-11-06 19:56:29 +00:00
s3_both.c
s3_clnt.c Add SSL_CIPHER_get_min_version and tidy up SSL_TLSV1_2 logic. 2015-11-06 19:56:29 +00:00
s3_enc.c
s3_lib.c Add SSL_CIPHER_get_min_version and tidy up SSL_TLSV1_2 logic. 2015-11-06 19:56:29 +00:00
s3_meth.c
s3_pkt.c Add ssl_renegotiate_ignore. 2015-11-03 21:58:13 +00:00
s3_srvr.c Change the type of |EC_GROUP_get_degree| and friends to |unsigned|. 2015-10-27 16:48:04 +00:00
ssl_aead_ctx.c Revert most of "Refactor ChaCha20-Poly1305 AEAD nonce handling." 2015-10-29 18:40:33 +00:00
ssl_asn1.c Fix all sign/unsigned warnings with Clang and GCC. 2015-10-27 22:48:00 +00:00
ssl_buffer.c Fix DTLS asynchronous write handling. 2015-11-02 23:16:22 +00:00
ssl_cert.c
ssl_cipher.c Add various functions for SSL_CIPHER. 2015-11-06 19:26:22 +00:00
ssl_file.c More SSL_SESSION serialization functions. 2015-10-26 17:57:50 +00:00
ssl_lib.c Add SSL_get_ivs. 2015-11-04 19:45:28 +00:00
ssl_rsa.c Add server-side support for asynchronous RSA decryption. 2015-10-26 20:26:20 +00:00
ssl_session.c Tidy up SSL_CTX_add_session. 2015-10-26 19:22:40 +00:00
ssl_stat.c Document alert handling. 2015-10-20 19:03:24 +00:00
ssl_test.cc Refactor ChaCha20-Poly1305 AEAD nonce handling. 2015-10-27 01:01:42 +00:00
t1_enc.c
t1_lib.c Add SSL_CIPHER_get_min_version and tidy up SSL_TLSV1_2 logic. 2015-11-06 19:56:29 +00:00
tls_record.c Add use counters for SSL_OP_TLS_D5_BUG and SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER. 2015-10-20 18:22:47 +00:00