コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
 public HandshakeConnectionToEncryptor(HandshakeKey key)
 {
     this.key = key;
 }
コード例 #8
0
 public HandshakeConnectionEncryptedMessage(NetworkOutgoingMessage inner, HandshakeKey key)
 {
     this.inner = inner;
     this.key   = key;
 }
コード例 #9
0
 public void Send(NetworkOutgoingMessage message, HandshakeKey key)
 {
     connection.Send(new HandshakeConnectionEncryptedMessage(message, key));
 }
コード例 #10
0
 public HandshakeKeyScope(HandshakeKey key)
 {
     this.key = key;
 }