Package net.i2p.router.transport.ntcp
Class OutboundNTCP2State
java.lang.Object
net.i2p.router.transport.ntcp.OutboundNTCP2State
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final long
in SECONDSstatic final int
64static final int
static final int
48static final int
static final int
static final int
one less than 288 byte NTCP1 msg 1static final byte[]
-
Constructor Summary
ConstructorDescriptionOutboundNTCP2State
(RouterContext ctx, NTCPTransport transport, NTCPConnection con) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Release resources on timeout.protected void
protected void
protected void
(package private) static byte[][]
generateSipHashKeys
(RouterContext ctx, HandshakeState state) KDF for SipHashint
Get the NTCP versionboolean
Don't synchronize this, deadlocks all over.boolean
did the handshake fail for some reason?void
We are Alice.void
receive
(ByteBuffer src) Parse the contents of the buffer as part of the handshake.toString()
-
Field Details
-
KEY_SIZE
public static final int KEY_SIZE- See Also:
-
MAC_SIZE
public static final int MAC_SIZE- See Also:
-
IV_SIZE
public static final int IV_SIZE- See Also:
-
OPTIONS1_SIZE
public static final int OPTIONS1_SIZE- See Also:
-
MSG1_SIZE
public static final int MSG1_SIZE64- See Also:
-
TOTAL1_MAX
public static final int TOTAL1_MAXone less than 288 byte NTCP1 msg 1- See Also:
-
OPTIONS2_SIZE
public static final int OPTIONS2_SIZE- See Also:
-
MSG2_SIZE
public static final int MSG2_SIZE- See Also:
-
MSG3P1_SIZE
public static final int MSG3P1_SIZE48- See Also:
-
MAX_SKEW
public static final long MAX_SKEWin SECONDS- See Also:
-
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
-