final class SSU2Util extends Object
Modifier and Type | Method and 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 block
|
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
|
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
|
static byte[] |
hkdf(I2PAppContext ctx,
byte[] key,
String info)
32 byte output, ZEROLEN data
|
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.
|
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.
|
public static final int PROTOCOL_VERSION
public static final int KEY_LEN
public static final int MAC_LEN
public static final int CHACHA_IV_LEN
public static final int INTRO_KEY_LEN
public static final int SHORT_HEADER_SIZE
public static final int LONG_HEADER_SIZE
public static final int SESSION_HEADER_SIZE
public static final int DEST_CONN_ID_OFFSET
public static final int PKT_NUM_OFFSET
public static final int PKT_NUM_LEN
public static final int TYPE_OFFSET
public static final int VERSION_OFFSET
public static final int SHORT_HEADER_FLAGS_OFFSET
public static final int SHORT_HEADER_FLAGS_LEN
public static final int NETID_OFFSET
public static final int LONG_HEADER_FLAGS_OFFSET
public static final int SRC_CONN_ID_OFFSET
public static final int TOKEN_OFFSET
public static final int HEADER_PROT_SAMPLE_LEN
public static final int TOTAL_PROT_SAMPLE_LEN
public static final int HEADER_PROT_SAMPLE_1_OFFSET
public static final int HEADER_PROT_SAMPLE_2_OFFSET
public static final int HEADER_PROT_DATA_LEN
public static final int HEADER_PROT_1_OFFSET
public static final int HEADER_PROT_2_OFFSET
public static final int PADDING_MAX
public static final int PADDING_MAX_SESSION_REQUEST
public static final int PADDING_MAX_SESSION_CREATED
public static final int MIN_DATA_LEN
public static final int MIN_LONG_DATA_LEN
public static final int MIN_HANDSHAKE_DATA_LEN
public static final int MIN_TOKEN_REQUEST_LEN
public static final int MIN_RETRY_LEN
public static final int MIN_SESSION_REQUEST_LEN
public static final int MIN_SESSION_CREATED_LEN
public static final int FIRST_FRAGMENT_HEADER_SIZE
public static final int DATA_FOLLOWON_EXTRA_SIZE
public static final int FOLLOWON_FRAGMENT_HEADER_SIZE
public static final int DATA_HEADER_SIZE
public static final byte SESSION_REQUEST_FLAG_BYTE
public static final byte SESSION_CREATED_FLAG_BYTE
public static final byte SESSION_CONFIRMED_FLAG_BYTE
public static final byte DATA_FLAG_BYTE
public static final byte PEER_TEST_FLAG_BYTE
public static final byte RETRY_FLAG_BYTE
public static final byte TOKEN_REQUEST_FLAG_BYTE
public static final byte HOLE_PUNCH_FLAG_BYTE
public static final String INFO_CREATED
public static final String INFO_CONFIRMED
public static final String INFO_DATA
public static final byte[] ZEROLEN
public static final byte[] ZEROKEY
public static final byte[] RELAY_REQUEST_PROLOGUE
public static final byte[] RELAY_RESPONSE_PROLOGUE
public static final byte[] PEER_TEST_PROLOGUE
public static final int TEST_ACCEPT
public static final int TEST_REJECT_BOB_UNSPEC
public static final int TEST_REJECT_BOB_NO_CHARLIE
public static final int TEST_REJECT_BOB_LIMIT
public static final int TEST_REJECT_BOB_SIGFAIL
public static final int TEST_REJECT_BOB_ADDRESS
public static final int TEST_REJECT_CHARLIE_UNSPEC
public static final int TEST_REJECT_CHARLIE_ADDRESS
public static final int TEST_REJECT_CHARLIE_LIMIT
public static final int TEST_REJECT_CHARLIE_SIGFAIL
public static final int TEST_REJECT_CHARLIE_CONNECTED
public static final int TEST_REJECT_CHARLIE_BANNED
public static final int TEST_REJECT_CHARLIE_UNKNOWN_ALICE
public static final int RELAY_ACCEPT
public static final int RELAY_REJECT_BOB_UNSPEC
public static final int RELAY_REJECT_BOB_BANNED_CHARLIE
public static final int RELAY_REJECT_BOB_LIMIT
public static final int RELAY_REJECT_BOB_SIGFAIL
public static final int RELAY_REJECT_BOB_NO_TAG
public static final int RELAY_REJECT_BOB_UNKNOWN_ALICE
public static final int RELAY_REJECT_CHARLIE_UNSPEC
public static final int RELAY_REJECT_CHARLIE_ADDRESS
public static final int RELAY_REJECT_CHARLIE_LIMIT
public static final int RELAY_REJECT_CHARLIE_SIGFAIL
public static final int RELAY_REJECT_CHARLIE_CONNECTED
public static final int RELAY_REJECT_CHARLIE_BANNED
public static final int RELAY_REJECT_CHARLIE_UNKNOWN_ALICE
public static final int REASON_UNSPEC
public static final int REASON_TERMINATION
public static final int REASON_TIMEOUT
public static final int REASON_SHUTDOWN
public static final int REASON_AEAD
public static final int REASON_OPTIONS
public static final int REASON_SIGTYPE
public static final int REASON_SKEW
public static final int REASON_PADDING
public static final int REASON_FRAMING
public static final int REASON_PAYLOAD
public static final int REASON_MSG1
public static final int REASON_MSG2
public static final int REASON_MSG3
public static final int REASON_FRAME_TIMEOUT
public static final int REASON_SIGFAIL
public static final int REASON_S_MISMATCH
public static final int REASON_BANNED
public static final int REASON_TOKEN
public static final int REASON_LIMITS
public static final int REASON_VERSION
public static final int REASON_NETID
public static final int REASON_REPLACED
public static byte[] hkdf(I2PAppContext ctx, byte[] key, String info)
public static byte[] createPeerTestData(I2PAppContext ctx, Hash h, Hash h2, PeerTestState.Role role, long nonce, byte[] ip, int port, SigningPrivateKey spk)
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 nullpublic static byte[] createRelayRequestData(I2PAppContext ctx, Hash h, Hash h2, long nonce, long tag, byte[] ip, int port, SigningPrivateKey spk)
h
- Bob hash to be included in sig, not included in datah2
- Charlie hash to be included in sig, not included in dataip
- non-nullpublic static byte[] createRelayResponseData(I2PAppContext ctx, Hash h, int code, long nonce, byte[] ip, int port, SigningPrivateKey spk, long token)
h
- Bob hash to be included in sig, not included in dataip
- may be nullport
- ignored if ip is nulltoken
- if nonzero, append itpublic static Signature sign(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, int datalen, SigningPrivateKey spk)
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 datapublic static boolean validateSig(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, SigningPublicKey spk)
h2
- may be nulldata
- not including relay response token