Author: toad
Date: 2006-04-26 20:08:32 +0000 (Wed, 26 Apr 2006)
New Revision: 8582
Modified:
trunk/freenet/src/freenet/crypt/DSAPrivateKey.java
trunk/freenet/src/freenet/crypt/DSAPublicKey.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/Version.java
Log:
658: Fix pub/priv node key corruption. (#328)
Modified: trunk/freenet/src/freenet/crypt/DSAPrivateKey.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAPrivateKey.java 2006-04-26 19:48:08 UTC
(rev 8581)
+++ trunk/freenet/src/freenet/crypt/DSAPrivateKey.java 2006-04-26 20:08:32 UTC
(rev 8582)
@@ -69,12 +69,13 @@
return fs;
}
- public static DSAPublicKey create(SimpleFieldSet set, DSAGroup group,
boolean base64) throws IllegalBase64Exception {
- NativeBigInteger x =
- new NativeBigInteger(1,
- base64 ? Base64.decode(set.get("x")) :
- HexUtil.hexToBytes(set.get("x")));
- return new DSAPublicKey(group, x);
+ public static DSAPrivateKey create(SimpleFieldSet fs, DSAGroup group,
boolean base64) throws IllegalBase64Exception {
+ NativeBigInteger y = new NativeBigInteger(1,
+ base64 ? Base64.decode(fs.get("x")) :
+ HexUtil.hexToBytes(fs.get("x")));
+ if(y.bitLength() > 512)
+ throw new IllegalBase64Exception("Probably a pubkey");
+ return new DSAPrivateKey(y);
}
// public static void main(String[] args) throws Exception {
Modified: trunk/freenet/src/freenet/crypt/DSAPublicKey.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2006-04-26 19:48:08 UTC
(rev 8581)
+++ trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2006-04-26 20:08:32 UTC
(rev 8582)
@@ -192,10 +192,11 @@
return fs;
}
- public static DSAPrivateKey create(SimpleFieldSet fs, DSAGroup group,
boolean base64) throws IllegalBase64Exception {
- NativeBigInteger y = new NativeBigInteger(1,
- base64 ? Base64.decode(fs.get("y")) :
- HexUtil.hexToBytes(fs.get("y")));
- return new DSAPrivateKey(y);
+ public static DSAPublicKey create(SimpleFieldSet set, DSAGroup group,
boolean base64) throws IllegalBase64Exception {
+ NativeBigInteger x =
+ new NativeBigInteger(1,
+ base64 ? Base64.decode(set.get("y")) :
+ HexUtil.hexToBytes(set.get("y")));
+ return new DSAPublicKey(group, x);
}
}
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-04-26 19:48:08 UTC (rev
8581)
+++ trunk/freenet/src/freenet/node/Node.java 2006-04-26 20:08:32 UTC (rev
8582)
@@ -395,14 +395,18 @@
// FIXME: Back compatibility; REMOVE !!
try {
this.myCryptoGroup = DSAGroup.create(fs.subset("dsaGroup"),
base64);
- this.myPrivKey = DSAPublicKey.create(fs.subset("dsaPubKey"),
myCryptoGroup, base64);
- this.myPubKey = DSAPrivateKey.create(fs.subset("dsaPrivKey"),
myCryptoGroup, base64);
+ this.myPrivKey = DSAPrivateKey.create(fs.subset("dsaPrivKey"),
myCryptoGroup, base64);
+ this.myPubKey = DSAPublicKey.create(fs.subset("dsaPubKey"),
myCryptoGroup, base64);
} catch (NullPointerException e) {
+ Logger.minor(this, "Caught "+e, e);
this.myCryptoGroup = Global.DSAgroupBigA;
this.myPrivKey = new DSAPrivateKey(myCryptoGroup, r);
this.myPubKey = new DSAPublicKey(myCryptoGroup, myPrivKey);
} catch (IllegalBase64Exception e) {
- throw new IOException();
+ Logger.minor(this, "Caught "+e, e);
+ this.myCryptoGroup = Global.DSAgroupBigA;
+ this.myPrivKey = new DSAPrivateKey(myCryptoGroup, r);
+ this.myPubKey = new DSAPublicKey(myCryptoGroup, myPrivKey);
}
wasTestnet = Fields.stringToBool(fs.get("testnet"), false);
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-04-26 19:48:08 UTC (rev
8581)
+++ trunk/freenet/src/freenet/node/Version.java 2006-04-26 20:08:32 UTC (rev
8582)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 657;
+ private static final int buildNumber = 658;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 591;