From 0511c8cac8eebdda10607b585a563d3a9310ac0d Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 27 Apr 2016 14:04:47 -0700 Subject: [PATCH] delay check of DTLS handshake message's RH version until the handshake header check --- src/internal.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/internal.c b/src/internal.c index 49fc511ff..31ff1879e 100755 --- a/src/internal.c +++ b/src/internal.c @@ -3982,11 +3982,9 @@ static int GetRecordHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx, ssl->options.downgrade && ssl->options.connectState < FIRST_REPLY_DONE) WOLFSSL_MSG("Server attempting to accept with different version"); - else if (ssl->options.dtls - && (ssl->options.acceptState == ACCEPT_BEGIN - || ssl->options.acceptState == CLIENT_HELLO_SENT)) - /* Do not check version until Server Hello or Hello Again (2) */ - WOLFSSL_MSG("Use version for formatting only in DTLS till "); + else if (ssl->options.dtls && rh->type == handshake) + /* Check the DTLS handshake message RH version later. */ + WOLFSSL_MSG("DTLS handshake, skip RH version number check"); else { WOLFSSL_MSG("SSL version error"); return VERSION_ERROR; /* only use requested version */ @@ -4064,6 +4062,15 @@ static int GetDtlsHandShakeHeader(WOLFSSL* ssl, const byte* input, idx += DTLS_HANDSHAKE_FRAG_SZ; c24to32(input + idx, fragSz); + if (ssl->curRL.pvMajor != ssl->version.major || + ssl->curRL.pvMinor != ssl->version.minor) { + + if (*type != client_hello && *type != hello_verify_request) + return VERSION_ERROR; + else + WOLFSSL_MSG("DTLS Handshake ignoring hello or " + "hello verify version"); + } return 0; } #endif