protected override void HandleClientHelloRequest(ClientHelloRequest packet, MessageOrigin origin) { if (!clientRandoms.ContainsKey(origin.endPoint)) { clientRandoms[origin.endPoint] = packet.random; } var random = PacketEncryptionLayer.GenerateRandom(32); SendUnreliableResponse(1u, origin.endPoint, packet, HelloVerifyRequest.pool.Obtain().Init(random)); packet.Release(); }
protected override async void HandleClientHelloWithCookieRequest(ClientHelloWithCookieRequest packet, MessageOrigin origin) { var fakeSignature = PacketEncryptionLayer.GenerateRandom(128); if (!serverRandoms.ContainsKey(origin.endPoint)) { serverRandoms[origin.endPoint] = PacketEncryptionLayer.GenerateRandom(32); } if (!serverKeys.ContainsKey(origin.endPoint)) { serverKeys[origin.endPoint] = await _keysTask; } SendReliableResponse(1u, origin.endPoint, packet, ServerHelloRequest.pool.Obtain().Init(serverRandoms[origin.endPoint], serverKeys[origin.endPoint].publicKey, fakeSignature)); SendReliableResponse(1u, origin.endPoint, packet.certificateResponseId, ServerCertificateRequest.pool.Obtain().Init(new List <byte[]> { serverRandoms[origin.endPoint] })); packet.Release(); }