I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 71f7c712 authored by zzz's avatar zzz
Browse files

NetDB: Disallow RSA for RI or LS

parent f5f411b6
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,8 @@ import java.util.Arrays; ...@@ -13,6 +13,8 @@ import java.util.Arrays;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.crypto.DSAEngine; import net.i2p.crypto.DSAEngine;
import net.i2p.crypto.SigAlgo;
import net.i2p.crypto.SigType;
/** /**
*<p> *<p>
...@@ -206,6 +208,12 @@ public abstract class DatabaseEntry extends DataStructureImpl { ...@@ -206,6 +208,12 @@ public abstract class DatabaseEntry extends DataStructureImpl {
if (data == null) if (data == null)
return false; return false;
// if the data is non-null the SPK will be non-null // if the data is non-null the SPK will be non-null
return DSAEngine.getInstance().verifySignature(_signature, data, getSigningPublicKey()); SigningPublicKey spk = getSigningPublicKey();
SigType type = spk.getType();
// As of 0.9.28, disallow RSA as it's so slow it could be
// used as a DoS
if (type == null || type.getBaseAlgorithm() == SigAlgo.RSA)
return false;
return DSAEngine.getInstance().verifySignature(_signature, data, spk);
} }
} }
...@@ -19,6 +19,7 @@ import java.util.Iterator; ...@@ -19,6 +19,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import net.i2p.crypto.SigAlgo;
import net.i2p.crypto.SigType; import net.i2p.crypto.SigType;
import net.i2p.data.Certificate; import net.i2p.data.Certificate;
import net.i2p.data.DatabaseEntry; import net.i2p.data.DatabaseEntry;
...@@ -1080,7 +1081,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { ...@@ -1080,7 +1081,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
try { try {
KeyCertificate kc = c.toKeyCertificate(); KeyCertificate kc = c.toKeyCertificate();
SigType type = kc.getSigType(); SigType type = kc.getSigType();
if (type == null || !type.isAvailable()) { if (type == null || !type.isAvailable() || type.getBaseAlgorithm() == SigAlgo.RSA) {
failPermanently(d); failPermanently(d);
String stype = (type != null) ? type.toString() : Integer.toString(kc.getSigTypeCode()); String stype = (type != null) ? type.toString() : Integer.toString(kc.getSigTypeCode());
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment