From 3cc473b1ec47a771d1deca85b48155d4dffb81fd Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Fri, 18 Aug 2023 15:14:51 +0200 Subject: [PATCH] Check that HVR and HRR don't appear in the same connection --- src/internal.c | 6 ++++++ src/tls13.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/internal.c b/src/internal.c index b4593d496..b3a8408b2 100644 --- a/src/internal.c +++ b/src/internal.c @@ -15682,6 +15682,12 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type) WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E); return DUPLICATE_MSG_E; } + if (ssl->msgsReceived.got_hello_retry_request) { + WOLFSSL_MSG("Received HelloVerifyRequest after a " + "HelloRetryRequest"); + WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); + return VERSION_ERROR; + } ssl->msgsReceived.got_hello_verify_request = 1; break; diff --git a/src/tls13.c b/src/tls13.c index 19898edff..5a55c65e1 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -5024,6 +5024,13 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, WOLFSSL_MSG("HelloRetryRequest format"); *extMsgType = hello_retry_request; + if (ssl->msgsReceived.got_hello_verify_request) { + WOLFSSL_MSG("Received HelloRetryRequest after a " + "HelloVerifyRequest"); + WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); + return VERSION_ERROR; + } + /* A HelloRetryRequest comes in as an ServerHello for MiddleBox compat. * Found message to be a HelloRetryRequest. * Don't allow more than one HelloRetryRequest or ServerHello.