Author: toad
Date: 2007-10-20 20:13:41 +0000 (Sat, 20 Oct 2007)
New Revision: 15461

Modified:
   trunk/freenet/src/freenet/node/FNPPacketMangler.java
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Move jfkNoncesSent back to PeerNode.
This prevents leaking of nonces relating to peers we no longer care about.
It will also make preventing leaks more generally easier.

Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java        2007-10-20 
20:09:27 UTC (rev 15460)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java        2007-10-20 
20:13:41 UTC (rev 15461)
@@ -122,11 +122,6 @@

        final int fullHeadersLengthMinimum;
        final int fullHeadersLengthOneMessage;
-       /**
-        *  The initiator has to ensure that nonces send back by the
-        *  responder in message2 match what was chosen in message 1
-        */
-       protected final HashMap jfkNoncesSent = new HashMap();


        public FNPPacketMangler(Node node, NodeCrypto crypt, 
PacketSocketHandler sock) {
@@ -517,8 +512,8 @@
                byte[] nonce = new byte[NONCE_SIZE];
                node.random.nextBytes(nonce);

-               synchronized (jfkNoncesSent) {
-                       jfkNoncesSent.put(replyTo, nonce);
+               synchronized (pn) {
+                       pn.jfkNoncesSent.put(replyTo, nonce);
                }

                byte[] message1 = new 
byte[NONCE_SIZE+DiffieHellman.modulusLengthInBytes()];
@@ -656,8 +651,8 @@

                // sanity check
                byte[] myNi = null;
-               synchronized (jfkNoncesSent) {
-                       myNi = (byte[]) jfkNoncesSent.get(replyTo);
+               synchronized (pn) {
+                       myNi = (byte[]) pn.jfkNoncesSent.get(replyTo);
                }
                // We don't except such a message;
                if(myNi == null) {
@@ -984,8 +979,8 @@
                pn.jfkKa = null;
                pn.jfkKe = null;
                pn.jfkKs = null;
-               synchronized (jfkNoncesSent) {
-                       jfkNoncesSent.remove(pn);
+               synchronized (pn) {
+                       pn.jfkNoncesSent.remove(replyTo);
                }

                final long t2=System.currentTimeMillis();

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2007-10-20 20:09:27 UTC 
(rev 15460)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2007-10-20 20:13:41 UTC 
(rev 15461)
@@ -11,6 +11,7 @@
 import java.net.MalformedURLException;
 import java.net.UnknownHostException;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -313,6 +314,13 @@
        /** The node is being disconnected, but it may take a while. */
        private boolean disconnecting;

+       /**
+        * For FNP link setup:
+        *  The initiator has to ensure that nonces send back by the
+        *  responder in message2 match what was chosen in message 1
+        */
+       protected final HashMap jfkNoncesSent = new HashMap();
+       
     private static boolean logMINOR;

     /**


Reply via email to