private void MeasureHandshakeMessage(NetworkIncomingMessage message) { HandshakeKey decryptor = keys.Remote.Clone(); NetworkIncomingMessage decrypted = decryptor.Decrypt(message); int size = HandshakeMessage.GetSize(decrypted); connection.Receive(HandleHandshakeMessage, size); }
private bool VerifyCryptoMessage(NetworkIncomingMessage message) { HandshakeKey decryptor = keys.Remote.Clone(); byte[] synchronize = HandshakeCryptoPayload.GetVerification(); byte[] encrypted = decryptor.Decrypt(synchronize); int offset = Bytes.Find(message.ToBytes(), encrypted); return(offset >= 0 && message.Length >= offset + HandshakeCryptoPayload.MinimumSize); }
private void HandleCryptoMessage(NetworkIncomingMessage message) { HandshakeKey decryptor = keys.Remote.Clone(); NetworkIncomingMessage decrypted = decryptor.Decrypt(message); int size = HandshakeCryptoPayload.GetSize(decrypted); message.Acknowledge(size); keys.Remote.Acknowledge(size); connection.Send(new HandshakeMessage(context.Peer, context.Hash, context.Options), keys.Local); connection.Receive(MeasureHandshakeMessage, HandshakeMessage.MinSize); }
private void SynchronizeCryptoMessage(NetworkIncomingMessage message) { HandshakeKey decryptor = keys.Remote.Clone(); byte[] synchronize = HandshakeCryptoPayload.GetVerification(); byte[] encrypted = decryptor.Encrypt(synchronize, 0, synchronize.Length); int offset = Bytes.Find(message.ToBytes(), encrypted); message.Acknowledge(offset); connection.Receive(MeasureCryptoMessage, HandshakeCryptoPayload.MinimumSize); }
private void HandleCryptoPayloadMessage(NetworkIncomingMessage message) { HandshakeKey decryptor = keys.Remote.Clone(); NetworkIncomingMessage decrypted = decryptor.Decrypt(message); int size = HandshakeCryptoPayload.GetSize(decrypted); int method = HandshakeCryptoPayload.GetMethod(decrypted); message.Acknowledge(size); keys.Remote.Acknowledge(size); connection.Receive(MeasureCryptoMessage, HandshakeCryptoMessage.MinimumSize, method); }
private void HandleHandshakeMessage(NetworkIncomingMessage message) { HandshakeKey decryptor = keys.Remote.Clone(); NetworkIncomingMessage decrypted = decryptor.Decrypt(message); int size = HandshakeMessage.GetSize(decrypted); PeerHash peer = HandshakeMessage.GetPeer(decrypted); HandshakeOptions options = HandshakeMessage.GetOptions(decrypted); Handshake handshake = new Handshake(context.Peer, peer, context.Hash, options); message.Acknowledge(size); keys.Remote.Acknowledge(size); NetworkConnection other = connection.StartEncryption(keys); hooks.CallHandshakeCompleted(other, handshake); context.OnHandshake(other, handshake); }
public HandshakeConnectionToEncryptor(HandshakeKey key) { this.key = key; }
public HandshakeConnectionEncryptedMessage(NetworkOutgoingMessage inner, HandshakeKey key) { this.inner = inner; this.key = key; }
public void Send(NetworkOutgoingMessage message, HandshakeKey key) { connection.Send(new HandshakeConnectionEncryptedMessage(message, key)); }
public HandshakeKeyScope(HandshakeKey key) { this.key = key; }