Package net.i2p.router.transport.udp
Class SSU2Header
java.lang.Object
net.i2p.router.transport.udp.SSU2Header
Encrypt/decrypt headers
- Since:
- 0.9.54
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A temporary structure returned from trial decrypt, with methods to access the fields. -
Field Summary
Modifier and TypeFieldDescriptionstatic final byte[]
12 bytes of zerosstatic final byte[]
8 bytes of zeros -
Method Summary
Modifier and TypeMethodDescriptionstatic void
acceptTrialDecrypt
(UDPPacket packet, SSU2Header.Header header) Copy the header back to the packet.static long
decryptDestConnID
(DatagramPacket pkt, byte[] key1) Decrypt bytes 0-7 in header.static void
encryptHandshakeHeader
(UDPPacket packet, byte[] key1, byte[] key2) First 64 bytesstatic void
encryptLongHeader
(UDPPacket packet, byte[] key1, byte[] key2) First 32 bytesstatic void
encryptShortHeader
(UDPPacket packet, byte[] key1, byte[] key2) First 16 bytes.static SSU2Header.Header
trialDecryptHandshakeHeader
(UDPPacket packet, byte[] key1, byte[] key2) Session Request and Session Created only.static SSU2Header.Header
trialDecryptLongHeader
(UDPPacket packet, byte[] key1, byte[] key2) Retry, Token Request, Peer Test only.static SSU2Header.Header
trialDecryptShortHeader
(UDPPacket packet, byte[] key1, byte[] key2) Session Confirmed and data phase.
-
Field Details
-
HEADER_PROT_DATA
public static final byte[] HEADER_PROT_DATA8 bytes of zeros -
CHACHA_IV_0
public static final byte[] CHACHA_IV_012 bytes of zeros
-
-
Method Details
-
trialDecryptHandshakeHeader
public static SSU2Header.Header trialDecryptHandshakeHeader(UDPPacket packet, byte[] key1, byte[] key2) Session Request and Session Created only. 64 bytes. Packet is unmodified.- Parameters:
packet
- must be 88 bytes min- Returns:
- 64 byte header, null if data too short
-
trialDecryptLongHeader
Retry, Token Request, Peer Test only. 32 bytes. Packet is unmodified.- Parameters:
packet
- must be 56 bytes min- Returns:
- 32 byte header, null if data too short
-
trialDecryptShortHeader
Session Confirmed and data phase. 16 bytes. Packet is unmodified.- Parameters:
packet
- must be 40 bytes min- Returns:
- 16 byte header, null if data too short, must be 40 bytes min
-
decryptDestConnID
Decrypt bytes 0-7 in header. Packet is unmodified.- Parameters:
pkt
- must be 8 bytes min- Returns:
- the destination connection ID
- Throws:
IndexOutOfBoundsException
- if too short
-
acceptTrialDecrypt
Copy the header back to the packet. Cannot be undone. -
encryptHandshakeHeader
First 64 bytes -
encryptLongHeader
First 32 bytes -
encryptShortHeader
First 16 bytes. First 8 bytes uses key1 and the next-to-last 12 bytes as the IV. Next 8 bytes uses key2 and the last 12 bytes as the IV.
-