Package net.i2p.router.transport.ntcp
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 Summary
Fields Modifier and Type Field Description static int
IV_SIZE
static int
KEY_SIZE
static int
MAC_SIZE
static long
MAX_SKEW
in SECONDSstatic int
MSG1_SIZE
64static int
MSG2_SIZE
static int
MSG3P1_SIZE
48static int
OPTIONS1_SIZE
static int
OPTIONS2_SIZE
static int
TOTAL1_MAX
one less than 288 byte NTCP1 msg 1static byte[]
ZEROKEY
-
Constructor Summary
Constructors Constructor Description OutboundNTCP2State(RouterContext ctx, NTCPTransport transport, NTCPConnection con)
-
Method Summary
Modifier and Type Method Description void
close(String reason, Exception e)
Release resources on timeout.protected void
fail(String reason)
protected void
fail(String reason, Exception e)
protected void
fail(String reason, Exception e, boolean bySkew)
(package private) static byte[][]
generateSipHashKeys(RouterContext ctx, HandshakeState state)
KDF for SipHashint
getVersion()
Get the NTCP versionboolean
isComplete()
Don't synchronize this, deadlocks all over.boolean
isCorrupt()
did the handshake fail for some reason?void
prepareOutbound()
We are Alice.void
receive(ByteBuffer src)
Parse the contents of the buffer as part of the handshake.String
toString()
-
Field Details
-
KEY_SIZE
public static final int KEY_SIZE- See Also:
- Constant Field Values
-
MAC_SIZE
public static final int MAC_SIZE- See Also:
- Constant Field Values
-
IV_SIZE
public static final int IV_SIZE- See Also:
- Constant Field Values
-
OPTIONS1_SIZE
public static final int OPTIONS1_SIZE- See Also:
- Constant Field Values
-
MSG1_SIZE
public static final int MSG1_SIZE64- See Also:
- Constant Field Values
-
TOTAL1_MAX
public static final int TOTAL1_MAXone less than 288 byte NTCP1 msg 1- See Also:
- Constant Field Values
-
OPTIONS2_SIZE
public static final int OPTIONS2_SIZE- See Also:
- Constant Field Values
-
MSG2_SIZE
public static final int MSG2_SIZE- See Also:
- Constant Field Values
-
MSG3P1_SIZE
public static final int MSG3P1_SIZE48- See Also:
- Constant Field Values
-
MAX_SKEW
public static final long MAX_SKEWin SECONDS- See Also:
- Constant Field Values
-
ZEROKEY
public static final byte[] ZEROKEY
-
-
Constructor Details
-
OutboundNTCP2State
- Throws:
IllegalArgumentException
- on bad address in the con
-
-
Method Details
-
receive
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 interfaceEstablishState
-
isCorrupt
public boolean isCorrupt()did the handshake fail for some reason?- Specified by:
isCorrupt
in interfaceEstablishState
-
isComplete
public boolean isComplete()Don't synchronize this, deadlocks all over.- Specified by:
isComplete
in interfaceEstablishState
- Returns:
- is the handshake complete and valid?
-
getVersion
public int getVersion()Get the NTCP version- Specified by:
getVersion
in interfaceEstablishState
- 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 interfaceEstablishState
- Throws:
IllegalStateException
-
generateSipHashKeys
KDF for SipHash- Returns:
- rv[0] is sip_ab, rv[1] is sip_ba
-
close
Release resources on timeout.- Specified by:
close
in interfaceEstablishState
- Parameters:
e
- may be null- Since:
- 0.9.16
-
fail
-
fail
-
fail
-
toString
-