Class OutboundNTCP2State

java.lang.Object
net.i2p.router.transport.ntcp.OutboundNTCP2State
All Implemented Interfaces:
EstablishState

class OutboundNTCP2State extends Object implements EstablishState
NTCP 2 only. We are Alice. Also contains static constants and methods used by InboundEstablishState for NTCP2. Does not extend EstablishBase.
Since:
0.9.35
  • Field Details

  • Constructor Details

  • Method Details

    • receive

      public void receive(ByteBuffer src)
      Parse the contents of the buffer as part of the handshake. All data must be copied out of the buffer as Reader.processRead() will return it to the pool.
      Specified by:
      receive in interface EstablishState
    • isCorrupt

      public boolean isCorrupt()
      did the handshake fail for some reason?
      Specified by:
      isCorrupt in interface EstablishState
    • isComplete

      public boolean isComplete()
      Don't synchronize this, deadlocks all over.
      Specified by:
      isComplete in interface EstablishState
      Returns:
      is the handshake complete and valid?
    • getVersion

      public int getVersion()
      Get the NTCP version
      Specified by:
      getVersion in interface EstablishState
      Returns:
      2
    • prepareOutbound

      public void prepareOutbound()
      We are Alice. We are establishing an outbound connection, so prepare ourselves by writing the first message in the handshake. Encrypt X and write X, the options block, and the padding. Save last half of encrypted X as IV for message 2 AES.
      Specified by:
      prepareOutbound in interface EstablishState
      Throws:
      IllegalStateException
    • generateSipHashKeys

      static byte[][] generateSipHashKeys(RouterContext ctx, HandshakeState state)
      KDF for SipHash
      Returns:
      rv[0] is sip_ab, rv[1] is sip_ba
    • close

      public void close(String reason, Exception e)
      Release resources on timeout.
      Specified by:
      close in interface EstablishState
      Parameters:
      e - may be null
      Since:
      0.9.16
    • fail

      protected void fail(String reason)
    • fail

      protected void fail(String reason, Exception e)
    • fail

      protected void fail(String reason, Exception e, boolean bySkew)
    • toString

      public String toString()
      Overrides:
      toString in class Object