Author: toad
Date: 2007-04-18 18:55:52 +0000 (Wed, 18 Apr 2007)
New Revision: 12786
Modified:
trunk/freenet/src/freenet/node/PeerNode.java
Log:
Refactor: keep identityHashHash
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2007-04-18 18:53:51 UTC
(rev 12785)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2007-04-18 18:55:52 UTC
(rev 12786)
@@ -168,9 +168,12 @@
*/
final byte[] identity;
- /** Hash of node identity. Used as setup key. */
+ /** Hash of node identity. Used in setup key. */
final byte[] identityHash;
+ /** Hash of hash of node identity. Used in setup key. */
+ final byte[] identityHashHash;
+
/** Negotiation types supported */
int[] negTypes;
@@ -357,6 +360,7 @@
if(identity == null) throw new FSParseException("No identity");
identityHash = SHA256.digest(identity);
+ identityHashHash = SHA256.digest(identityHash);
hashCode = Fields.hashCode(identityHash);
version = fs.get("version");
Version.seenVersion(version);
@@ -461,12 +465,11 @@
// Setup incoming and outgoing setup ciphers
byte[] nodeKey = node.identityHash;
byte[] nodeKeyHash = node.identityHashHash;
- byte[] setupKeyHash = SHA256.digest(identityHash);
int digestLength = SHA256.getDigestLength();
incomingSetupKey = new byte[digestLength];
for(int i=0;i<incomingSetupKey.length;i++)
- incomingSetupKey[i] = (byte) (nodeKey[i] ^ setupKeyHash[i]);
+ incomingSetupKey[i] = (byte) (nodeKey[i] ^ identityHashHash[i]);
outgoingSetupKey = new byte[digestLength];
for(int i=0;i<outgoingSetupKey.length;i++)
outgoingSetupKey[i] = (byte) (nodeKeyHash[i] ^ identityHash[i]);
@@ -476,7 +479,7 @@
"\nNode: "+HexUtil.bytesToHex(nodeKey)+
"\nNode hash: "+HexUtil.bytesToHex(nodeKeyHash)+
"\nThis:
"+HexUtil.bytesToHex(identityHash)+
- "\nThis hash:
"+HexUtil.bytesToHex(setupKeyHash)+
+ "\nThis hash:
"+HexUtil.bytesToHex(identityHashHash)+
"\nFor: "+getPeer());
try {