Router: Fix persistence of blinded privkey and timestamp

This commit is contained in:
zzz
2019-05-31 13:17:30 +00:00
parent 67224858b7
commit b4f331e621
2 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,7 @@
package net.i2p.data; package net.i2p.data;
import java.util.Date;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.crypto.Blinding; import net.i2p.crypto.Blinding;
import net.i2p.crypto.SigType; import net.i2p.crypto.SigType;
@ -25,6 +27,7 @@ public class BlindData {
private long _routingKeyGenMod; private long _routingKeyGenMod;
private boolean _secretRequired; private boolean _secretRequired;
private boolean _authRequired; private boolean _authRequired;
private long _date;
/** /**
* bits 3-0 including per-client bit * bits 3-0 including per-client bit
@ -94,6 +97,7 @@ public class BlindData {
_secretRequired = true; _secretRequired = true;
if (authKey != null) if (authKey != null)
_authRequired = true; _authRequired = true;
_date = _context.clock().now();
// defer until needed // defer until needed
//calculate(); //calculate();
} }
@ -244,6 +248,21 @@ public class BlindData {
return _authRequired; return _authRequired;
} }
/**
* @since 0.9.41
*/
public void setDate(long date) {
_date = date;
}
/**
* @return creation date or as overridden by setDate()
* @since 0.9.41
*/
public long getDate() {
return _date;
}
@Override @Override
public synchronized String toString() { public synchronized String toString() {
calculate(); calculate();
@ -271,6 +290,7 @@ public class BlindData {
else else
buf.append("\n\tDestination : unknown"); buf.append("\n\tDestination : unknown");
buf.append("\n\tB32 : ").append(toBase32()); buf.append("\n\tB32 : ").append(toBase32());
buf.append("\n\tCreated : ").append((new Date(_date)).toString());
buf.append(']'); buf.append(']');
return buf.toString(); return buf.toString();
} }

View File

@ -380,15 +380,15 @@ class BlindCache {
privkey = null; privkey = null;
} }
BlindData rv; BlindData rv;
// TODO pass privkey
if (ss[7].length() > 0) { if (ss[7].length() > 0) {
Destination dest = new Destination(ss[7]); Destination dest = new Destination(ss[7]);
if (!spk.equals(dest.getSigningPublicKey())) if (!spk.equals(dest.getSigningPublicKey()))
throw new DataFormatException("spk mismatch"); throw new DataFormatException("spk mismatch");
rv = new BlindData(_context, dest, st2, secret); rv = new BlindData(_context, dest, st2, secret, auth, privkey);
} else { } else {
rv = new BlindData(_context, spk, st2, secret); rv = new BlindData(_context, spk, st2, secret, auth, privkey);
} }
rv.setDate(time);
return rv; return rv;
} }
@ -402,8 +402,7 @@ class BlindCache {
buf.append(spk.getType().getCode()).append(','); buf.append(spk.getType().getCode()).append(',');
buf.append(bd.getBlindedSigType().getCode()).append(','); buf.append(bd.getBlindedSigType().getCode()).append(',');
buf.append(bd.getAuthType()).append(','); buf.append(bd.getAuthType()).append(',');
// timestamp todo buf.append(bd.getDate()).append(',');
buf.append('0').append(',');
buf.append(spk.toBase64()).append(','); buf.append(spk.toBase64()).append(',');
String secret = bd.getSecret(); String secret = bd.getSecret();
if (secret != null && secret.length() > 0) if (secret != null && secret.length() > 0)