I2CP: Basic router-side handling of meta LS2

Improve error handling of LS2 params client-side
Methods to remember blinded key in LS2
This commit is contained in:
zzz
2019-01-10 13:39:18 +00:00
parent 8cd7e7de65
commit 0d330caf9a
4 changed files with 73 additions and 31 deletions

View File

@@ -103,6 +103,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
return true;
} catch (NumberFormatException nfe) {
session.propogateError("Bad LS2 type", nfe);
session.destroySession();
return true;
}
}
@@ -124,6 +125,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
leaseSet = new MetaLeaseSet();
} else {
session.propogateError("Unsupported LS2 type", new Exception());
session.destroySession();
return;
}
} else {
@@ -284,7 +286,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
session.getOfflineSignature());
if (!ok) {
session.propogateError("Bad offline signature", new Exception());
// TODO just let the router handle it for now
session.destroySession();
}
}
try {
@@ -306,6 +308,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
_log.debug("Created and signed LeaseSet: " + leaseSet);
} catch (DataFormatException dfe) {
session.propogateError("Error signing the leaseSet", dfe);
session.destroySession();
} catch (I2PSessionException ise) {
if (session.isClosed()) {
// race, closed while signing leaseset

View File

@@ -50,6 +50,7 @@ class RequestVariableLeaseSetMessageHandler extends RequestLeaseSetMessageHandle
leaseSet = new MetaLeaseSet();
} else {
session.propogateError("Unsupported LS2 type", new Exception());
session.destroySession();
return;
}
} else {

View File

@@ -39,6 +39,8 @@ public class LeaseSet2 extends LeaseSet {
protected Properties _options;
// only used if more than one key, otherwise null
private List<PublicKey> _encryptionKeys;
// If this leaseset was formerly blinded, the blinded hash, so we can find it again
private Hash _blindedHash;
private static final int FLAG_OFFLINE_KEYS = 1;
private static final int FLAG_UNPUBLISHED = 2;
@@ -182,6 +184,21 @@ public class LeaseSet2 extends LeaseSet {
return ctx.dsa().verifySignature(_offlineSignature, data, 0, data.length, getSigningPublicKey());
}
/**
* Set this on creation if known
*/
public void setBlindedHash(Hash bh) {
_blindedHash = bh;
}
/**
* The orignal blinded hash, where this came from.
* @return null if unknown or not previously blinded
*/
public Hash getBlindedHash() {
return _blindedHash;
}
///// overrides below here