From 105f4b72e29eb999e3bbee5d1e6c2732f9d1e36f Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Thu, 1 Apr 2021 18:10:37 -0700 Subject: [PATCH] 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. --- Hazel/Dtls/DtlsUnityConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(); -- 2.39.5