From: Matthew Endsley Date: Fri, 2 Apr 2021 01:10:37 +0000 (-0700) Subject: Do not generate ClientRandom on ClientHello resend X-Git-Tag: 1.0.0~9^2 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=105f4b72e29eb999e3bbee5d1e6c2732f9d1e36f;p=rhonda%2Fimpostor.hazel.git Do not generate ClientRandom on ClientHello resend 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. --- diff --git a/Hazel/Dtls/DtlsUnityConnection.cs b/Hazel/Dtls/DtlsUnityConnection.cs index 0c09e3d..eed6ba7 100644 --- a/Hazel/Dtls/DtlsUnityConnection.cs +++ b/Hazel/Dtls/DtlsUnityConnection.cs @@ -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();