Class InboundEstablishState2

    • Constructor Detail

      • InboundEstablishState2

        public InboundEstablishState2​(RouterContext ctx,
                                      UDPTransport transport,
                                      UDPPacket packet)
                               throws GeneralSecurityException
        Start a new handshake with the given incoming packet, which must be a Session Request or Token Request. Caller must then check getState() and build a Retry or Session Created in response.
        Parameters:
        packet - with all header encryption removed, either a SessionRequest OR a TokenRequest.
        Throws:
        GeneralSecurityException
    • Method Detail

      • gotOptions

        public void gotOptions​(byte[] options,
                               boolean isHandshake)
        Specified by:
        gotOptions in interface SSU2Payload.PayloadCallback
        isHandshake - true only for message 3 part 2
      • gotRI

        public void gotRI​(RouterInfo ri,
                          boolean isHandshake,
                          boolean flood)
                   throws DataFormatException
        For most errors here we throw a RIException with a reason code, which is caught in processPayload() to create a PeerStateDestroyed and send a termination with that reason. Plain DataFormatExceptions indicate you may not respond in-session.
        Specified by:
        gotRI in interface SSU2Payload.PayloadCallback
        Parameters:
        ri - will already be validated
        isHandshake - true only for message 3 part 2
        Throws:
        DataFormatException
      • gotRIFragment

        public void gotRIFragment​(byte[] data,
                                  boolean isHandshake,
                                  boolean flood,
                                  boolean isGzipped,
                                  int frag,
                                  int totalFrags)
        Specified by:
        gotRIFragment in interface SSU2Payload.PayloadCallback
        Parameters:
        data - is first gzipped and then fragmented
        isHandshake - true only for message 3 part 2
      • gotRelayResponse

        public void gotRelayResponse​(int status,
                                     byte[] data)
        Specified by:
        gotRelayResponse in interface SSU2Payload.PayloadCallback
        Parameters:
        status - 0 = accept, 1-255 = reject
        data - excludes flag, includes signature
      • gotPeerTest

        public void gotPeerTest​(int msg,
                                int status,
                                Hash h,
                                byte[] data)
        Specified by:
        gotPeerTest in interface SSU2Payload.PayloadCallback
        Parameters:
        msg - 1-7
        status - 0 = accept, 1-255 = reject
        h - Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7
        data - excludes flag, includes signature
      • gotTermination

        public void gotTermination​(int reason,
                                   long count)
        Specified by:
        gotTermination in interface SSU2Payload.PayloadCallback
        count - in theory could wrap around to negative, but very unlikely
      • fail

        public void fail()
        Overridden to destroy the handshake state
        Overrides:
        fail in class InboundEstablishState
        Since:
        0.9.56
      • getSendConnID

        public long getSendConnID()
      • getRcvConnID

        public long getRcvConnID()
      • getToken

        public long getToken()
      • getSendHeaderEncryptKey1

        public byte[] getSendHeaderEncryptKey1()
      • getRcvHeaderEncryptKey1

        public byte[] getRcvHeaderEncryptKey1()
      • getSendHeaderEncryptKey2

        public byte[] getSendHeaderEncryptKey2()
      • getRcvHeaderEncryptKey2

        public byte[] getRcvHeaderEncryptKey2()
      • retryPacketSent

        public void retryPacketSent()
        note that we just sent a Retry packet
      • receiveSessionConfirmed

        public PeerState2 receiveSessionConfirmed​(UDPPacket packet)
                                           throws GeneralSecurityException
        Receive the last messages in the handshake, and create the PeerState. If the message is fragmented, store the data for reassembly and return, unless this was the last one. Exceptions thrown from here are fatal.
        Returns:
        the new PeerState2 if are done, may also be retrieved from getPeerState(), or null if more fragments to go
        Throws:
        GeneralSecurityException
      • createdPacketSent

        public void createdPacketSent​(DatagramPacket pkt)
        note that we just sent the SessionCreated packet and save it for retransmission
      • getRetransmitSessionCreatedPacket

        public UDPPacket getRetransmitSessionCreatedPacket()
        Returns:
        null if not sent or already got the session confirmed
      • getPeerState

        public PeerState2 getPeerState()
        Returns:
        null if we have not received the session confirmed
      • queuePossibleDataPacket

        public void queuePossibleDataPacket​(UDPPacket packet)
        Parameters:
        packet - with header still encrypted