I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit 7628168c authored by zzz's avatar zzz
Browse files

Tunnels: Consolidate tunnel key generation

in BuildRequestor.createTunnelBuildMessage()
to prep for derived keys in prop. 157
parent 65b57fed
No related branches found
No related tags found
No related merge requests found
......@@ -110,9 +110,8 @@ abstract class BuildRequestor {
if (i > 0)
cfg.getConfig(i-1).setSendTunnelId(hop.getReceiveTunnelId());
byte iv[] = new byte[TunnelCreatorConfig.REPLY_IV_LENGTH];
ctx.random().nextBytes(iv);
cfg.setAESReplyKeys(i, ctx.keyGenerator().generateSessionKey(), iv);
// AES reply keys now set in createTunnelBuildMessage(),
// as we don't need them for short TBM
}
// This is in BuildExecutor.buildTunnel() now
// And it was overwritten by the one in createTunnelBuildMessage() anyway!
......@@ -357,6 +356,20 @@ abstract class BuildRequestor {
order = new ArrayList<Integer>(ORDER);
}
if (!useShortTBM) {
int len = cfg.getLength();
for (int i = 0; i < len; i++) {
HopConfig hop = cfg.getConfig(i);
// set IV/Layer keys (formerly in TunnelPool.configureNewTunnel())
hop.setIVKey(ctx.keyGenerator().generateSessionKey());
hop.setLayerKey(ctx.keyGenerator().generateSessionKey());
// set the AES reply keys (formerly in prepare())
byte iv[] = new byte[TunnelCreatorConfig.REPLY_IV_LENGTH];
ctx.random().nextBytes(iv);
cfg.setAESReplyKeys(i, ctx.keyGenerator().generateSessionKey(), iv);
}
} // else keys are derived
// This is in BuildExecutor.buildTunnel() now
//long replyMessageId = ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE);
//cfg.setReplyMessageId(replyMessageId);
......
......@@ -1110,6 +1110,9 @@ public class TunnelPool {
}
/**
* This only sets the peers and creation/expiration times in the configuration.
* For the crypto, see BuildRequestor and BuildMessageGenerator.
*
* @return null on failure
*/
PooledTunnelCreatorConfig configureNewTunnel() { return configureNewTunnel(false); }
......@@ -1178,8 +1181,7 @@ public class TunnelPool {
HopConfig hop = cfg.getConfig(j);
hop.setCreation(now);
hop.setExpiration(expiration);
hop.setIVKey(_context.keyGenerator().generateSessionKey());
hop.setLayerKey(_context.keyGenerator().generateSessionKey());
// IV and Layer key now set in BuildRequestor.createTunnelBuildMessage()
// tunnelIds will be updated during building, and as the creator, we
// don't need to worry about prev/next hop
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment