java.lang.Object
net.i2p.router.tunnel.pool.BuildMessageGenerator
Fill in the encrypted BuildRequestRecords in a TunnelBuildMessage.
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateUtility class, not intended for instantiation.Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateRecord(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).private static BuildRequestRecordcreateUnencryptedRecord(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.static booleanisBlank(TunnelCreatorConfig cfg, int hop) Check if a hop should have a blank (random) record.static voidlayeredEncrypt(I2PAppContext ctx, TunnelBuildMessage msg, TunnelCreatorConfig cfg, List<Integer> order) Encrypt the records so their hop ident is visible at the appropriate times.
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 inhop- the hop number for this recordmsg- out parameter - the tunnel build message to add the record tocfg- the tunnel creator configurationreplyRouter- the router to reply to (for OBEP), or nullreplyTunnel- the tunnel ID to reply to (for OBEP), or -1ctx- the router contextpeerKey- the public key to encrypt with; if null, record is random dataprops- 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 contextcfg- the tunnel creator configurationhop- the hop numberreplyRouter- null unless we are the OBEPreplyTunnel- -1 unless we are the OBEPisEC- must be true if isShort is trueisShort- short EC recordprops- 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 contextmsg- the tunnel build message to encrypt records incfg- the tunnel creator configurationorder- list of hop #s as Integers. For instance, if (order.get(1) is 4), it is peer cfg.getPeer(4)
isBlank
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 configurationhop- the hop number to check- Returns:
- true if the record should be blank