Пример #1
0
        public override SSUState HandleMessage(SSUHeader header, BufRefLen reader)
        {
            if (header.MessageType == SSUHeader.MessageTypes.SessionCreated)
            {
                Logging.LogTransport($"SSU SessionConfirmedState {Session.DebugId}: Unexpected message received: {header.MessageType}");
                return(this);
            }

            Logging.LogTransport($"SSU SessionConfirmedState: Session {Session.DebugId} established. " +
                                 $"{header.MessageType} received. Moving to Established state.");

            var next = new EstablishedState(Session);

            Session.ReportConnectionEstablished();

            return(next.HandleMessage(header, reader));
        }
Пример #2
0
        private SSUState VerifyRemoteSignature()
        {
            var baaddr = new BufLen(AAddr);
            var bbport = BufUtils.Flip16BL((ushort)Session.MyRouterContext.UDPPort);

#if LOG_MUCH_TRANSPORT
            Logging.LogTransport($"SSU {this}: X for signature {Request.X}.");
            Logging.LogTransport($"SSU {this}: Y for signature {Y.Key}.");
            Logging.LogTransport($"SSU {this}: Alice address for signature {baaddr}. Port {(BufLen)APort}.");
            Logging.LogTransport($"SSU {this}: Bob address for signature {Request.Address}. Port {bbport}.");
            Logging.LogTransport($"SSU {this}: Relay tag {(BufLen)RelayTag}. Signon time {(BufLen)ASignonTime}.");
#endif

            var signdata = new BufLen[] {
                Request.X, Y.Key,
                baaddr, BufUtils.To16BL(APort),
                Request.Address, bbport,
                BufUtils.To32BL(RelayTag), BufUtils.To32BL(ASignonTime)
            };

            var ok = I2PSignature.DoVerify(Session.RemoteRouter.SigningPublicKey, ASign, signdata);

            Logging.LogTransport($"SSU SessionCreatedState {Session.DebugId}: " +
                                 $"{Session.RemoteRouter.Certificate.SignatureType} " +
                                 $"signature check: {ok}");

            if (!ok)
            {
                throw new SignatureCheckFailureException("SSU SessionCreatedState recv sig check failure");
            }

            Logging.LogTransport("SSU SessionCreatedState: Session " + Session.DebugId + " established. Moving to Established state.");
            var next = new EstablishedState(Session);

            Session.ReportConnectionEstablished();

            NetDb.Inst.Statistics.SuccessfulConnect(Session.RemoteRouter.IdentHash);
            return(next);
        }