]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Do not generate ClientRandom on ClientHello resend
authorMatthew Endsley <mendsley@gmail.com>
Fri, 2 Apr 2021 01:10:37 +0000 (18:10 -0700)
committerMatthew Endsley <mendsley@gmail.com>
Fri, 2 Apr 2021 01:12:29 +0000 (18:12 -0700)
This buffer should only be generated at the start of the session.
Re-generating it on resend of ClientHello will desynchronize the session
between the client and server, resulting in the server refusing the
client's connection due to a hash mismatch in the Finished handshake
message.

Hazel/Dtls/DtlsUnityConnection.cs

index 0c09e3d0e599f6021bf5ccc2fe633e031e552260..eed6ba7ec6136287575e5aca94ca937bf0ab63d3 100644 (file)
@@ -199,6 +199,7 @@ namespace Hazel.Dtls
             lock (this.syncRoot)
             {
                 this.ResetConnectionState();
+                this.nextEpoch.ClientRandom.FillWithRandom(this.random);
                 this.SendClientHello();
             }
 
@@ -577,6 +578,7 @@ namespace Hazel.Dtls
                         helloVerifyRequest.Cookie.CopyTo(this.nextEpoch.Cookie);
 
                         // Restart the handshake
+                        this.nextEpoch.ClientRandom.FillWithRandom(this.random);
                         this.SendClientHello();
                         break;
 
@@ -882,7 +884,6 @@ namespace Hazel.Dtls
         {
             // Reset our verification stream
             this.nextEpoch.VerificationStream.SetLength(0);
-            this.nextEpoch.ClientRandom.FillWithRandom(this.random);
 
             // Describe our ClientHello flight
             ClientHello clientHello = new ClientHello();