提交 b9ef52b0 编写于 作者: R Robin Seggelmann 提交者: Dr. Stephen Henson

DTLS/SCTP Finished Auth Bug

PR: 2808

With DTLS/SCTP the SCTP extension SCTP-AUTH is used to protect DATA and
FORWARD-TSN chunks. The key for this extension is derived from the
master secret and changed with the next ChangeCipherSpec, whenever a new
key has been negotiated. The following Finished then already uses the
new key.  Unfortunately, the ChangeCipherSpec and Finished are part of
the same flight as the ClientKeyExchange, which is necessary for the
computation of the new secret. Hence, these messages are sent
immediately following each other, leaving the server very little time to
compute the new secret and pass it to SCTP before the finished arrives.
So the Finished is likely to be discarded by SCTP and a retransmission
becomes necessary. To prevent this issue, the Finished of the client is
still sent with the old key.
(cherry picked from commit 9fb523adce6fd6015b68da2ca8e4ac4900ac2be2)
上级 29b490a4
...@@ -556,13 +556,6 @@ int dtls1_connect(SSL *s) ...@@ -556,13 +556,6 @@ int dtls1_connect(SSL *s)
SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B); SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);
if (ret <= 0) goto end; if (ret <= 0) goto end;
#ifndef OPENSSL_NO_SCTP
/* Change to new shared key of SCTP-Auth,
* will be ignored if no SCTP used.
*/
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
#endif
s->state=SSL3_ST_CW_FINISHED_A; s->state=SSL3_ST_CW_FINISHED_A;
s->init_num=0; s->init_num=0;
...@@ -589,6 +582,16 @@ int dtls1_connect(SSL *s) ...@@ -589,6 +582,16 @@ int dtls1_connect(SSL *s)
goto end; goto end;
} }
#ifndef OPENSSL_NO_SCTP
if (s->hit)
{
/* Change to new shared key of SCTP-Auth,
* will be ignored if no SCTP used.
*/
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
}
#endif
dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); dtls1_reset_seq_numbers(s, SSL3_CC_WRITE);
break; break;
...@@ -631,6 +634,13 @@ int dtls1_connect(SSL *s) ...@@ -631,6 +634,13 @@ int dtls1_connect(SSL *s)
} }
else else
{ {
#ifndef OPENSSL_NO_SCTP
/* Change to new shared key of SCTP-Auth,
* will be ignored if no SCTP used.
*/
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
#endif
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
/* Allow NewSessionTicket if ticket expected */ /* Allow NewSessionTicket if ticket expected */
if (s->tlsext_ticket_expected) if (s->tlsext_ticket_expected)
......
...@@ -758,10 +758,13 @@ int dtls1_accept(SSL *s) ...@@ -758,10 +758,13 @@ int dtls1_accept(SSL *s)
if (ret <= 0) goto end; if (ret <= 0) goto end;
#ifndef OPENSSL_NO_SCTP #ifndef OPENSSL_NO_SCTP
/* Change to new shared key of SCTP-Auth, if (!s->hit)
* will be ignored if no SCTP used. {
*/ /* Change to new shared key of SCTP-Auth,
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); * will be ignored if no SCTP used.
*/
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
}
#endif #endif
s->state=SSL3_ST_SW_FINISHED_A; s->state=SSL3_ST_SW_FINISHED_A;
...@@ -786,7 +789,16 @@ int dtls1_accept(SSL *s) ...@@ -786,7 +789,16 @@ int dtls1_accept(SSL *s)
if (ret <= 0) goto end; if (ret <= 0) goto end;
s->state=SSL3_ST_SW_FLUSH; s->state=SSL3_ST_SW_FLUSH;
if (s->hit) if (s->hit)
{
s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A; s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A;
#ifndef OPENSSL_NO_SCTP
/* Change to new shared key of SCTP-Auth,
* will be ignored if no SCTP used.
*/
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL);
#endif
}
else else
{ {
s->s3->tmp.next_state=SSL_ST_OK; s->s3->tmp.next_state=SSL_ST_OK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册