* NetDB: Add hash collision detection

This commit is contained in:
zzz
2012-08-22 17:40:25 +00:00
parent 612fab1b2a
commit 85fbbf8980

View File

@ -676,6 +676,10 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
throw new IllegalArgumentException("Attempt to replace RI with " + leaseSet);
}
// spoof / hash collision detection
if (rv != null && !leaseSet.getDestination().equals(rv.getDestination()))
throw new IllegalArgumentException("LS Hash collision");
String err = validate(key, leaseSet);
if (err != null)
throw new IllegalArgumentException("Invalid store attempt - " + err);
@ -815,6 +819,10 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
throw new IllegalArgumentException("Attempt to replace LS with " + routerInfo);
}
// spoof / hash collision detection
if (rv != null && !routerInfo.getIdentity().equals(rv.getIdentity()))
throw new IllegalArgumentException("RI Hash collision");
String err = validate(key, routerInfo);
if (err != null)
throw new IllegalArgumentException("Invalid store attempt - " + err);