i2ptunnel: Add ECIES persistent key support

Fix changing enc type on servers
This commit is contained in:
zzz
2020-05-05 14:38:04 +00:00
parent 78effe14ad
commit 4996c05361
4 changed files with 53 additions and 7 deletions

View File

@ -1056,8 +1056,14 @@ public class TunnelController implements Logging {
public String getListenPort() { return _config.getProperty(PROP_LISTEN_PORT); }
public String getTargetDestination() { return _config.getProperty(PROP_DEST); }
public String getProxyList() { return _config.getProperty(PROP_PROXIES); }
/** default true */
public String getSharedClient() { return _config.getProperty(PROP_SHARED, "true"); }
/** default true for clients, always false for servers */
public String getSharedClient() {
if (!isClient())
return "false";
return _config.getProperty(PROP_SHARED, "true");
}
/** default true */
public boolean getStartOnLoad() { return Boolean.parseBoolean(_config.getProperty(PROP_START, "true")); }
public boolean getPersistentClientKey() { return Boolean.parseBoolean(_config.getProperty(OPT_PERSISTENT)); }

View File

@ -15,7 +15,9 @@ import java.util.concurrent.ConcurrentHashMap;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PClient;
import net.i2p.crypto.EncType;
import net.i2p.crypto.KeyGenerator;
import net.i2p.crypto.KeyPair;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
@ -847,14 +849,34 @@ public class TunnelConfig {
SigType type = _dest.getSigType();
SimpleDataStructure keys[] = KeyGenerator.getInstance().generateSigningKeys(type);
config.setProperty(p, type.name() + ':' + keys[1].toBase64());
p = OPT + "i2cp.leaseSetPrivateKey";
keys = KeyGenerator.getInstance().generatePKIKeys();
config.setProperty(p, "ELGAMAL_2048:" + keys[1].toBase64());
// TODO ECIES key
} catch (GeneralSecurityException gse) {
// so much for that
}
}
// persistent LS encryption keys
// multiple types as of 0.9.46, add missing ones
p = OPT + "i2cp.leaseSetPrivateKey";
String skeys = config.getProperty(p);
// normalize it first to make the code below easier
if (skeys != null && skeys.length() > 0 && !skeys.contains(":"))
config.setProperty(p, "ELGAMAL_2048:" + skeys);
String senc = config.getProperty(OPT + "i2cp.leaseSetEncType", "0");
String[] senca = DataHelper.split(senc, ",");
// for each configured enc type, generate a key if we don't have it
for (int i = 0; i < senca.length; i++) {
EncType type = EncType.parseEncType(senca[i]);
if (type != null && type.isAvailable()) {
String stype = type.toString();
skeys = config.getProperty(p, "");
if (!skeys.contains(stype + ':')) {
KeyPair keys = KeyGenerator.getInstance().generatePKIKeys(type);
if (skeys.length() > 0)
config.setProperty(p, skeys + ',' + stype + ':' + keys.getPrivate().toBase64());
else
config.setProperty(p, stype + ':' + keys.getPrivate().toBase64());
}
}
}
}
return config;

View File

@ -1,3 +1,21 @@
2020-05-05 zzz
* Build: Use --java2 for msgfmt
* i2ptunnel:
- Add ECIES persistent key support
- Fix changing enc type on servers
- Remove experts label from dual-key option
* Ratchet: Add padding based on optimal message size
2020-05-04 zzz
* Console: Add log clear buttons (ticket #2449)
* i2ptunnel: Copy over all relevant options to other shared clients
when saving, not just tunnel quantity and length (ticket #1545)
2020-05-02 zzz
* eepsite: Fix RTL issues on Arabic help page (ticket #2731)
* i2ptunnel: Disable I2CP gzip for HTTP server tunnels
* i2psnark: Disable I2CP gzip
2020-05-01 zzz
* Ratchet: Fix NPE ratcheting IB NSR tagset

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";