Author: nextgens
Date: 2007-09-10 08:22:01 +0000 (Mon, 10 Sep 2007)
New Revision: 15112

Modified:
   branches/freenet-jfk/src/freenet/node/FNPPacketMangler.java
   branches/freenet-jfk/src/freenet/node/NodeCrypto.java
Log:
More logical that way

Modified: branches/freenet-jfk/src/freenet/node/FNPPacketMangler.java
===================================================================
--- branches/freenet-jfk/src/freenet/node/FNPPacketMangler.java 2007-09-10 
07:07:45 UTC (rev 15111)
+++ branches/freenet-jfk/src/freenet/node/FNPPacketMangler.java 2007-09-10 
08:22:01 UTC (rev 15112)
@@ -75,7 +75,7 @@
         */
        final Map message3Cache;
        final Map message4Cache;
-       private byte[] transientKey = null;
+       private final byte[] transientKey = new byte[TRANSIENT_KEY_SIZE];;
        private final HashMap authenticatorCache;
        final eKey encryptionKey;
        final DSAGroup g;
@@ -129,6 +129,7 @@
                fullHeadersLengthMinimum = HEADERS_LENGTH_MINIMUM + 
sock.getHeadersLength();
                fullHeadersLengthOneMessage = HEADERS_LENGTH_ONE_MESSAGE + 
sock.getHeadersLength();
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
+               resetTransientKey();
        }

        /**
@@ -2259,13 +2260,6 @@

        private byte[] getTransientKey() {
                synchronized (authenticatorCache) {
-                       if(transientKey == null){
-                               transientKey = new byte[TRANSIENT_KEY_SIZE];
-                               node.random.nextBytes(transientKey);
-
-                               // reset the authenticator cache
-                               authenticatorCache.clear();
-                       }
                        return transientKey;
                }
        }
@@ -2273,7 +2267,10 @@
        //TODO: when shall that be called ? what about DH exponentials ?
        private void resetTransientKey() {
                synchronized (authenticatorCache) {
-                       transientKey = null;
+                       node.random.nextBytes(transientKey);
+
+                       // reset the authenticator cache
+                       authenticatorCache.clear();
                }
        }
 }
\ No newline at end of file

Modified: branches/freenet-jfk/src/freenet/node/NodeCrypto.java
===================================================================
--- branches/freenet-jfk/src/freenet/node/NodeCrypto.java       2007-09-10 
07:07:45 UTC (rev 15111)
+++ branches/freenet-jfk/src/freenet/node/NodeCrypto.java       2007-09-10 
08:22:01 UTC (rev 15112)
@@ -383,7 +383,7 @@
        }

        /** Sign a hash */
-       protected DSASignature sign(byte[] hash) {
+       DSASignature sign(byte[] hash) {
                return DSA.sign(cryptoGroup, privKey, new NativeBigInteger(1, 
hash), random);
        }
         // Sign a hash with a specified PrivateKey


Reply via email to