This is a common case since all clients send a non-signed ClientHello
message to initiate a new session. There is no need to perform the
hash+hmac for signatures that will always fail verification due to a
mismatched size.
/// <returns>True if the cookie is valid. Otherwise false</returns>
public static bool VerifyCookie(ByteSpan cookie, EndPoint peerAddress, HMAC hmac)
{
+ if (cookie.Length != CookieSize)
+ {
+ return false;
+ }
+
ByteSpan expectedHash = ComputeAddressMac(peerAddress, hmac);
if (expectedHash.Length != cookie.Length)
{