forked from I2P_Developers/i2p.i2p
i2ptunnel: Set default sig type to ECDSA P256 for client tunnel
types Standard, IRC, and Socks IRC, if non-shared.
This commit is contained in:
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user