diff --git a/apps/i2ptunnel/jsp/editClient.jsi b/apps/i2ptunnel/jsp/editClient.jsi
index 63825aa67..5d12f7360 100644
--- a/apps/i2ptunnel/jsp/editClient.jsi
+++ b/apps/i2ptunnel/jsp/editClient.jsi
@@ -548,7 +548,7 @@
ECIES-X25519 (<%=intl._t("Experts only!")%>)
-
diff --git a/apps/i2ptunnel/jsp/editServer.jsi b/apps/i2ptunnel/jsp/editServer.jsi
index 02fe950c5..b29d378fd 100644
--- a/apps/i2ptunnel/jsp/editServer.jsi
+++ b/apps/i2ptunnel/jsp/editServer.jsi
@@ -857,7 +857,7 @@
ECIES-X25519 (<%=intl._t("Experts only!")%>)
- class="tickbox" />
+ class="tickbox" />
<%=intl._t("Both encryption types")%> (<%=intl._t("Experts only!")%>)
diff --git a/core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java b/core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java
index 03279cba2..3f673b34f 100644
--- a/core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java
+++ b/core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java
@@ -73,7 +73,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
private static final String PROP_DH = "i2cp.leaseSetClient.dh.";
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) {
this(context, RequestLeaseSetMessage.MESSAGE_TYPE);
@@ -243,6 +243,8 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
if (senc != null) {
if (!PREFER_NEW_ENC && senc.equals("4,0"))
senc = "0,4";
+ else if (PREFER_NEW_ENC && senc.equals("0,4"))
+ senc = "4,0";
String[] senca = DataHelper.split(senc, ",");
for (String sencaa : senca) {
EncType newtype = EncType.parseEncType(sencaa);
diff --git a/core/java/src/net/i2p/data/LeaseSet2.java b/core/java/src/net/i2p/data/LeaseSet2.java
index 3c290c080..3df166c0f 100644
--- a/core/java/src/net/i2p/data/LeaseSet2.java
+++ b/core/java/src/net/i2p/data/LeaseSet2.java
@@ -44,6 +44,9 @@ public class LeaseSet2 extends LeaseSet {
// If this leaseset was formerly blinded, the blinded hash, so we can find it again
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_UNPUBLISHED = 0x02;
/**
@@ -150,9 +153,25 @@ public class LeaseSet2 extends LeaseSet {
*/
@Override
public PublicKey getEncryptionKey(Set supported) {
- for (PublicKey pk : getEncryptionKeys()) {
- if (supported.contains(pk.getType()))
- return pk;
+ List keys = getEncryptionKeys();
+ if (keys == null)
+ 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 types = new ArrayList(supported);
+ Collections.sort(types, Collections.reverseOrder());
+ for (EncType type : types) {
+ for (PublicKey pk : keys) {
+ if (type == pk.getType())
+ return pk;
+ }
+ }
}
return null;
}