Author: toad
Date: 2009-01-02 18:00:33 +0000 (Fri, 02 Jan 2009)
New Revision: 24886

Modified:
   trunk/freenet/src/freenet/node/NodeCrypto.java
Log:
Add clientNonce


Modified: trunk/freenet/src/freenet/node/NodeCrypto.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeCrypto.java      2009-01-02 17:22:42 UTC 
(rev 24885)
+++ trunk/freenet/src/freenet/node/NodeCrypto.java      2009-01-02 18:00:33 UTC 
(rev 24886)
@@ -58,6 +58,8 @@
        byte[] identityHash;
        /** Hash of hash of identity i.e. hash of setup key. */
        byte[] identityHashHash;
+       /** Nonce used to generate ?secureid= for fproxy etc */
+       byte[] clientNonce;
        /** My crypto group */
        private DSAGroup cryptoGroup;
        /** My private key */
@@ -231,6 +233,18 @@
                }
                myARK = ark;
                
+               String cn = fs.get("clientNonce");
+               if(cn != null) {
+                       try {
+                               clientNonce = Base64.decode(cn);
+                       } catch (IllegalBase64Exception e) {
+                               throw new IOException("Invalid clientNonce 
field: "+e);
+                       }
+               } else {
+                       clientNonce = new byte[32];
+                       node.random.nextBytes(clientNonce);
+               }
+               
        }
 
        /**
@@ -249,6 +263,8 @@
                myARKNumber = 0;
                SHA256.returnMessageDigest(md);
                anonSetupCipher.initialize(identityHash);
+               clientNonce = new byte[32];
+               node.random.nextBytes(clientNonce);
        }
 
        public void start(boolean disableHangchecker) {
@@ -433,6 +449,7 @@
                // We must save the location!
                if(fs.get("location") == null)
                        fs.put("location", node.lm.getLocation());
+               fs.putSingle("clientNonce", Base64.encode(clientNonce));
                
        }
 

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to