public HandshakeNegotiatorPassive(NetworkPool pool, NetworkConnection connection, HandshakeNegotiatorPassiveContext context, HandshakeNegotiatorHooks hooks)
        {
            this.context = context;
            this.hooks   = hooks;

            this.connection  = new HandshakeConnection(pool, connection, hooks);
            this.credentials = HandshakeCryptography.Generate();
            this.keys        = new HandshakeKeyContainer();
        }
        private void HandleKeyExchangeMessage(NetworkIncomingMessage message)
        {
            HandshakeKeyExchange exchange = new HandshakeKeyExchange(message);

            keys.Secret = HandshakeCryptography.Secret(credentials, exchange.Key);
            message.Acknowledge(96);

            connection.Send(new HandshakeKeyExchangeMessage(credentials));
            connection.Receive(SynchronizeCryptoHashMessage, VerifyCryptoHashMessage);
        }
Exemple #3
0
        private void HandleKeyExchangeMessage(NetworkIncomingMessage message)
        {
            HandshakeKeyExchange exchange = new HandshakeKeyExchange(message);

            keys.Secret = HandshakeCryptography.Secret(credentials, exchange.Key);
            keys.Local  = new HandshakeKey(HandshakeKeyOwnership.Initiator, keys.Secret, context.Hash);
            keys.Remote = new HandshakeKey(HandshakeKeyOwnership.Receiver, keys.Secret, context.Hash);

            message.Acknowledge(96);

            connection.Send(new HandshakeCryptoHashMessage(keys.Secret, context.Hash.ToBytes()));
            connection.Send(new HandshakeCryptoPayloadMessage(2), keys.Local);
            connection.Send(new HandshakeCryptoMessage(), keys.Local);

            connection.Receive(SynchronizeCryptoMessage, VerifyCryptoMessage);
        }