forked from I2P_Developers/i2p.i2p
minor cleanups
This commit is contained in:
@ -55,7 +55,9 @@ public abstract class BuildMessageGenerator {
|
||||
*
|
||||
* @param msg out parameter
|
||||
*/
|
||||
public static void createRecord(int recordNum, int hop, TunnelBuildMessage msg, TunnelCreatorConfig cfg, Hash replyRouter, long replyTunnel, I2PAppContext ctx, PublicKey peerKey) {
|
||||
public static void createRecord(int recordNum, int hop, TunnelBuildMessage msg,
|
||||
TunnelCreatorConfig cfg, Hash replyRouter,
|
||||
long replyTunnel, I2PAppContext ctx, PublicKey peerKey) {
|
||||
byte encrypted[] = new byte[TunnelBuildMessage.RECORD_SIZE];
|
||||
//Log log = ctx.logManager().getLog(BuildMessageGenerator.class);
|
||||
if (peerKey != null) {
|
||||
@ -79,7 +81,8 @@ public abstract class BuildMessageGenerator {
|
||||
msg.setRecord(recordNum, new ByteArray(encrypted));
|
||||
}
|
||||
|
||||
private static BuildRequestRecord createUnencryptedRecord(I2PAppContext ctx, TunnelCreatorConfig cfg, int hop, Hash replyRouter, long replyTunnel) {
|
||||
private static BuildRequestRecord createUnencryptedRecord(I2PAppContext ctx, TunnelCreatorConfig cfg, int hop,
|
||||
Hash replyRouter, long replyTunnel) {
|
||||
//Log log = ctx.logManager().getLog(BuildMessageGenerator.class);
|
||||
if (hop < cfg.getLength()) {
|
||||
// ok, now lets fill in some data
|
||||
@ -143,7 +146,8 @@ public abstract class BuildMessageGenerator {
|
||||
* Encrypt the records so their hop ident is visible at the appropriate times
|
||||
* @param order list of hop #s as Integers. For instance, if (order.get(1) is 4), it is peer cfg.getPeer(4)
|
||||
*/
|
||||
public static void layeredEncrypt(I2PAppContext ctx, TunnelBuildMessage msg, TunnelCreatorConfig cfg, List<Integer> order) {
|
||||
public static void layeredEncrypt(I2PAppContext ctx, TunnelBuildMessage msg,
|
||||
TunnelCreatorConfig cfg, List<Integer> order) {
|
||||
//Log log = ctx.logManager().getLog(BuildMessageGenerator.class);
|
||||
// encrypt the records so that the right elements will be visible at the right time
|
||||
for (int i = 0; i < msg.getRecordCount(); i++) {
|
||||
|
@ -20,13 +20,15 @@ class HopProcessor {
|
||||
private final IVValidator _validator;
|
||||
|
||||
/** helpful flag for debugging */
|
||||
static final boolean USE_ENCRYPTION = true;
|
||||
//static final boolean USE_ENCRYPTION = true;
|
||||
/**
|
||||
* as of i2p 0.6, the tunnel crypto will change by encrypting the IV both before
|
||||
* as of i2p 0.6, the tunnel crypto changed to encrypt the IV both before
|
||||
* and after using it at each hop so as to prevent a certain type of replay/confirmation
|
||||
* attack.
|
||||
*
|
||||
* See: http://osdir.com/ml/network.i2p/2005-07/msg00031.html
|
||||
*/
|
||||
static final boolean USE_DOUBLE_IV_ENCRYPTION = true;
|
||||
//static final boolean USE_DOUBLE_IV_ENCRYPTION = true;
|
||||
static final int IV_LENGTH = 16;
|
||||
|
||||
/** @deprecated unused */
|
||||
@ -83,12 +85,12 @@ class HopProcessor {
|
||||
//_log.debug("IV received: " + Base64.encode(iv));
|
||||
//_log.debug("Before:" + Base64.encode(orig, IV_LENGTH, orig.length - IV_LENGTH));
|
||||
}
|
||||
if (USE_ENCRYPTION) {
|
||||
if (USE_DOUBLE_IV_ENCRYPTION)
|
||||
//if (USE_ENCRYPTION) {
|
||||
//if (USE_DOUBLE_IV_ENCRYPTION)
|
||||
updateIV(orig, offset);
|
||||
encrypt(orig, offset, length);
|
||||
updateIV(orig, offset);
|
||||
}
|
||||
//}
|
||||
//if (_log.shouldLog(Log.DEBUG)) {
|
||||
//_log.debug("Data after processing: " + Base64.encode(orig, IV_LENGTH, orig.length - IV_LENGTH));
|
||||
//_log.debug("IV sent: " + Base64.encode(orig, 0, IV_LENGTH));
|
||||
|
@ -19,7 +19,7 @@ class InboundEndpointProcessor {
|
||||
private final TunnelCreatorConfig _config;
|
||||
private final IVValidator _validator;
|
||||
|
||||
static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
//static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
|
||||
/** @deprecated unused */
|
||||
public InboundEndpointProcessor(RouterContext ctx, TunnelCreatorConfig cfg) {
|
||||
@ -67,7 +67,7 @@ class InboundEndpointProcessor {
|
||||
}
|
||||
|
||||
// inbound endpoints and outbound gateways have to undo the crypto in the same way
|
||||
if (USE_ENCRYPTION)
|
||||
//if (USE_ENCRYPTION)
|
||||
decrypt(_context, _config, iv, orig, offset, length);
|
||||
|
||||
SimpleByteCache.release(iv);
|
||||
|
@ -10,14 +10,14 @@ import net.i2p.I2PAppContext;
|
||||
class InboundSender implements TunnelGateway.Sender {
|
||||
private final InboundGatewayProcessor _processor;
|
||||
|
||||
static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
//static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
|
||||
public InboundSender(I2PAppContext ctx, HopConfig config) {
|
||||
_processor = new InboundGatewayProcessor(ctx, config);
|
||||
}
|
||||
|
||||
public long sendPreprocessed(byte[] preprocessed, TunnelGateway.Receiver receiver) {
|
||||
if (USE_ENCRYPTION)
|
||||
//if (USE_ENCRYPTION)
|
||||
_processor.process(preprocessed, 0, preprocessed.length);
|
||||
return receiver.receiveEncrypted(preprocessed);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class OutboundGatewayProcessor {
|
||||
private final Log _log;
|
||||
private final TunnelCreatorConfig _config;
|
||||
|
||||
static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
//static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
|
||||
public OutboundGatewayProcessor(I2PAppContext ctx, TunnelCreatorConfig cfg) {
|
||||
_context = ctx;
|
||||
@ -42,7 +42,7 @@ class OutboundGatewayProcessor {
|
||||
_log.debug("Orig random IV: " + Base64.encode(iv));
|
||||
//_log.debug("data: " + Base64.encode(orig, iv.length, length - iv.length));
|
||||
}
|
||||
if (USE_ENCRYPTION)
|
||||
//if (USE_ENCRYPTION)
|
||||
decrypt(_context, _config, iv, orig, offset, length);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("finished processing the preprocessed data");
|
||||
@ -97,7 +97,7 @@ class OutboundGatewayProcessor {
|
||||
cur = xf;
|
||||
}
|
||||
|
||||
if (HopProcessor.USE_DOUBLE_IV_ENCRYPTION)
|
||||
//if (HopProcessor.USE_DOUBLE_IV_ENCRYPTION)
|
||||
ctx.aes().decryptBlock(orig, offset, config.getIVKey(), orig, offset);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class OutboundSender implements TunnelGateway.Sender {
|
||||
private final TunnelCreatorConfig _config;
|
||||
private final OutboundGatewayProcessor _processor;
|
||||
|
||||
static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
//static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||
|
||||
public OutboundSender(I2PAppContext ctx, TunnelCreatorConfig config) {
|
||||
_context = ctx;
|
||||
@ -27,7 +27,7 @@ class OutboundSender implements TunnelGateway.Sender {
|
||||
public long sendPreprocessed(byte[] preprocessed, TunnelGateway.Receiver receiver) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed));
|
||||
if (USE_ENCRYPTION)
|
||||
//if (USE_ENCRYPTION)
|
||||
_processor.process(preprocessed, 0, preprocessed.length);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("after wrapping up the preprocessed data on " + _config);
|
||||
|
@ -248,7 +248,9 @@ abstract class BuildRequestor {
|
||||
* then use that, otherwise the old 8-entry version.
|
||||
* @return null on error
|
||||
*/
|
||||
private static TunnelBuildMessage createTunnelBuildMessage(RouterContext ctx, TunnelPool pool, PooledTunnelCreatorConfig cfg, TunnelInfo pairedTunnel, BuildExecutor exec) {
|
||||
private static TunnelBuildMessage createTunnelBuildMessage(RouterContext ctx, TunnelPool pool,
|
||||
PooledTunnelCreatorConfig cfg,
|
||||
TunnelInfo pairedTunnel, BuildExecutor exec) {
|
||||
Log log = ctx.logManager().getLog(BuildRequestor.class);
|
||||
long replyTunnel = 0;
|
||||
Hash replyRouter = null;
|
||||
|
@ -1137,7 +1137,8 @@ public class TunnelPool {
|
||||
peers = Collections.singletonList(_context.routerHash());
|
||||
}
|
||||
|
||||
PooledTunnelCreatorConfig cfg = new PooledTunnelCreatorConfig(_context, peers.size(), settings.isInbound(), settings.getDestination());
|
||||
PooledTunnelCreatorConfig cfg = new PooledTunnelCreatorConfig(_context, peers.size(),
|
||||
settings.isInbound(), settings.getDestination());
|
||||
cfg.setTunnelPool(this);
|
||||
// peers list is ordered endpoint first, but cfg.getPeer() is ordered gateway first
|
||||
for (int i = 0; i < peers.size(); i++) {
|
||||
|
Reference in New Issue
Block a user