Author: toad
Date: 2006-09-20 15:45:31 +0000 (Wed, 20 Sep 2006)
New Revision: 10492
Modified:
trunk/freenet/src/freenet/crypt/DSAPublicKey.java
trunk/freenet/src/freenet/node/PeerNode.java
Log:
Maybe fix an NPE when adding peers.
Modified: trunk/freenet/src/freenet/crypt/DSAPublicKey.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2006-09-20 06:20:11 UTC
(rev 10491)
+++ trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2006-09-20 15:45:31 UTC
(rev 10492)
@@ -29,6 +29,7 @@
this.y=y;
this.yAsHexString = HexUtil.biToHex(y);
this.group=g;
+ if(g == null) throw new NullPointerException();
}
/**
@@ -39,6 +40,7 @@
this.y=new NativeBigInteger(yAsHexString,16);
this.yAsHexString = yAsHexString;
this.group=g;
+ if(g == null) throw new NullPointerException();
}
public DSAPublicKey(DSAGroup g, DSAPrivateKey p) {
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2006-09-20 06:20:11 UTC
(rev 10491)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2006-09-20 15:45:31 UTC
(rev 10492)
@@ -396,7 +396,7 @@
this.peerCryptoGroup = DSAGroup.create(sfs);
sfs = fs.subset("dsaPubKey");
- if(sfs == null)
+ if(sfs == null || peerCryptoGroup == null)
this.peerPubKey = null;
else
this.peerPubKey = DSAPublicKey.create(sfs,
peerCryptoGroup);
@@ -405,7 +405,8 @@
fs.removeValue("sig");
if(!fromLocal){
try{
- if(signature == null || !DSA.verify(peerPubKey,
new DSASignature(signature), new
BigInteger(md.digest(fs.toOrderedString().getBytes("UTF-8"))))){
+ if(signature == null || peerCryptoGroup == null
|| peerPubKey == null ||
+ !DSA.verify(peerPubKey, new
DSASignature(signature), new
BigInteger(md.digest(fs.toOrderedString().getBytes("UTF-8"))))){
Logger.error(this, "The integrity of
the reference has been compromized!");
this.isSignatureVerificationSuccessfull
= false;
if(Version.getArbitraryBuildNumber(version)>970) // TODO: REMOVE: the backward
compat. kludge : version checking