Skip to content

Commit

Permalink
Add additional IgnoreHandshakeMessageAsync restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
Metalnem committed May 17, 2018
1 parent e3a3689 commit e97a3ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions NoiseSocket/NoiseSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,17 @@ public async Task IgnoreHandshakeMessageAsync(CancellationToken cancellationToke
throw new InvalidOperationException(error);
}

if (client && (savedMessages == null || savedMessages.Count != 3))
{
string error = $"Client can ignore only the initial handshake message from the server in the Retry case.";
throw new InvalidOperationException(error);
}

if (!client && (savedMessages == null || savedMessages.Count != 1))
{
throw new InvalidOperationException($"Server can ignore only the initial handshake message from the client.");
}

var noiseMessage = await ReadPacketAsync(stream, cancellationToken).ConfigureAwait(false);
ProcessMessage(HandshakeOperation.ReadHandshakeMessage, noiseMessage, false);
}
Expand Down

0 comments on commit e97a3ed

Please sign in to comment.