java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.CreateLeaseSetMessage
- All Implemented Interfaces:
I2CPMessage
- Direct Known Subclasses:
CreateLeaseSet2Message
Defines the message a client sends to a router when authorizing the LeaseSet.
Field Summary
Modifier and TypeFieldDescriptionprotected LeaseSetThe lease set.protected PrivateKeyThe private key.protected SessionIdThe session ID.private SigningPrivateKeyThe signing private key.static final intThe I2CP message type number for a CreateLeaseSet request.Constructor Summary
ConstructorsConstructorDescriptionNo-arg constructor for I2CP deserialization; the session ID and lease set are filled in from the wire format by readData().Method Summary
Modifier and TypeMethodDescriptionprotected voiddoReadMessage(InputStream in, int size) Read the message body from the input stream.protected byte[]Write the message body to the output stream.Lease set being created.ElGamal encryption key.Session identifier for this message.Signing private key for the lease set.intgetType()Returns the I2CP message type number for this message.private static EncTypepkTypeForLen(int len) Map a known encryption private key length to its most likely type.Return the SessionId for this message.voidsetLeaseSet(LeaseSet leaseSet) Lease set being created.voidsetPrivateKey(PrivateKey privateKey) ElGamal encryption key.voidSession identifier for this message.voidSigning private key for the lease set.private static SigTypespkTypeForLen(int len) Map a known signing private key length to its most likely type.toString()Returns a string representation of this message.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, writeBytes, writeMessageModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException inDataFormatException.voidValidate the type and size of the message, and then read the message into the data structures.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.voidwriteBytes(OutputStream out) Write the message to the stream, wrapping I2CPMessageException in DataFormatException.voidwriteMessage(OutputStream out) Write out the full message to the stream, including the 4 byte size and 1 byte type header.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEThe I2CP message type number for a CreateLeaseSet request.- See Also:
_sessionId
The session ID._leaseSet
The lease set._signingPrivateKey
The signing private key._privateKey
The private key.
Constructor Details
CreateLeaseSetMessage
public CreateLeaseSetMessage()No-arg constructor for I2CP deserialization; the session ID and lease set are filled in from the wire format by readData().
Method Details
getSessionId
sessionId
Return the SessionId for this message.- Specified by:
sessionIdin interfaceI2CPMessage- Overrides:
sessionIdin classI2CPMessageImpl- Returns:
- null always. Extending classes with a SessionId must override.
setSessionId
Session identifier for this message.- Parameters:
id- the session ID
getSigningPrivateKey
Signing private key for the lease set.- Returns:
- the signing private key
setSigningPrivateKey
Signing private key for the lease set.- Parameters:
key- the signing private key
getPrivateKey
setPrivateKey
ElGamal encryption key.- Parameters:
privateKey- the private key
getLeaseSet
setLeaseSet
Lease set being created.- Parameters:
leaseSet- the lease set
doReadMessage
Read the message body from the input stream.The signing and encryption private keys precede the LeaseSet but carry no type or length prefix, so their sizes cannot be known up front. The historical reader assumed DSA (20 bytes) + ElGamal (256 bytes); an external client sending ECIES or EdDSA keys therefore shifts every following field, and the recovered "LeaseSet" is garbage (insane lease dates, wrong destination). We now buffer the payload and try the known key layouts in turn, taking the first that yields a parseable LeaseSet. The classic layout is tried first so well-formed legacy messages behave exactly as before.
- Specified by:
doReadMessagein classI2CPMessageImpl- Parameters:
in- positioned just past the 4 byte size and 1 byte type headersize- how many payload bytes remain to be read- Throws:
I2CPMessageException- if the message format is invalidIOException- if there's an error reading from the stream
spkTypeForLen
Map a known signing private key length to its most likely type.- Parameters:
len- key length in bytes- Returns:
- DSA_SHA1 for 20, EdDSA_SHA512_Ed25519 for 64, else ECDSA_SHA256_P256
pkTypeForLen
Map a known encryption private key length to its most likely type.- Parameters:
len- key length in bytes- Returns:
- ELGAMAL_2048 for 256, else ECIES_X25519
doWriteMessage
Write the message body to the output stream.- Specified by:
doWriteMessagein classI2CPMessageImpl- Returns:
- byte array
- Throws:
I2CPMessageException- if the message cannot be writtenIOException- if there's an error writing to the stream
getType
public int getType()Returns the I2CP message type number for this message.- Returns:
MESSAGE_TYPE, identifying this as a CreateLeaseSet message to the peer
toString