[freenet-cvs] r19711 - trunk/freenet/src/freenet/keys
toad at freenetproject.org
toad at freenetproject.org
Sat May 3 18:00:56 UTC 2008
Author: toad
Date: 2008-05-03 18:00:56 +0000 (Sat, 03 May 2008)
New Revision: 19711
Modified:
trunk/freenet/src/freenet/keys/NodeCHK.java
Log:
CHKStore was passing in the routing-key as full-key to store() until r19644.
Therefore, the keys stored in the .keys file may actually be routing-keys rather than full-keys, so CHK recovery may put wrong routing-keys into the datastore index.
Detect this in routingKeyFromFullKey().
Modified: trunk/freenet/src/freenet/keys/NodeCHK.java
===================================================================
--- trunk/freenet/src/freenet/keys/NodeCHK.java 2008-05-03 17:25:26 UTC (rev 19710)
+++ trunk/freenet/src/freenet/keys/NodeCHK.java 2008-05-03 18:00:56 UTC (rev 19711)
@@ -90,6 +90,18 @@
if(keyBuf.length != FULL_KEY_LENGTH) {
Logger.error(NodeCHK.class, "routingKeyFromFullKey() on "+keyBuf.length+" bytes");
}
+ if(keyBuf[0] != 1 || keyBuf[1] != Key.ALGO_AES_PCFB_256_SHA256) {
+ if(keyBuf[keyBuf.length-1] == 0 && keyBuf[keyBuf.length-2] == 0) {
+ // We are certain it's a routing-key
+ Logger.minor(NodeCHK.class, "Recovering routing-key stored wrong as full-key (two nulls at end)");
+ } else {
+ // It might be a routing-key or it might be random data
+ Logger.error(NodeCHK.class, "Maybe recovering routing-key stored wrong as full-key");
+ }
+ byte[] out = new byte[KEY_LENGTH];
+ System.arraycopy(keyBuf, 0, out, 0, KEY_LENGTH);
+ return out;
+ }
byte[] out = new byte[KEY_LENGTH];
System.arraycopy(keyBuf, 2, out, 0, KEY_LENGTH);
return out;
More information about the cvs
mailing list