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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final longin SECONDSstatic final int64static final intstatic final int48static final intstatic final intstatic final intone less than 288 byte NTCP1 msg 1static final byte[] -
Constructor Summary
ConstructorsConstructorDescriptionOutboundNTCP2State(RouterContext ctx, NTCPTransport transport, NTCPConnection con) -
Method Summary
Modifier and TypeMethodDescriptionvoidRelease resources on timeout.protected voidprotected voidprotected void(package private) static byte[][]generateSipHashKeys(RouterContext ctx, HandshakeState state) KDF for SipHashintGet the NTCP versionbooleanDon't synchronize this, deadlocks all over.booleandid the handshake fail for some reason?voidWe are Alice.voidreceive(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:
receivein interfaceEstablishState
-
isCorrupt
public boolean isCorrupt()did the handshake fail for some reason?- Specified by:
isCorruptin interfaceEstablishState
-
isComplete
public boolean isComplete()Don't synchronize this, deadlocks all over.- Specified by:
isCompletein interfaceEstablishState- Returns:
- is the handshake complete and valid?
-
getVersion
public int getVersion()Get the NTCP version- Specified by:
getVersionin 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:
prepareOutboundin 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:
closein interfaceEstablishState- Parameters:
e- may be null- Since:
- 0.9.16
-
fail
-
fail
-
fail
-
toString
-