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 intIV_SIZEstatic intKEY_SIZEstatic intMAC_SIZEstatic longMAX_SKEWin SECONDSstatic intMSG1_SIZE64static intMSG2_SIZEstatic intMSG3P1_SIZE48static intOPTIONS1_SIZEstatic intOPTIONS2_SIZEstatic intTOTAL1_MAXone 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 voidclose(String reason, Exception e)Release resources on timeout.protected voidfail(String reason)protected voidfail(String reason, Exception e)protected voidfail(String reason, Exception e, boolean bySkew)(package private) static byte[][]generateSipHashKeys(RouterContext ctx, HandshakeState state)KDF for SipHashintgetVersion()Get the NTCP versionbooleanisComplete()Don't synchronize this, deadlocks all over.booleanisCorrupt()did the handshake fail for some reason?voidprepareOutbound()We are Alice.voidreceive(ByteBuffer src)Parse the contents of the buffer as part of the handshake.StringtoString()
-
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:
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
-