Преглед изворни кода

Support (D)TLS1.3 downgrade when using PSK

DTLS Server:
examples/server/server -v3 -u -s

DTLS Client:
examples/client/client -vd -g -u -s

TLS Server:
examples/server/server -v3 -s

TLS Client:
examples/client/client -vd -g -s

Support checking for DTLS1.2 Hello Verify Request when using PSK.

Unset options.tls1_3 when handling a DTLS1.2 Hello Verify Request.

Unset options.tls1_3 when handling a (D)TLS1.2 Server Hello to stop
checking of Encrypted Client Hello

Requires ./configure --enable-all --enable-dtls13

Add in tests for DTLS1.3 and TLS1.3 downgrade when using PSK.
Jon Shallow пре 2 месеци
родитељ
комит
a0f3933881
5 измењених фајлова са 34 додато и 2 уклоњено
  1. 3 0
      src/internal.c
  2. 2 1
      src/tls.c
  3. 5 1
      src/tls13.c
  4. 13 0
      tests/test-dtls13-downgrade.conf
  5. 11 0
      tests/test-tls13-down.conf

+ 3 - 0
src/internal.c

@@ -28818,6 +28818,9 @@ static int HashSkeData(WOLFSSL* ssl, enum wc_HashType hashType,
             if (!ssl->options.downgrade ||
                     ssl->options.minDowngrade <= DTLSv1_3_MINOR)
                 return VERSION_ERROR;
+
+            /* Cannot be DTLS1.3 as HELLO_VERIFY_REQUEST */
+            ssl->options.tls1_3 = 0;
         }
 #endif /* defined(WOLFSSL_DTLS13) && defined(WOLFSSL_TLS13) */
 

+ 2 - 1
src/tls.c

@@ -14914,7 +14914,8 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
     }
 
 #ifdef HAVE_EXTENDED_MASTER
-    if (IsAtLeastTLSv1_3(ssl->version) && msgType == hello_retry_request) {
+    if (IsAtLeastTLSv1_3(ssl->version) &&
+        (msgType == hello_retry_request || msgType == hello_verify_request)) {
         /* Don't change EMS status until server_hello received.
          * Second ClientHello must have same extensions.
          */

+ 5 - 1
src/tls13.c

@@ -5285,6 +5285,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
             }
 
             ssl->version.minor = args->pv.minor;
+            ssl->options.tls1_3 = 0;
 
 #ifdef WOLFSSL_DTLS13
             if (ssl->options.dtls) {
@@ -5386,7 +5387,10 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
         }
 
         /* Force client hello version 1.2 to work for static RSA. */
-        ssl->chVersion.minor = TLSv1_2_MINOR;
+        if (ssl->options.dtls)
+            ssl->chVersion.minor = DTLSv1_2_MINOR;
+        else
+            ssl->chVersion.minor = TLSv1_2_MINOR;
         /* Complete TLS v1.2 processing of ServerHello. */
         ret = CompleteServerHello(ssl);
 #else

+ 13 - 0
tests/test-dtls13-downgrade.conf

@@ -41,3 +41,16 @@
 -7 2
 -u
 -l TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
+
+# server DTLSv1.2 - PSK
+-v 3
+-u
+-s
+-l ECDHE-PSK-AES128-GCM-SHA256
+
+# client DTLS PSK multiversion, allow downgrade
+-vd
+-7 2
+-u
+-s
+-l ECDHE-PSK-AES128-GCM-SHA256

+ 11 - 0
tests/test-tls13-down.conf

@@ -108,3 +108,14 @@
 # client TLSv 1.2
 -v 3
 -H exitWithRet
+
+# server TLSv1.2 - PSK
+-v 3
+-s
+-l ECDHE-PSK-AES128-GCM-SHA256
+
+# client TLS PSK multiversion, allow downgrade
+-v d
+-7 3
+-s
+-l ECDHE-PSK-AES128-GCM-SHA256