提交 f74a0c0c 编写于 作者: D Dr. Stephen Henson

PR: 2458

Submitted by: Robin Seggelmann <seggelmann@fh-muenster.de>
Reviewed by: steve

Don't change state when answering DTLS ClientHello.
上级 6e28b60a
...@@ -464,7 +464,10 @@ again: ...@@ -464,7 +464,10 @@ again:
memset(msg_hdr, 0x00, sizeof(struct hm_header_st)); memset(msg_hdr, 0x00, sizeof(struct hm_header_st));
/* Don't change sequence numbers while listening */
if (!s->d1->listen)
s->d1->handshake_read_seq++; s->d1->handshake_read_seq++;
/* we just read a handshake message from the other side: /* we just read a handshake message from the other side:
* this means that we don't need to retransmit of the * this means that we don't need to retransmit of the
* buffered messages. * buffered messages.
...@@ -814,8 +817,10 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) ...@@ -814,8 +817,10 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
/* /*
* if this is a future (or stale) message it gets buffered * if this is a future (or stale) message it gets buffered
* (or dropped)--no further processing at this time * (or dropped)--no further processing at this time
* While listening, we accept seq 1 (ClientHello with cookie)
* although we're still expecting seq 0 (ClientHello)
*/ */
if ( msg_hdr.seq != s->d1->handshake_read_seq) if (msg_hdr.seq != s->d1->handshake_read_seq && !(s->d1->listen && msg_hdr.seq == 1))
return dtls1_process_out_of_seq_message(s, &msg_hdr, ok); return dtls1_process_out_of_seq_message(s, &msg_hdr, ok);
len = msg_hdr.msg_len; len = msg_hdr.msg_len;
...@@ -1322,7 +1327,8 @@ unsigned char * ...@@ -1322,7 +1327,8 @@ unsigned char *
dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt, dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt,
unsigned long len, unsigned long frag_off, unsigned long frag_len) unsigned long len, unsigned long frag_off, unsigned long frag_len)
{ {
if ( frag_off == 0) /* Don't change sequence numbers while listening */
if (frag_off == 0 && !s->d1->listen)
{ {
s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; s->d1->handshake_write_seq = s->d1->next_handshake_write_seq;
s->d1->next_handshake_write_seq++; s->d1->next_handshake_write_seq++;
......
...@@ -278,6 +278,12 @@ int dtls1_accept(SSL *s) ...@@ -278,6 +278,12 @@ int dtls1_accept(SSL *s)
{ {
ret = 2; ret = 2;
s->d1->listen = 0; s->d1->listen = 0;
/* Set expected sequence numbers
* to continue the handshake.
*/
s->d1->handshake_read_seq = 2;
s->d1->handshake_write_seq = 1;
s->d1->next_handshake_write_seq = 1;
goto end; goto end;
} }
...@@ -737,9 +743,6 @@ int dtls1_send_hello_verify_request(SSL *s) ...@@ -737,9 +743,6 @@ int dtls1_send_hello_verify_request(SSL *s)
/* number of bytes to write */ /* number of bytes to write */
s->init_num=p-buf; s->init_num=p-buf;
s->init_off=0; s->init_off=0;
/* buffer the message to handle re-xmits */
dtls1_buffer_message(s, 0);
} }
/* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */ /* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册