Exemplo n.º 1
0
        private void MeasureHandshakeMessage(NetworkIncomingMessage message)
        {
            HandshakeKey           decryptor = keys.Remote.Clone();
            NetworkIncomingMessage decrypted = decryptor.Decrypt(message);

            int size = HandshakeMessage.GetSize(decrypted);

            connection.Receive(HandleHandshakeMessage, size);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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 void Decrypt(byte[] data, int offset, int count)
 {
     key.Decrypt(data, offset, count);
 }