From 0557bd5fa4bee08f06487300cf99c426daed1773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 19 Aug 2014 19:18:39 +0200 Subject: [PATCH] Fix message_seq with server-initiated renego --- library/ssl_tls.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 9ae336a722..af5e390ad1 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -4550,6 +4550,17 @@ static int ssl_start_renegotiation( ssl_context *ssl ) if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) return( ret ); + /* RFC 6347 4.2.2: "[...] the HelloRequest will have message_seq = 0 and + * the ServerHello will have message_seq = 1" */ +#if defined(POLARSSL_SSL_PROTO_DTLS) + if( ssl->transport == SSL_TRANSPORT_DATAGRAM && + ssl->endpoint == SSL_IS_SERVER && + ssl->renegotiation == SSL_RENEGOTIATION_PENDING ) + { + ssl->handshake->msg_seq = 1; + } +#endif + ssl->state = SSL_HELLO_REQUEST; ssl->renegotiation = SSL_RENEGOTIATION;