store ls secret as b64

This commit is contained in:
zzz
2019-05-29 11:53:55 +00:00
parent 973aab8f53
commit a3fe7467c3
4 changed files with 12 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import net.i2p.I2PAppContext;
import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
@ -596,7 +597,12 @@ public class GeneralHelper {
* @since 0.9.40
*/
public String getBlindedPassword(int tunnel) {
return getProperty(tunnel, "i2cp.leaseSetSecret", "");
String rv = getProperty(tunnel, "i2cp.leaseSetSecret", null);
if (rv != null)
rv = DataHelper.getUTF8(Base64.decode(rv));
if (rv == null)
rv = "";
return rv;
}
/**

View File

@ -277,7 +277,7 @@ public class TunnelConfig {
/** @since 0.9.40 */
public void setBlindedPassword(String s) {
if (s != null && s.length() > 0)
_otherOptions.put("i2cp.leaseSetSecret", s);
_otherOptions.put("i2cp.leaseSetSecret", Base64.encode(DataHelper.getUTF8(s.trim())));
else
_otherOptions.remove("i2cp.leaseSetSecret");
}

View File

@ -132,8 +132,10 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
} else if (_ls2Type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
EncryptedLeaseSet encls2 = new EncryptedLeaseSet();
String secret = session.getOptions().getProperty(PROP_SECRET);
if (secret != null)
if (secret != null) {
secret = DataHelper.getUTF8(Base64.decode(secret));
encls2.setSecret(secret);
}
leaseSet = encls2;
} else if (_ls2Type == DatabaseEntry.KEY_TYPE_META_LS2) {
leaseSet = new MetaLeaseSet();

View File

@ -655,6 +655,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
String secret = cfg.getOptions().getProperty("i2cp.leaseSetSecret");
if (secret != null) {
EncryptedLeaseSet encls = (EncryptedLeaseSet) ls;
secret = DataHelper.getUTF8(Base64.decode(secret));
encls.setSecret(secret);
}
}