Author: toad
Date: 2006-12-22 02:16:40 +0000 (Fri, 22 Dec 2006)
New Revision: 11511
Modified:
trunk/freenet/src/freenet/node/FNPPacketMangler.java
Log:
Add 0-100 bytes of random data (padding) on auth packets.
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2006-12-22
01:30:23 UTC (rev 11510)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2006-12-22
02:16:40 UTC (rev 11511)
@@ -472,12 +472,13 @@
BlockCipher cipher = pn.outgoingSetupCipher;
if(logMINOR) Logger.minor(this, "Outgoing cipher:
"+HexUtil.bytesToHex(pn.outgoingSetupKey));
PCFBMode pcfb = new PCFBMode(cipher);
+ int paddingLength = node.random.nextInt(100);
byte[] iv = new byte[pcfb.lengthIV()];
node.random.nextBytes(iv);
MessageDigest md = SHA256.getMessageDigest();
byte[] hash = md.digest(output);
if(logMINOR) Logger.minor(this, "Data hash:
"+HexUtil.bytesToHex(hash));
- byte[] data = new byte[iv.length + hash.length + 2 /* length */ +
output.length];
+ byte[] data = new byte[iv.length + hash.length + 2 /* length */ +
output.length + paddingLength];
pcfb.reset(iv);
System.arraycopy(iv, 0, data, 0, iv.length);
pcfb.blockEncipher(hash, 0, hash.length);
@@ -487,6 +488,10 @@
data[hash.length+iv.length+1] = (byte) pcfb.encipher((byte)length);
pcfb.blockEncipher(output, 0, output.length);
System.arraycopy(output, 0, data, hash.length+iv.length+2,
output.length);
+ byte[] random = new byte[paddingLength];
+ // FIXME don't use node.random
+ node.random.nextBytes(random);
+ System.arraycopy(random, 0, data,
hash.length+iv.length+2+output.length, random.length);
try {
sendPacket(data, replyTo, pn, 0);
} catch (LocalAddressException e) {