Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Remove renegotiation deferral logic. When the peer or caller requests a renegotiation, OpenSSL doesn't renegotiate immediately. It sets a flag to begin a renegotiation as soon as record-layer read and write buffers are clear. One reason is that OpenSSL's record layer cannot write a handshake record while an application data record is being written. The buffer consistency checks around partial writes will break. None of these cases are relevant for the client auth hack. We already require that renego come in at a quiescent part of the application protocol by forbidding handshake/app_data interleave. The new behavior is now: when a HelloRequest comes in, if the record layer is not idle, the renegotiation is rejected as if SSL_set_reject_peer_renegotiations were set. Otherwise we immediately begin the new handshake. The server may not send any application data between HelloRequest and completing the handshake. The HelloRequest may not be consumed if an SSL_write is pending. Note this does require that Chromium's HTTP stack not attempt to read the HTTP response until the request has been written, but the renegotiation logic already assumes it. Were Chromium to drive the SSL_read state machine early and the server, say, sent a HelloRequest after reading the request headers but before we've sent the whole POST body, the SSL state machine may racily enter renegotiate early, block writing the POST body on the new handshake, which would break Chromium's ERR_SSL_CLIENT_AUTH_CERT_NEEDED plumbing. BUG=429450 Change-Id: I6278240c3bceb5d2e1a2195bdb62dd9e0f4df718 Reviewed-on: https://boringssl-review.googlesource.com/4825 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Remove renegotiation deferral logic. When the peer or caller requests a renegotiation, OpenSSL doesn't renegotiate immediately. It sets a flag to begin a renegotiation as soon as record-layer read and write buffers are clear. One reason is that OpenSSL's record layer cannot write a handshake record while an application data record is being written. The buffer consistency checks around partial writes will break. None of these cases are relevant for the client auth hack. We already require that renego come in at a quiescent part of the application protocol by forbidding handshake/app_data interleave. The new behavior is now: when a HelloRequest comes in, if the record layer is not idle, the renegotiation is rejected as if SSL_set_reject_peer_renegotiations were set. Otherwise we immediately begin the new handshake. The server may not send any application data between HelloRequest and completing the handshake. The HelloRequest may not be consumed if an SSL_write is pending. Note this does require that Chromium's HTTP stack not attempt to read the HTTP response until the request has been written, but the renegotiation logic already assumes it. Were Chromium to drive the SSL_read state machine early and the server, say, sent a HelloRequest after reading the request headers but before we've sent the whole POST body, the SSL state machine may racily enter renegotiate early, block writing the POST body on the new handshake, which would break Chromium's ERR_SSL_CLIENT_AUTH_CERT_NEEDED plumbing. BUG=429450 Change-Id: I6278240c3bceb5d2e1a2195bdb62dd9e0f4df718 Reviewed-on: https://boringssl-review.googlesource.com/4825 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
Factor out the buffering and low-level record code. This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
9 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.]
  56. */
  57. /* ====================================================================
  58. * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
  59. *
  60. * Redistribution and use in source and binary forms, with or without
  61. * modification, are permitted provided that the following conditions
  62. * are met:
  63. *
  64. * 1. Redistributions of source code must retain the above copyright
  65. * notice, this list of conditions and the following disclaimer.
  66. *
  67. * 2. Redistributions in binary form must reproduce the above copyright
  68. * notice, this list of conditions and the following disclaimer in
  69. * the documentation and/or other materials provided with the
  70. * distribution.
  71. *
  72. * 3. All advertising materials mentioning features or use of this
  73. * software must display the following acknowledgment:
  74. * "This product includes software developed by the OpenSSL Project
  75. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  76. *
  77. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  78. * endorse or promote products derived from this software without
  79. * prior written permission. For written permission, please contact
  80. * openssl-core@openssl.org.
  81. *
  82. * 5. Products derived from this software may not be called "OpenSSL"
  83. * nor may "OpenSSL" appear in their names without prior written
  84. * permission of the OpenSSL Project.
  85. *
  86. * 6. Redistributions of any form whatsoever must retain the following
  87. * acknowledgment:
  88. * "This product includes software developed by the OpenSSL Project
  89. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  90. *
  91. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  92. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  93. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  94. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  95. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  96. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  97. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  98. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  99. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  100. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  101. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  102. * OF THE POSSIBILITY OF SUCH DAMAGE.
  103. * ====================================================================
  104. *
  105. * This product includes cryptographic software written by Eric Young
  106. * (eay@cryptsoft.com). This product includes software written by Tim
  107. * Hudson (tjh@cryptsoft.com). */
  108. #include <openssl/ssl.h>
  109. #include <assert.h>
  110. #include <limits.h>
  111. #include <string.h>
  112. #include <openssl/buf.h>
  113. #include <openssl/err.h>
  114. #include <openssl/evp.h>
  115. #include <openssl/mem.h>
  116. #include <openssl/rand.h>
  117. #include "internal.h"
  118. static int do_ssl3_write(SSL *ssl, int type, const uint8_t *buf, unsigned len);
  119. /* ssl3_get_record reads a new input record. On success, it places it in
  120. * |ssl->s3->rrec| and returns one. Otherwise it returns <= 0 on error or if
  121. * more data is needed. */
  122. static int ssl3_get_record(SSL *ssl) {
  123. again:
  124. switch (ssl->s3->recv_shutdown) {
  125. case ssl_shutdown_none:
  126. break;
  127. case ssl_shutdown_fatal_alert:
  128. OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN);
  129. return -1;
  130. case ssl_shutdown_close_notify:
  131. return 0;
  132. }
  133. CBS body;
  134. uint8_t type, alert;
  135. size_t consumed;
  136. enum ssl_open_record_t open_ret =
  137. tls_open_record(ssl, &type, &body, &consumed, &alert,
  138. ssl_read_buffer(ssl), ssl_read_buffer_len(ssl));
  139. if (open_ret != ssl_open_record_partial) {
  140. ssl_read_buffer_consume(ssl, consumed);
  141. }
  142. switch (open_ret) {
  143. case ssl_open_record_partial: {
  144. int read_ret = ssl_read_buffer_extend_to(ssl, consumed);
  145. if (read_ret <= 0) {
  146. return read_ret;
  147. }
  148. goto again;
  149. }
  150. case ssl_open_record_success:
  151. if (CBS_len(&body) > 0xffff) {
  152. OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
  153. return -1;
  154. }
  155. SSL3_RECORD *rr = &ssl->s3->rrec;
  156. rr->type = type;
  157. rr->length = (uint16_t)CBS_len(&body);
  158. rr->data = (uint8_t *)CBS_data(&body);
  159. return 1;
  160. case ssl_open_record_discard:
  161. goto again;
  162. case ssl_open_record_close_notify:
  163. return 0;
  164. case ssl_open_record_fatal_alert:
  165. return -1;
  166. case ssl_open_record_error:
  167. ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
  168. return -1;
  169. }
  170. assert(0);
  171. OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
  172. return -1;
  173. }
  174. int ssl3_write_app_data(SSL *ssl, const void *buf, int len) {
  175. assert(!SSL_in_init(ssl) || SSL_in_false_start(ssl));
  176. return ssl3_write_bytes(ssl, SSL3_RT_APPLICATION_DATA, buf, len);
  177. }
  178. /* Call this to write data in records of type |type|. It will return <= 0 if
  179. * not all data has been sent or non-blocking IO. */
  180. int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) {
  181. const uint8_t *buf = buf_;
  182. unsigned tot, n, nw;
  183. assert(ssl->s3->wnum <= INT_MAX);
  184. tot = ssl->s3->wnum;
  185. ssl->s3->wnum = 0;
  186. /* Ensure that if we end up with a smaller value of data to write out than
  187. * the the original len from a write which didn't complete for non-blocking
  188. * I/O and also somehow ended up avoiding the check for this in
  189. * ssl3_write_pending/SSL_R_BAD_WRITE_RETRY as it must never be possible to
  190. * end up with (len-tot) as a large number that will then promptly send
  191. * beyond the end of the users buffer ... so we trap and report the error in
  192. * a way the user will notice. */
  193. if (len < 0 || (size_t)len < tot) {
  194. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_LENGTH);
  195. return -1;
  196. }
  197. n = (len - tot);
  198. for (;;) {
  199. /* max contains the maximum number of bytes that we can put into a
  200. * record. */
  201. unsigned max = ssl->max_send_fragment;
  202. if (n > max) {
  203. nw = max;
  204. } else {
  205. nw = n;
  206. }
  207. int ret = do_ssl3_write(ssl, type, &buf[tot], nw);
  208. if (ret <= 0) {
  209. ssl->s3->wnum = tot;
  210. return ret;
  211. }
  212. if (ret == (int)n || (type == SSL3_RT_APPLICATION_DATA &&
  213. (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) {
  214. return tot + ret;
  215. }
  216. n -= ret;
  217. tot += ret;
  218. }
  219. }
  220. static int ssl3_write_pending(SSL *ssl, int type, const uint8_t *buf,
  221. unsigned int len) {
  222. if (ssl->s3->wpend_tot > (int)len ||
  223. (!(ssl->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER) &&
  224. ssl->s3->wpend_buf != buf) ||
  225. ssl->s3->wpend_type != type) {
  226. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_WRITE_RETRY);
  227. return -1;
  228. }
  229. int ret = ssl_write_buffer_flush(ssl);
  230. if (ret <= 0) {
  231. return ret;
  232. }
  233. return ssl->s3->wpend_ret;
  234. }
  235. /* do_ssl3_write writes an SSL record of the given type. */
  236. static int do_ssl3_write(SSL *ssl, int type, const uint8_t *buf, unsigned len) {
  237. /* If there is still data from the previous record, flush it. */
  238. if (ssl_write_buffer_is_pending(ssl)) {
  239. return ssl3_write_pending(ssl, type, buf, len);
  240. }
  241. /* If we have an alert to send, lets send it */
  242. if (ssl->s3->alert_dispatch) {
  243. int ret = ssl->method->dispatch_alert(ssl);
  244. if (ret <= 0) {
  245. return ret;
  246. }
  247. /* if it went, fall through and send more stuff */
  248. }
  249. if (len > SSL3_RT_MAX_PLAIN_LENGTH) {
  250. OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
  251. return -1;
  252. }
  253. if (len == 0) {
  254. return 0;
  255. }
  256. size_t max_out = len + SSL_max_seal_overhead(ssl);
  257. if (max_out < len) {
  258. OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
  259. return -1;
  260. }
  261. uint8_t *out;
  262. size_t ciphertext_len;
  263. if (!ssl_write_buffer_init(ssl, &out, max_out) ||
  264. !tls_seal_record(ssl, out, &ciphertext_len, max_out, type, buf, len)) {
  265. return -1;
  266. }
  267. ssl_write_buffer_set_len(ssl, ciphertext_len);
  268. /* memorize arguments so that ssl3_write_pending can detect bad write retries
  269. * later */
  270. ssl->s3->wpend_tot = len;
  271. ssl->s3->wpend_buf = buf;
  272. ssl->s3->wpend_type = type;
  273. ssl->s3->wpend_ret = len;
  274. /* we now just need to write the buffer */
  275. return ssl3_write_pending(ssl, type, buf, len);
  276. }
  277. static int consume_record(SSL *ssl, uint8_t *out, int len, int peek) {
  278. SSL3_RECORD *rr = &ssl->s3->rrec;
  279. if (len <= 0) {
  280. return len;
  281. }
  282. if (len > (int)rr->length) {
  283. len = (int)rr->length;
  284. }
  285. memcpy(out, rr->data, len);
  286. if (!peek) {
  287. rr->length -= len;
  288. rr->data += len;
  289. if (rr->length == 0) {
  290. /* The record has been consumed, so we may now clear the buffer. */
  291. ssl_read_buffer_discard(ssl);
  292. }
  293. }
  294. return len;
  295. }
  296. int ssl3_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len,
  297. int peek) {
  298. assert(!SSL_in_init(ssl));
  299. assert(ssl->s3->initial_handshake_complete);
  300. *out_got_handshake = 0;
  301. SSL3_RECORD *rr = &ssl->s3->rrec;
  302. for (;;) {
  303. /* A previous iteration may have read a partial handshake message. Do not
  304. * allow more app data in that case. */
  305. int has_hs_data = ssl->init_buf != NULL && ssl->init_buf->length > 0;
  306. /* Get new packet if necessary. */
  307. if (rr->length == 0 && !has_hs_data) {
  308. int ret = ssl3_get_record(ssl);
  309. if (ret <= 0) {
  310. return ret;
  311. }
  312. }
  313. if (has_hs_data || rr->type == SSL3_RT_HANDSHAKE) {
  314. /* Post-handshake data prior to TLS 1.3 is always renegotiation, which we
  315. * never accept as a server. Otherwise |ssl3_get_message| will send
  316. * |SSL_R_EXCESSIVE_MESSAGE_SIZE|. */
  317. if (ssl->server && ssl3_protocol_version(ssl) < TLS1_3_VERSION) {
  318. ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_NO_RENEGOTIATION);
  319. OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION);
  320. return -1;
  321. }
  322. /* Parse post-handshake handshake messages. */
  323. int ret = ssl3_get_message(ssl, -1, ssl_dont_hash_message);
  324. if (ret <= 0) {
  325. return ret;
  326. }
  327. *out_got_handshake = 1;
  328. return -1;
  329. }
  330. if (rr->type != SSL3_RT_APPLICATION_DATA) {
  331. OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_RECORD);
  332. ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);
  333. return -1;
  334. }
  335. if (rr->length != 0) {
  336. return consume_record(ssl, buf, len, peek);
  337. }
  338. /* Discard empty records and loop again. */
  339. }
  340. }
  341. int ssl3_read_change_cipher_spec(SSL *ssl) {
  342. SSL3_RECORD *rr = &ssl->s3->rrec;
  343. if (rr->length == 0) {
  344. int ret = ssl3_get_record(ssl);
  345. if (ret <= 0) {
  346. return ret;
  347. }
  348. }
  349. if (rr->type != SSL3_RT_CHANGE_CIPHER_SPEC) {
  350. ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);
  351. OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_RECORD);
  352. return -1;
  353. }
  354. if (rr->length != 1 || rr->data[0] != SSL3_MT_CCS) {
  355. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_CHANGE_CIPHER_SPEC);
  356. ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
  357. return -1;
  358. }
  359. ssl_do_msg_callback(ssl, 0 /* read */, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data,
  360. rr->length);
  361. rr->length = 0;
  362. ssl_read_buffer_discard(ssl);
  363. return 1;
  364. }
  365. void ssl3_read_close_notify(SSL *ssl) {
  366. /* Read records until an error or close_notify. */
  367. while (ssl3_get_record(ssl) > 0) {
  368. ;
  369. }
  370. }
  371. int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len) {
  372. SSL3_RECORD *rr = &ssl->s3->rrec;
  373. for (;;) {
  374. /* Get new packet if necessary. */
  375. if (rr->length == 0) {
  376. int ret = ssl3_get_record(ssl);
  377. if (ret <= 0) {
  378. return ret;
  379. }
  380. }
  381. if (rr->type != SSL3_RT_HANDSHAKE) {
  382. OPENSSL_PUT_ERROR(SSL, SSL_R_UNEXPECTED_RECORD);
  383. ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);
  384. return -1;
  385. }
  386. if (rr->length != 0) {
  387. return consume_record(ssl, buf, len, 0 /* consume data */);
  388. }
  389. /* Discard empty records and loop again. */
  390. }
  391. }
  392. int ssl3_send_alert(SSL *ssl, int level, int desc) {
  393. /* It is illegal to send an alert when we've already sent a closing one. */
  394. if (ssl->s3->send_shutdown != ssl_shutdown_none) {
  395. OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN);
  396. return -1;
  397. }
  398. if (level == SSL3_AL_FATAL) {
  399. ssl->s3->send_shutdown = ssl_shutdown_fatal_alert;
  400. } else if (level == SSL3_AL_WARNING && desc == SSL_AD_CLOSE_NOTIFY) {
  401. ssl->s3->send_shutdown = ssl_shutdown_close_notify;
  402. }
  403. ssl->s3->alert_dispatch = 1;
  404. ssl->s3->send_alert[0] = level;
  405. ssl->s3->send_alert[1] = desc;
  406. if (!ssl_write_buffer_is_pending(ssl)) {
  407. /* Nothing is being written out, so the alert may be dispatched
  408. * immediately. */
  409. return ssl->method->dispatch_alert(ssl);
  410. }
  411. /* The alert will be dispatched later. */
  412. return -1;
  413. }
  414. int ssl3_dispatch_alert(SSL *ssl) {
  415. ssl->s3->alert_dispatch = 0;
  416. int ret = do_ssl3_write(ssl, SSL3_RT_ALERT, &ssl->s3->send_alert[0], 2);
  417. if (ret <= 0) {
  418. ssl->s3->alert_dispatch = 1;
  419. return ret;
  420. }
  421. /* If the alert is fatal, flush the BIO now. */
  422. if (ssl->s3->send_alert[0] == SSL3_AL_FATAL) {
  423. BIO_flush(ssl->wbio);
  424. }
  425. ssl_do_msg_callback(ssl, 1 /* write */, SSL3_RT_ALERT, ssl->s3->send_alert,
  426. 2);
  427. int alert = (ssl->s3->send_alert[0] << 8) | ssl->s3->send_alert[1];
  428. ssl_do_info_callback(ssl, SSL_CB_WRITE_ALERT, alert);
  429. return 1;
  430. }