Author: nextgens
Date: 2008-08-09 10:15:10 +0000 (Sat, 09 Aug 2008)
New Revision: 21682

Modified:
   trunk/freenet/src/freenet/crypt/DiffieHellman.java
   trunk/freenet/src/freenet/node/FNPPacketMangler.java
Log:
JFK:
        - improve logging
        - tweak the size of the signed-exponents cache
        - cut DiffieHellman's exponents cache and generation rate to a 
reasonable value (we don't need more than 1 pair of parameters every 30 sec 
with jfk as it maintains its own caching)

We should have done it sooner: here it reduces node's startup time 
significantly at no cost (memory gain, added security due to the increased size 
of jfk's exponent cache)...

Modified: trunk/freenet/src/freenet/crypt/DiffieHellman.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DiffieHellman.java  2008-08-08 23:21:35 UTC 
(rev 21681)
+++ trunk/freenet/src/freenet/crypt/DiffieHellman.java  2008-08-09 10:15:10 UTC 
(rev 21682)
@@ -6,6 +6,7 @@

 package freenet.crypt;

+import freenet.node.FNPPacketMangler;
 import java.math.BigInteger;
 import java.util.Random;
 import java.util.Stack;
@@ -20,10 +21,10 @@
         * When the number of precalculations falls below this threshold 
generation
         * starts up to make more.
         */
-       private static final int PRECALC_RESUME = 150;
+       private static final int PRECALC_RESUME = 
FNPPacketMangler.DH_CONTEXT_BUFFER_SIZE / 2;

        /** Maximum number of precalculations to create. */
-       private static final int PRECALC_MAX = 300;
+       private static final int PRECALC_MAX = 
FNPPacketMangler.DH_CONTEXT_BUFFER_SIZE * 2;

        /**
         * How often to wake up and make sure the precalculation buffer is full
@@ -119,6 +120,7 @@
                        }

                }
+               Logger.normal(DiffieHellman.class, "DiffieHellman had to 
generate a parameter on thread! (report if that happens often)");
                return genParams();
        }


Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java        2008-08-08 
23:21:35 UTC (rev 21681)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java        2008-08-09 
10:15:10 UTC (rev 21682)
@@ -95,7 +95,7 @@
        /* How often shall we generate a new exponential and add it to the 
FIFO? */
        public final static int DH_GENERATION_INTERVAL = 30000; // 30sec
        /* How big is the FIFO? */
-       public final static int DH_CONTEXT_BUFFER_SIZE = 10;
+       public final static int DH_CONTEXT_BUFFER_SIZE = 20;
        /*
        * The FIFO itself
        * Get a lock on dhContextFIFO before touching it!
@@ -2833,10 +2833,8 @@
                        // reset the authenticator cache
                        authenticatorCache.clear();
                }
-               if(logMINOR)
-                       Logger.minor(this, "Reset the JFK transitent key 
because "+(isCacheTooBig ? ("the cache's capacity is exeeded 
("+authenticatorCache.size()+')') : "it's time to rekey") + this);
                node.getTicker().queueTimedJob(transientKeyRekeyer, 
"JFKmaybeResetTransitentKey "+now, TRANSIENT_KEY_REKEYING_MIN_INTERVAL, false);
-               Logger.normal(this, "JFK's TransientKey has been changed and 
the message cache flushed.");
+               Logger.normal(this, "JFK's TransientKey has been changed and 
the message cache flushed because "+(isCacheTooBig ? ("the cache is oversized 
("+authenticatorCache.size()+')') : "it's time to rekey")+ " on " + this);
                return true;
        }



Reply via email to