forked from I2P_Developers/i2p.i2p
I2PTunnel, I2CP: Place ECIES first in LS2
Data: Add debug code to ignore LS2 key order
This commit is contained in:
@@ -548,7 +548,7 @@
|
|||||||
ECIES-X25519 (<%=intl._t("Experts only!")%>)</label>
|
ECIES-X25519 (<%=intl._t("Experts only!")%>)</label>
|
||||||
</span>
|
</span>
|
||||||
<span class="multiOption">
|
<span class="multiOption">
|
||||||
<label><input value="0,4" type="radio" id="startOnLoad" name="encType" <%=((has0 && has4) ? " checked=\"checked\"" : "")%> class="tickbox" />
|
<label><input value="4,0" type="radio" id="startOnLoad" name="encType" <%=((has0 && has4) ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||||
<%=intl._t("Both encryption types")%> (<%=intl._t("Experts only!")%>)</label>
|
<%=intl._t("Both encryption types")%> (<%=intl._t("Experts only!")%>)</label>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -857,7 +857,7 @@
|
|||||||
ECIES-X25519 (<%=intl._t("Experts only!")%>)</label>
|
ECIES-X25519 (<%=intl._t("Experts only!")%>)</label>
|
||||||
</span>
|
</span>
|
||||||
<span class="multiOption">
|
<span class="multiOption">
|
||||||
<label><input value="0,4" type="radio" id="startOnLoad" name="encType" <%=((has0 && has4) ? " checked=\"checked\"" : "")%> class="tickbox" />
|
<label><input value="4,0" type="radio" id="startOnLoad" name="encType" <%=((has0 && has4) ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||||
<%=intl._t("Both encryption types")%> (<%=intl._t("Experts only!")%>)</label>
|
<%=intl._t("Both encryption types")%> (<%=intl._t("Experts only!")%>)</label>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
|||||||
private static final String PROP_DH = "i2cp.leaseSetClient.dh.";
|
private static final String PROP_DH = "i2cp.leaseSetClient.dh.";
|
||||||
private static final String PROP_PSK = "i2cp.leaseSetClient.psk.";
|
private static final String PROP_PSK = "i2cp.leaseSetClient.psk.";
|
||||||
|
|
||||||
private static final boolean PREFER_NEW_ENC = false;
|
private static final boolean PREFER_NEW_ENC = true;
|
||||||
|
|
||||||
public RequestLeaseSetMessageHandler(I2PAppContext context) {
|
public RequestLeaseSetMessageHandler(I2PAppContext context) {
|
||||||
this(context, RequestLeaseSetMessage.MESSAGE_TYPE);
|
this(context, RequestLeaseSetMessage.MESSAGE_TYPE);
|
||||||
@@ -243,6 +243,8 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
|||||||
if (senc != null) {
|
if (senc != null) {
|
||||||
if (!PREFER_NEW_ENC && senc.equals("4,0"))
|
if (!PREFER_NEW_ENC && senc.equals("4,0"))
|
||||||
senc = "0,4";
|
senc = "0,4";
|
||||||
|
else if (PREFER_NEW_ENC && senc.equals("0,4"))
|
||||||
|
senc = "4,0";
|
||||||
String[] senca = DataHelper.split(senc, ",");
|
String[] senca = DataHelper.split(senc, ",");
|
||||||
for (String sencaa : senca) {
|
for (String sencaa : senca) {
|
||||||
EncType newtype = EncType.parseEncType(sencaa);
|
EncType newtype = EncType.parseEncType(sencaa);
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ public class LeaseSet2 extends LeaseSet {
|
|||||||
// If this leaseset was formerly blinded, the blinded hash, so we can find it again
|
// If this leaseset was formerly blinded, the blinded hash, so we can find it again
|
||||||
private Hash _blindedHash;
|
private Hash _blindedHash;
|
||||||
|
|
||||||
|
// true for testing
|
||||||
|
private static final boolean IGNORE_SERVER_KEY_PREFERENCE = false;
|
||||||
|
|
||||||
private static final int FLAG_OFFLINE_KEYS = 0x01;
|
private static final int FLAG_OFFLINE_KEYS = 0x01;
|
||||||
private static final int FLAG_UNPUBLISHED = 0x02;
|
private static final int FLAG_UNPUBLISHED = 0x02;
|
||||||
/**
|
/**
|
||||||
@@ -150,9 +153,25 @@ public class LeaseSet2 extends LeaseSet {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PublicKey getEncryptionKey(Set<EncType> supported) {
|
public PublicKey getEncryptionKey(Set<EncType> supported) {
|
||||||
for (PublicKey pk : getEncryptionKeys()) {
|
List<PublicKey> keys = getEncryptionKeys();
|
||||||
if (supported.contains(pk.getType()))
|
if (keys == null)
|
||||||
return pk;
|
return null;
|
||||||
|
if (!IGNORE_SERVER_KEY_PREFERENCE || supported.size() <= 1 || keys.size() <= 1) {
|
||||||
|
// Honor order in LS
|
||||||
|
for (PublicKey pk : keys) {
|
||||||
|
if (supported.contains(pk.getType()))
|
||||||
|
return pk;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Our preference, newest enc type first
|
||||||
|
List<EncType> types = new ArrayList<EncType>(supported);
|
||||||
|
Collections.sort(types, Collections.reverseOrder());
|
||||||
|
for (EncType type : types) {
|
||||||
|
for (PublicKey pk : keys) {
|
||||||
|
if (type == pk.getType())
|
||||||
|
return pk;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user