Package net.i2p.router.transport.udp
Class SSU2Util
- java.lang.Object
-
- net.i2p.router.transport.udp.SSU2Util
-
final class SSU2Util extends Object
SSU2 Utils and constants- Since:
- 0.9.54
-
-
Field Summary
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
createPeerTestData(I2PAppContext ctx, Hash h, Hash h2, PeerTestState.Role role, long nonce, byte[] ip, int port, SigningPrivateKey spk)
Make the data for the peer test blockstatic byte[]
createRelayRequestData(I2PAppContext ctx, Hash h, Hash h2, long nonce, long tag, byte[] ip, int port, SigningPrivateKey spk)
Make the data for the relay request blockstatic byte[]
createRelayResponseData(I2PAppContext ctx, Hash h, int code, long nonce, byte[] ip, int port, SigningPrivateKey spk, long token)
Make the data for the relay response blockstatic byte[]
hkdf(I2PAppContext ctx, byte[] key, String info)
32 byte output, ZEROLEN datastatic Signature
sign(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, int datalen, SigningPrivateKey spk)
Sign the relay or peer test data, using the prologue and hash as the initial data, and then the provided data.static boolean
validateSig(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, SigningPublicKey spk)
Validate the signed relay or peer test data, using the prologue and hash as the initial data, and then the provided data which ends with a signature of the specified type.
-
-
-
Field Detail
-
PROTOCOL_VERSION
public static final int PROTOCOL_VERSION
- See Also:
- Constant Field Values
-
KEY_LEN
public static final int KEY_LEN
32
-
MAC_LEN
public static final int MAC_LEN
- See Also:
- Constant Field Values
-
CHACHA_IV_LEN
public static final int CHACHA_IV_LEN
- See Also:
- Constant Field Values
-
INTRO_KEY_LEN
public static final int INTRO_KEY_LEN
- See Also:
- Constant Field Values
-
SHORT_HEADER_SIZE
public static final int SHORT_HEADER_SIZE
- See Also:
- Constant Field Values
-
LONG_HEADER_SIZE
public static final int LONG_HEADER_SIZE
- See Also:
- Constant Field Values
-
SESSION_HEADER_SIZE
public static final int SESSION_HEADER_SIZE
64
-
DEST_CONN_ID_OFFSET
public static final int DEST_CONN_ID_OFFSET
- See Also:
- Constant Field Values
-
PKT_NUM_OFFSET
public static final int PKT_NUM_OFFSET
- See Also:
- Constant Field Values
-
PKT_NUM_LEN
public static final int PKT_NUM_LEN
- See Also:
- Constant Field Values
-
TYPE_OFFSET
public static final int TYPE_OFFSET
- See Also:
- Constant Field Values
-
VERSION_OFFSET
public static final int VERSION_OFFSET
- See Also:
- Constant Field Values
-
SHORT_HEADER_FLAGS_OFFSET
public static final int SHORT_HEADER_FLAGS_OFFSET
- See Also:
- Constant Field Values
-
SHORT_HEADER_FLAGS_LEN
public static final int SHORT_HEADER_FLAGS_LEN
- See Also:
- Constant Field Values
-
NETID_OFFSET
public static final int NETID_OFFSET
- See Also:
- Constant Field Values
-
LONG_HEADER_FLAGS_OFFSET
public static final int LONG_HEADER_FLAGS_OFFSET
- See Also:
- Constant Field Values
-
SRC_CONN_ID_OFFSET
public static final int SRC_CONN_ID_OFFSET
- See Also:
- Constant Field Values
-
TOKEN_OFFSET
public static final int TOKEN_OFFSET
- See Also:
- Constant Field Values
-
HEADER_PROT_SAMPLE_LEN
public static final int HEADER_PROT_SAMPLE_LEN
- See Also:
- Constant Field Values
-
TOTAL_PROT_SAMPLE_LEN
public static final int TOTAL_PROT_SAMPLE_LEN
- See Also:
- Constant Field Values
-
HEADER_PROT_SAMPLE_1_OFFSET
public static final int HEADER_PROT_SAMPLE_1_OFFSET
- See Also:
- Constant Field Values
-
HEADER_PROT_SAMPLE_2_OFFSET
public static final int HEADER_PROT_SAMPLE_2_OFFSET
- See Also:
- Constant Field Values
-
HEADER_PROT_DATA_LEN
public static final int HEADER_PROT_DATA_LEN
- See Also:
- Constant Field Values
-
HEADER_PROT_1_OFFSET
public static final int HEADER_PROT_1_OFFSET
- See Also:
- Constant Field Values
-
HEADER_PROT_2_OFFSET
public static final int HEADER_PROT_2_OFFSET
- See Also:
- Constant Field Values
-
PADDING_MAX
public static final int PADDING_MAX
- See Also:
- Constant Field Values
-
PADDING_MAX_SESSION_REQUEST
public static final int PADDING_MAX_SESSION_REQUEST
- See Also:
- Constant Field Values
-
PADDING_MAX_SESSION_CREATED
public static final int PADDING_MAX_SESSION_CREATED
- See Also:
- Constant Field Values
-
MIN_DATA_LEN
public static final int MIN_DATA_LEN
40- See Also:
- Constant Field Values
-
MIN_LONG_DATA_LEN
public static final int MIN_LONG_DATA_LEN
56- See Also:
- Constant Field Values
-
MIN_HANDSHAKE_DATA_LEN
public static final int MIN_HANDSHAKE_DATA_LEN
88
-
MIN_TOKEN_REQUEST_LEN
public static final int MIN_TOKEN_REQUEST_LEN
56- See Also:
- Constant Field Values
-
MIN_RETRY_LEN
public static final int MIN_RETRY_LEN
56- See Also:
- Constant Field Values
-
MIN_SESSION_REQUEST_LEN
public static final int MIN_SESSION_REQUEST_LEN
88
-
MIN_SESSION_CREATED_LEN
public static final int MIN_SESSION_CREATED_LEN
88
-
FIRST_FRAGMENT_HEADER_SIZE
public static final int FIRST_FRAGMENT_HEADER_SIZE
3 byte block header- See Also:
- Constant Field Values
-
DATA_FOLLOWON_EXTRA_SIZE
public static final int DATA_FOLLOWON_EXTRA_SIZE
5 for flag and msg number in followon block- See Also:
- Constant Field Values
-
FOLLOWON_FRAGMENT_HEADER_SIZE
public static final int FOLLOWON_FRAGMENT_HEADER_SIZE
3 byte block header + 4 byte msg ID + 1 byte fragment info = 8- See Also:
- Constant Field Values
-
DATA_HEADER_SIZE
public static final int DATA_HEADER_SIZE
16 byte short header- See Also:
- Constant Field Values
-
SESSION_REQUEST_FLAG_BYTE
public static final byte SESSION_REQUEST_FLAG_BYTE
The message types, 0-11, as bytes- See Also:
- Constant Field Values
-
SESSION_CREATED_FLAG_BYTE
public static final byte SESSION_CREATED_FLAG_BYTE
- See Also:
- Constant Field Values
-
SESSION_CONFIRMED_FLAG_BYTE
public static final byte SESSION_CONFIRMED_FLAG_BYTE
- See Also:
- Constant Field Values
-
DATA_FLAG_BYTE
public static final byte DATA_FLAG_BYTE
- See Also:
- Constant Field Values
-
PEER_TEST_FLAG_BYTE
public static final byte PEER_TEST_FLAG_BYTE
- See Also:
- Constant Field Values
-
RETRY_FLAG_BYTE
public static final byte RETRY_FLAG_BYTE
- See Also:
- Constant Field Values
-
TOKEN_REQUEST_FLAG_BYTE
public static final byte TOKEN_REQUEST_FLAG_BYTE
- See Also:
- Constant Field Values
-
HOLE_PUNCH_FLAG_BYTE
public static final byte HOLE_PUNCH_FLAG_BYTE
- See Also:
- Constant Field Values
-
INFO_CREATED
public static final String INFO_CREATED
- See Also:
- Constant Field Values
-
INFO_CONFIRMED
public static final String INFO_CONFIRMED
- See Also:
- Constant Field Values
-
INFO_DATA
public static final String INFO_DATA
- See Also:
- Constant Field Values
-
ZEROLEN
public static final byte[] ZEROLEN
-
ZEROKEY
public static final byte[] ZEROKEY
-
RELAY_REQUEST_PROLOGUE
public static final byte[] RELAY_REQUEST_PROLOGUE
-
RELAY_RESPONSE_PROLOGUE
public static final byte[] RELAY_RESPONSE_PROLOGUE
-
PEER_TEST_PROLOGUE
public static final byte[] PEER_TEST_PROLOGUE
-
TEST_ACCEPT
public static final int TEST_ACCEPT
- See Also:
- Constant Field Values
-
TEST_REJECT_BOB_UNSPEC
public static final int TEST_REJECT_BOB_UNSPEC
- See Also:
- Constant Field Values
-
TEST_REJECT_BOB_NO_CHARLIE
public static final int TEST_REJECT_BOB_NO_CHARLIE
- See Also:
- Constant Field Values
-
TEST_REJECT_BOB_LIMIT
public static final int TEST_REJECT_BOB_LIMIT
- See Also:
- Constant Field Values
-
TEST_REJECT_BOB_SIGFAIL
public static final int TEST_REJECT_BOB_SIGFAIL
- See Also:
- Constant Field Values
-
TEST_REJECT_BOB_ADDRESS
public static final int TEST_REJECT_BOB_ADDRESS
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_UNSPEC
public static final int TEST_REJECT_CHARLIE_UNSPEC
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_ADDRESS
public static final int TEST_REJECT_CHARLIE_ADDRESS
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_LIMIT
public static final int TEST_REJECT_CHARLIE_LIMIT
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_SIGFAIL
public static final int TEST_REJECT_CHARLIE_SIGFAIL
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_CONNECTED
public static final int TEST_REJECT_CHARLIE_CONNECTED
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_BANNED
public static final int TEST_REJECT_CHARLIE_BANNED
- See Also:
- Constant Field Values
-
TEST_REJECT_CHARLIE_UNKNOWN_ALICE
public static final int TEST_REJECT_CHARLIE_UNKNOWN_ALICE
- See Also:
- Constant Field Values
-
RELAY_ACCEPT
public static final int RELAY_ACCEPT
- See Also:
- Constant Field Values
-
RELAY_REJECT_BOB_UNSPEC
public static final int RELAY_REJECT_BOB_UNSPEC
- See Also:
- Constant Field Values
-
RELAY_REJECT_BOB_BANNED_CHARLIE
public static final int RELAY_REJECT_BOB_BANNED_CHARLIE
- See Also:
- Constant Field Values
-
RELAY_REJECT_BOB_LIMIT
public static final int RELAY_REJECT_BOB_LIMIT
- See Also:
- Constant Field Values
-
RELAY_REJECT_BOB_SIGFAIL
public static final int RELAY_REJECT_BOB_SIGFAIL
- See Also:
- Constant Field Values
-
RELAY_REJECT_BOB_NO_TAG
public static final int RELAY_REJECT_BOB_NO_TAG
- See Also:
- Constant Field Values
-
RELAY_REJECT_BOB_UNKNOWN_ALICE
public static final int RELAY_REJECT_BOB_UNKNOWN_ALICE
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_UNSPEC
public static final int RELAY_REJECT_CHARLIE_UNSPEC
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_ADDRESS
public static final int RELAY_REJECT_CHARLIE_ADDRESS
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_LIMIT
public static final int RELAY_REJECT_CHARLIE_LIMIT
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_SIGFAIL
public static final int RELAY_REJECT_CHARLIE_SIGFAIL
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_CONNECTED
public static final int RELAY_REJECT_CHARLIE_CONNECTED
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_BANNED
public static final int RELAY_REJECT_CHARLIE_BANNED
- See Also:
- Constant Field Values
-
RELAY_REJECT_CHARLIE_UNKNOWN_ALICE
public static final int RELAY_REJECT_CHARLIE_UNKNOWN_ALICE
- See Also:
- Constant Field Values
-
REASON_UNSPEC
public static final int REASON_UNSPEC
- See Also:
- Constant Field Values
-
REASON_TERMINATION
public static final int REASON_TERMINATION
- See Also:
- Constant Field Values
-
REASON_TIMEOUT
public static final int REASON_TIMEOUT
- See Also:
- Constant Field Values
-
REASON_SHUTDOWN
public static final int REASON_SHUTDOWN
- See Also:
- Constant Field Values
-
REASON_AEAD
public static final int REASON_AEAD
- See Also:
- Constant Field Values
-
REASON_OPTIONS
public static final int REASON_OPTIONS
- See Also:
- Constant Field Values
-
REASON_SIGTYPE
public static final int REASON_SIGTYPE
- See Also:
- Constant Field Values
-
REASON_SKEW
public static final int REASON_SKEW
- See Also:
- Constant Field Values
-
REASON_PADDING
public static final int REASON_PADDING
- See Also:
- Constant Field Values
-
REASON_FRAMING
public static final int REASON_FRAMING
- See Also:
- Constant Field Values
-
REASON_PAYLOAD
public static final int REASON_PAYLOAD
- See Also:
- Constant Field Values
-
REASON_MSG1
public static final int REASON_MSG1
- See Also:
- Constant Field Values
-
REASON_MSG2
public static final int REASON_MSG2
- See Also:
- Constant Field Values
-
REASON_MSG3
public static final int REASON_MSG3
- See Also:
- Constant Field Values
-
REASON_FRAME_TIMEOUT
public static final int REASON_FRAME_TIMEOUT
- See Also:
- Constant Field Values
-
REASON_SIGFAIL
public static final int REASON_SIGFAIL
- See Also:
- Constant Field Values
-
REASON_S_MISMATCH
public static final int REASON_S_MISMATCH
- See Also:
- Constant Field Values
-
REASON_BANNED
public static final int REASON_BANNED
- See Also:
- Constant Field Values
-
REASON_TOKEN
public static final int REASON_TOKEN
- See Also:
- Constant Field Values
-
REASON_LIMITS
public static final int REASON_LIMITS
- See Also:
- Constant Field Values
-
REASON_VERSION
public static final int REASON_VERSION
- See Also:
- Constant Field Values
-
REASON_NETID
public static final int REASON_NETID
- See Also:
- Constant Field Values
-
REASON_REPLACED
public static final int REASON_REPLACED
- See Also:
- Constant Field Values
-
-
Method Detail
-
hkdf
public static byte[] hkdf(I2PAppContext ctx, byte[] key, String info)
32 byte output, ZEROLEN data
-
createPeerTestData
public static byte[] createPeerTestData(I2PAppContext ctx, Hash h, Hash h2, PeerTestState.Role role, long nonce, byte[] ip, int port, SigningPrivateKey spk)
Make the data for the peer test block- Parameters:
h
- to be included in sig, not included in datah2
- may be null, to be included in sig, not included in datarole
- unusedip
- may be null- Returns:
- null on failure
-
createRelayRequestData
public static byte[] createRelayRequestData(I2PAppContext ctx, Hash h, Hash h2, long nonce, long tag, byte[] ip, int port, SigningPrivateKey spk)
Make the data for the relay request block- Parameters:
h
- Bob hash to be included in sig, not included in datah2
- Charlie hash to be included in sig, not included in dataip
- non-null- Returns:
- null on failure
- Since:
- 0.9.55
-
createRelayResponseData
public static byte[] createRelayResponseData(I2PAppContext ctx, Hash h, int code, long nonce, byte[] ip, int port, SigningPrivateKey spk, long token)
Make the data for the relay response block- Parameters:
h
- Bob hash to be included in sig, not included in dataip
- may be nullport
- ignored if ip is nulltoken
- if nonzero, append it- Returns:
- null on failure
- Since:
- 0.9.55
-
sign
public static Signature sign(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, int datalen, SigningPrivateKey spk)
Sign the relay or peer test data, using the prologue and hash as the initial data, and then the provided data.- Parameters:
data
- if desired, leave room at end for sigdatalen
- the length of the data to be signedh
- to be included in sig, not included in datah2
- may be null, to be included in sig, not included in data- Returns:
- null on failure
-
validateSig
public static boolean validateSig(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, SigningPublicKey spk)
Validate the signed relay or peer test data, using the prologue and hash as the initial data, and then the provided data which ends with a signature of the specified type.- Parameters:
h2
- may be nulldata
- not including relay response token
-
-