java.lang.Object
net.i2p.client.datagram.I2PDatagramMaker
Class for creating I2P repliable datagrams. Note that objects of this class are NOT THREAD SAFE!
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DSAEngineSigns the datagram.private final SHA256GeneratorHashes the datagram contents.private static final intStarting size of the datagram buffer, in bytes.private static final intLargest datagram that can be made, in bytes.private byte[]This maker's destination, embedded in each datagram.private final ByteArrayOutputStreamBuffer the datagram is assembled in.private SigningPrivateKeyKey that signs the datagrams.Constructor Summary
ConstructorsConstructorDescriptionAn I2PDatagramMaker with no session yet; use setI2PDatagramMaker to set the parameters.I2PDatagramMaker(I2PSession session) An I2PDatagramMaker able to create I2P repliable datagrams going to be sent through the specified I2PSession.Method Summary
All MethodsModifier and TypeMethodDescriptionbyte[]makeI2PDatagram(byte[] payload) Make a repliable I2P datagram containing the specified payload.voidsetI2PDatagramMaker(I2PSession session) Does NOT support LS2 offline keys!
Field Details
INIT_DGRAM_BUFSIZE
private static final int INIT_DGRAM_BUFSIZEStarting size of the datagram buffer, in bytes.- See Also:
MAX_DGRAM_BUFSIZE
private static final int MAX_DGRAM_BUFSIZELargest datagram that can be made, in bytes.- See Also:
hashGen
Hashes the datagram contents.dsaEng
Signs the datagram.sxPrivKey
Key that signs the datagrams.sxDestBytes
private byte[] sxDestBytesThis maker's destination, embedded in each datagram.sxDGram
Buffer the datagram is assembled in.
Constructor Details
I2PDatagramMaker
An I2PDatagramMaker able to create I2P repliable datagrams going to be sent through the specified I2PSession.Does NOT support LS2 offline keys!
- Parameters:
session- I2PSession used to send I2PDatagrams through- Throws:
IllegalArgumentException- if session has offline keys
I2PDatagramMaker
public I2PDatagramMaker()An I2PDatagramMaker with no session yet; use setI2PDatagramMaker to set the parameters.
Method Details
setI2PDatagramMaker
Does NOT support LS2 offline keys!- Parameters:
session- I2PSession used to send I2PDatagrams through- Throws:
IllegalArgumentException- if session has offline keys
makeI2PDatagram
public byte[] makeI2PDatagram(byte[] payload) Make a repliable I2P datagram containing the specified payload.Format is:
- Destination (387+ bytes)
- Signature (40+ bytes, type and length as implied by signing key type in the Destination)
- Payload
Maximum datagram size is ~64KB, so maximum payload size is a little less. Practical maximum is a few KB less due to Destination and Garlic overhead. 10 KB or less is recommended for best results.
For DSA_SHA1 Destinations, the signature is of the SHA-256 Hash of the payload.
As of 0.9.14, for non-DSA_SHA1 Destinations, the signature is of the payload itself.
- Parameters:
payload- non-null Bytes to be contained in the I2P datagram.- Returns:
- null on error
- Throws:
IllegalArgumentException- if payload is too bigIllegalStateException- if Destination signature type unsupported