java.lang.Object
net.i2p.router.tunnel.InboundEndpointProcessor

class InboundEndpointProcessorextends Object
Receive the inbound tunnel message, removing all of the layers added by earlier hops to recover the preprocessed data sent by the gateway. This delegates the crypto to the OutboundGatewayProcessor, since the tunnel creator does the same thing in both instances.
  • Field Details

    • _context

      private final RouterContext _context
      The router ending the tunnel.
    • _log

      private final Log _log
      Logger for this class.
    • _config

      private final TunnelCreatorConfig _config
      The tunnel's configuration.
    • _validator

      private final IVValidator _validator
      Rejects reused initialization vectors.
  • Constructor Details

    • InboundEndpointProcessor

      public InboundEndpointProcessor(RouterContext ctx, TunnelCreatorConfig cfg, IVValidator validator)
      Binds the router context, tunnel creator config, and IV validator.
      Parameters:
      ctx - the router context supplying the log and network database
      cfg - the tunnel creator config describing the inbound tunnel
      validator - the IV validator that authenticates and strips the per-message IV
  • Method Details

    • getDestination

      public Hash getDestination()
      The destination this inbound tunnel was created for.
      Returns:
      the destination hash this inbound tunnel serves, or null for exploratory tunnels
    • getConfig

      public TunnelCreatorConfig getConfig()
      The tunnel creator config for this endpoint.
      Returns:
      the config passed to the constructor, describing the inbound tunnel this processor belongs to
    • retrievePreprocessedData

      public boolean retrievePreprocessedData(byte[] orig, int offset, int length, Hash prev)
      Undo all of the encryption done by the peers in the tunnel, recovering the preprocessed data sent by the gateway.
      Parameters:
      orig - original data with an extra 16 byte IV prepended.
      offset - index into the array where the extra 16 bytes (IV) begins
      length - how much of orig can we write to (must be a multiple of 16). Should always be 1024 bytes.
      prev - the sending peer's hash, matched against the tunnel's second-to-last hop
      Returns:
      true if the data was recovered (and written in place to orig), false if it was a duplicate or from the wrong peer.
    • decrypt

      private void decrypt(RouterContext ctx, TunnelCreatorConfig cfg, byte[] orig, int offset, int length)
      Iteratively undo the crypto that the various layers in the tunnel added.
      Parameters:
      ctx - the router context, passed on to each layer's decryption
      cfg - the tunnel's configuration, supplying the crypto settings of every hop except the endpoint (this gateway created the tunnel)
      orig - original data with an extra 16 byte IV prepended.
      offset - index into the array where the extra 16 bytes (IV) begins
      length - how much of orig can we write to (must be a multiple of 16). Should always be 1024 bytes.