java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.CreateLeaseSetMessage
All Implemented Interfaces:
I2CPMessage
Direct Known Subclasses:
CreateLeaseSet2Message

public class CreateLeaseSetMessageextends I2CPMessageImpl
Defines the message a client sends to a router when authorizing the LeaseSet.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      The I2CP message type number for a CreateLeaseSet request.
      See Also:
    • _sessionId

      protected SessionId _sessionId
      The session ID.
    • _leaseSet

      protected LeaseSet _leaseSet
      The lease set.
    • _signingPrivateKey

      private SigningPrivateKey _signingPrivateKey
      The signing private key.
    • _privateKey

      protected PrivateKey _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

      public SessionId getSessionId()
      Session identifier for this message.
      Returns:
      the session ID
    • sessionId

      public SessionId sessionId()
      Return the SessionId for this message.
      Specified by:
      sessionId in interface I2CPMessage
      Overrides:
      sessionId in class I2CPMessageImpl
      Returns:
      null always. Extending classes with a SessionId must override.
    • setSessionId

      public void setSessionId(SessionId id)
      Session identifier for this message.
      Parameters:
      id - the session ID
    • getSigningPrivateKey

      public SigningPrivateKey getSigningPrivateKey()
      Signing private key for the lease set.
      Returns:
      the signing private key
    • setSigningPrivateKey

      public void setSigningPrivateKey(SigningPrivateKey key)
      Signing private key for the lease set.
      Parameters:
      key - the signing private key
    • getPrivateKey

      public PrivateKey getPrivateKey()
      ElGamal encryption key.
      Returns:
      the private key
    • setPrivateKey

      public void setPrivateKey(PrivateKey privateKey)
      ElGamal encryption key.
      Parameters:
      privateKey - the private key
    • getLeaseSet

      public LeaseSet getLeaseSet()
      Lease set being created.
      Returns:
      the lease set
    • setLeaseSet

      public void setLeaseSet(LeaseSet leaseSet)
      Lease set being created.
      Parameters:
      leaseSet - the lease set
    • doReadMessage

      protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException
      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:
      doReadMessage in class I2CPMessageImpl
      Parameters:
      in - positioned just past the 4 byte size and 1 byte type header
      size - how many payload bytes remain to be read
      Throws:
      I2CPMessageException - if the message format is invalid
      IOException - if there's an error reading from the stream
    • spkTypeForLen

      private static SigType spkTypeForLen(int len)
      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

      private static EncType pkTypeForLen(int len)
      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

      protected byte[] doWriteMessage() throws I2CPMessageException, IOException
      Write the message body to the output stream.
      Specified by:
      doWriteMessage in class I2CPMessageImpl
      Returns:
      byte array
      Throws:
      I2CPMessageException - if the message cannot be written
      IOException - 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

      public String toString()
      Returns a string representation of this message.
      Overrides:
      toString in class Object