* SigTypes:

- Add isSupportedSince(), use in floodfill selection
  - Handle mixed-case 25519 enum
  - Fix 25519 type code
  - Add dup type code check
This commit is contained in:
zzz
2014-08-22 14:34:13 +00:00
parent 7b64586c87
commit efebecfc67
6 changed files with 72 additions and 27 deletions

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 8;
public final static long BUILD = 9;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -171,21 +171,23 @@ class FloodfillVerifyStoreJob extends JobImpl {
private Hash pickTarget() {
Hash rkey = getContext().routingKeyGenerator().getRoutingKey(_key);
FloodfillPeerSelector sel = (FloodfillPeerSelector)_facade.getPeerSelector();
boolean isKeyCert = false;
Certificate keyCert = null;
if (!_isRouterInfo) {
LeaseSet ls = _facade.lookupLeaseSetLocally(_key);
if (ls != null &&
ls.getDestination().getCertificate().getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY)
isKeyCert = true;
if (ls != null) {
Certificate cert = ls.getDestination().getCertificate();
if (cert.getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY)
keyCert = cert;
}
}
if (isKeyCert) {
if (keyCert != null) {
while (true) {
List<Hash> peers = sel.selectFloodfillParticipants(rkey, 1, _ignore, _facade.getKBuckets());
if (peers.isEmpty())
break;
Hash peer = peers.get(0);
RouterInfo ri = _facade.lookupRouterInfoLocally(peer);
if (ri != null && StoreJob.supportsKeyCerts(ri))
if (ri != null && StoreJob.supportsCert(ri, keyCert))
return peer;
if (_log.shouldLog(Log.INFO))
_log.info(getJobId() + ": Skipping verify w/ router that doesn't support key certs " + peer);

View File

@@ -12,8 +12,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.i2p.crypto.SigType;
import net.i2p.data.Certificate;
import net.i2p.data.DatabaseEntry;
import net.i2p.data.DataFormatException;
import net.i2p.data.Hash;
import net.i2p.data.LeaseSet;
import net.i2p.data.RouterInfo;
@@ -170,8 +172,8 @@ class StoreJob extends JobImpl {
_state.addSkipped(peer);
skipped++;
} else if (_state.getData().getType() == DatabaseEntry.KEY_TYPE_LEASESET &&
((LeaseSet)_state.getData()).getDestination().getCertificate().getCertificateType() == Certificate.CERTIFICATE_TYPE_KEY &&
!supportsKeyCerts((RouterInfo)ds)) {
!supportsCert((RouterInfo)ds,
((LeaseSet)_state.getData()).getDestination().getCertificate())) {
if (_log.shouldLog(Log.INFO))
_log.info(getJobId() + ": Skipping router that doesn't support key certs " + peer);
_state.addSkipped(peer);
@@ -517,17 +519,27 @@ class StoreJob extends JobImpl {
return VersionComparator.comp(v, MIN_ENCRYPTION_VERSION) >= 0;
}
private static final String MIN_KEYCERT_VERSION = "0.9.12";
/**
* Does he support key certs (assumed with a non-DSA key)?
* Does this router understand this cert?
* @return true if not a key cert
* @since 0.9.12
*/
public static boolean supportsKeyCerts(RouterInfo ri) {
public static boolean supportsCert(RouterInfo ri, Certificate cert) {
if (cert.getCertificateType() != Certificate.CERTIFICATE_TYPE_KEY)
return true;
SigType type;
try {
type = cert.toKeyCertificate().getSigType();
} catch (DataFormatException dfe) {
return false;
}
if (type == null)
return false;
String v = ri.getOption("router.version");
if (v == null)
return false;
return VersionComparator.comp(v, MIN_KEYCERT_VERSION) >= 0;
String since = type.getSupportedSince();
return VersionComparator.comp(v, since) >= 0;
}
private static final String MIN_BIGLEASESET_VERSION = "0.9";