From d2c6a80d24bd8ff83b5d314979c69b354b586c1a Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 13 Oct 2014 16:46:58 +0000 Subject: [PATCH] i2ptunnel: Set default sig type to ECDSA P256 for client tunnel types Standard, IRC, and Socks IRC, if non-shared. --- .../net/i2p/i2ptunnel/TunnelController.java | 12 +++++- .../src/net/i2p/i2ptunnel/web/EditBean.java | 37 +++++++++++++++---- apps/i2ptunnel/jsp/editClient.jsp | 18 +++++---- apps/i2ptunnel/jsp/editServer.jsp | 18 +++++---- history.txt | 4 ++ installer/resources/i2ptunnel.config | 1 + .../src/net/i2p/router/RouterVersion.java | 2 +- 7 files changed, 65 insertions(+), 27 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java index 22c496f10b..5b4b0ba029 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java @@ -71,6 +71,7 @@ public class TunnelController implements Logging { private static final String OPT_BUNDLE_REPLY = PFX_OPTION + "shouldBundleReplyInfo"; private static final String OPT_TAGS_SEND = PFX_OPTION + "crypto.tagsToSend"; private static final String OPT_LOW_TAGS = PFX_OPTION + "crypto.lowTagThreshold"; + private static final String OPT_SIG_TYPE = PFX_OPTION + I2PClient.PROP_SIGTYPE; /** all of these @since 0.9.14 */ public static final String TYPE_CONNECT = "connectclient"; @@ -145,13 +146,13 @@ public class TunnelController implements Logging { try { fos = new SecureFileOutputStream(keyFile); SigType stype = I2PClient.DEFAULT_SIGTYPE; - String st = _config.getProperty(PFX_OPTION + I2PClient.PROP_SIGTYPE); + String st = _config.getProperty(OPT_SIG_TYPE); if (st != null) { SigType type = SigType.parseSigType(st); if (type != null) stype = type; else - log("Unsupported sig type " + st); + log("Unsupported sig type " + st + ", reverting to " + stype); } Destination dest = client.createDestination(fos, stype); String destStr = dest.toBase64(); @@ -584,6 +585,13 @@ public class TunnelController implements Logging { if (!_config.containsKey(OPT_LOW_TAGS)) _config.setProperty(OPT_LOW_TAGS, "14"); } + // same default logic as in EditBean.getSigType() + if ((type.equals(TYPE_IRC_CLIENT) || type.equals(TYPE_STD_CLIENT) || type.equals(TYPE_SOCKS_IRC)) + && !Boolean.valueOf(getSharedClient())) { + if (!_config.containsKey(OPT_SIG_TYPE) && + SigType.ECDSA_SHA256_P256.isAvailable()) + _config.setProperty(OPT_SIG_TYPE, "ECDSA_SHA256_P256"); + } } // tell i2ptunnel, who will tell the TunnelTask, who will tell the SocketManager diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 93ad17c2a7..5217befbea 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -181,14 +181,35 @@ public class EditBean extends IndexBean { return getBooleanProperty(tunnel, "i2cp.encryptLeaseSet"); } - /** @since 0.9.12 */ - public int getSigType(int tunnel) { - String stype = getProperty(tunnel, I2PClient.PROP_SIGTYPE, "0"); - if (stype.equals("0")) - return 0; - SigType type = SigType.parseSigType(stype); - if (type == null) - return 0; + /** + * @param newTunnelType used if tunnel < 0 + * @since 0.9.12 + */ + public int getSigType(int tunnel, String newTunnelType) { + SigType type; + String ttype; + boolean isShared; + if (tunnel >= 0) { + String stype = getProperty(tunnel, I2PClient.PROP_SIGTYPE, null); + type = stype != null ? SigType.parseSigType(stype) : null; + ttype = getTunnelType(tunnel); + isShared = isSharedClient(tunnel); + } else { + type = null; + ttype = newTunnelType; + isShared = false; + } + if (type == null) { + // same default logic as in TunnelController.setConfig() + if ((TunnelController.TYPE_IRC_CLIENT.equals(ttype) || + TunnelController.TYPE_SOCKS_IRC.equals(ttype) || + TunnelController.TYPE_STD_CLIENT.equals(ttype)) && + !isShared && + SigType.ECDSA_SHA256_P256.isAvailable()) + type = SigType.ECDSA_SHA256_P256; + else + type = SigType.DSA_SHA1; + } return type.getCode(); } diff --git a/apps/i2ptunnel/jsp/editClient.jsp b/apps/i2ptunnel/jsp/editClient.jsp index 8fa03c96c4..b4de7872a8 100644 --- a/apps/i2ptunnel/jsp/editClient.jsp +++ b/apps/i2ptunnel/jsp/editClient.jsp @@ -44,8 +44,8 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
<% - String tunnelTypeName = ""; - String tunnelType = ""; + String tunnelTypeName; + String tunnelType; if (curTunnel >= 0) { tunnelTypeName = editBean.getTunnelType(curTunnel); tunnelType = editBean.getInternalType(curTunnel); @@ -491,7 +491,9 @@ input.default { width: 1px; height: 1px; visibility: hidden; }
<% } // if httpclient %> - <% if (true /* editBean.isAdvanced() */ ) { %> + <% if (true /* editBean.isAdvanced() */ ) { + int currentSigType = editBean.getSigType(curTunnel, tunnelType); + %>