java.lang.Object
net.i2p.router.tunnel.pool.BuildMessageGenerator

abstract class BuildMessageGeneratorextends Object
Fill in the encrypted BuildRequestRecords in a TunnelBuildMessage.
  • Constructor Details

    • BuildMessageGenerator

      private BuildMessageGenerator()
      Utility class, not intended for instantiation.
  • Method Details

    • createRecord

      public static void createRecord(int recordNum, int hop, TunnelBuildMessage msg, TunnelCreatorConfig cfg, Hash replyRouter, long replyTunnel, RouterContext ctx, PublicKey peerKey, Properties props)
      Place the asymmetrically encrypted record in the specified record slot, containing the hop's configuration (as well as the reply info, if it is an outbound endpoint).
      Parameters:
      recordNum - the record number to place this record in
      hop - the hop number for this record
      msg - out parameter - the tunnel build message to add the record to
      cfg - the tunnel creator configuration
      replyRouter - the router to reply to (for OBEP), or null
      replyTunnel - the tunnel ID to reply to (for OBEP), or -1
      ctx - the router context
      peerKey - the public key to encrypt with; if null, record is random data
      props - properties to go in the build record, non-null
      Throws:
      IllegalArgumentException - if hop bigger than config
    • createUnencryptedRecord

      private static BuildRequestRecord createUnencryptedRecord(I2PAppContext ctx, TunnelCreatorConfig cfg, int hop, Hash replyRouter, long replyTunnel, boolean isEC, boolean isShort, Properties props)
      Create an unencrypted build request record for a tunnel hop. Returns null if hop >= cfg.length.
      Parameters:
      ctx - the I2P application context
      cfg - the tunnel creator configuration
      hop - the hop number
      replyRouter - null unless we are the OBEP
      replyTunnel - -1 unless we are the OBEP
      isEC - must be true if isShort is true
      isShort - short EC record
      props - to go in the build record, non-null
      Returns:
      the build request record, or null if hop >= cfg.length
      Throws:
      IllegalArgumentException - if isShort is true but isEC is false
    • layeredEncrypt

      public static void layeredEncrypt(I2PAppContext ctx, TunnelBuildMessage msg, TunnelCreatorConfig cfg, List<Integer> order)
      Encrypt the records so their hop ident is visible at the appropriate times.

      Note that this layer-encrypts the build records for the message in-place. Only call this once for a given message.

      Parameters:
      ctx - the I2P application context
      msg - the tunnel build message to encrypt records in
      cfg - the tunnel creator configuration
      order - list of hop #s as Integers. For instance, if (order.get(1) is 4), it is peer cfg.getPeer(4)
    • isBlank

      public static boolean isBlank(TunnelCreatorConfig cfg, int hop)
      Check if a hop should have a blank (random) record. Used for zero-hop tunnels or places where we don't need encryption.
      Parameters:
      cfg - the tunnel creator configuration
      hop - the hop number to check
      Returns:
      true if the record should be blank