Package net.i2p.router.crypto.ratchet
Class RatchetPayload
- java.lang.Object
-
- net.i2p.router.crypto.ratchet.RatchetPayload
-
class RatchetPayload extends Object
Ratchet payload generation and parsing- Since:
- 0.9.44 adapted from NTCP2Payload
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRatchetPayload.BlockBase class for blocks to be transmitted.static classRatchetPayload.DateTimeBlockstatic classRatchetPayload.GarlicBlockstatic classRatchetPayload.NextKeyBlockstatic classRatchetPayload.OptionsBlockstatic classRatchetPayload.PaddingBlockstatic interfaceRatchetPayload.PayloadCallbackFor all callbacks, recommend throwing exceptions only from the handshake.static classRatchetPayload.TerminationBlock
-
Field Summary
Fields Modifier and Type Field Description static intBLOCK_HEADER_SIZE
-
Constructor Summary
Constructors Constructor Description RatchetPayload()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static longfromLong8(byte[] src, int offset)Big endian.static intprocessPayload(I2PAppContext ctx, RatchetPayload.PayloadCallback cb, byte[] payload, int off, int length, boolean isHandshake)Incoming payload.(package private) static voidtoLong8(byte[] target, int offset, long value)Big endian.static intwritePayload(byte[] payload, int off, List<RatchetPayload.Block> blocks)
-
-
-
Field Detail
-
BLOCK_HEADER_SIZE
public static final int BLOCK_HEADER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
processPayload
public static int processPayload(I2PAppContext ctx, RatchetPayload.PayloadCallback cb, byte[] payload, int off, int length, boolean isHandshake) throws IOException, DataFormatException, I2NPMessageException
Incoming payload. Calls the callback for each received block.- Returns:
- number of blocks processed
- Throws:
IOException- on major errorsDataFormatException- on parsing of individual blocksI2NPMessageException- on parsing of I2NP block
-
writePayload
public static int writePayload(byte[] payload, int off, List<RatchetPayload.Block> blocks)- Parameters:
payload- writes to it starting at off- Returns:
- the new offset
-
fromLong8
static long fromLong8(byte[] src, int offset)Big endian. Same as DataHelper.fromLong(src, offset, 8) but allows negative result- Throws:
ArrayIndexOutOfBoundsException
-
toLong8
static void toLong8(byte[] target, int offset, long value)Big endian. Same as DataHelper.toLong(target, offset, 8, value) but allows negative value- Throws:
ArrayIndexOutOfBoundsException
-
-