Author: nextgens
Date: 2008-11-11 23:02:37 +0000 (Tue, 11 Nov 2008)
New Revision: 23496
Modified:
trunk/freenet/src/freenet/node/FNPPacketMangler.java
Log:
prevent jfk message4 to be handled more than once (might fix toad's keytracker
problem)
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-11-11
22:18:30 UTC (rev 23495)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-11-11
23:02:37 UTC (rev 23496)
@@ -1284,6 +1284,23 @@
Logger.normal(this, "The digest-HMAC doesn't match;
let's discard the packet - "+pn.getPeer());
return false;
}
+
+ // Try to find the HMAC in the cache:
+ // If it is already present it indicates duplicate/replayed
message4 and we can discard
+ // If it's not, we can add it with a timestamp
+ byte[] message4Timestamp = null;
+ synchronized (authenticatorCache) {
+ ByteArrayWrapper hmacBAW = new ByteArrayWrapper(hmac);
+ message4Timestamp = authenticatorCache.get(hmacBAW);
+ if(message4Timestamp == null) { // normal behaviour
+ authenticatorCache.put(hmacBAW,
Fields.longToBytes(t1));
+ }
+ }
+ if(message4Timestamp != null) {
+ Logger.normal(this, "We got a replayed message4 (first
handled at "+Fields.bytesToLong(message4Timestamp)+") from - "+pn);
+ return true;
+ }
+
// Get the IV
pk.reset(decypheredPayload, decypheredPayloadOffset);
decypheredPayloadOffset += ivLength;
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs