NetDB: Persistence for blinding cache

This commit is contained in:
zzz
2019-03-29 12:50:41 +00:00
parent ba801be24f
commit eb0920e2c7
3 changed files with 199 additions and 10 deletions

View File

@ -218,6 +218,7 @@ public final class Blinding {
* PRELIMINARY - Subject to change - see proposal 149
*
* @param b 35+ bytes
* @return BlindData structure, use getUnblindedPubKey() for the result
* @throws IllegalArgumentException on bad inputs
* @throws UnsupportedOperationException unless supported SigTypes
* @since 0.9.40
@ -313,6 +314,15 @@ public final class Blinding {
return Base32.encode(b) + ".b32.i2p";
}
public static void main(String args[]) throws Exception {
if (args.length != 1) {
System.out.println("Usage: blinding {56 chars}.b32.i2p");
System.exit(1);
}
System.out.println("Blinded B32: " + args[0]);
System.out.println(decode(I2PAppContext.getGlobalContext(), args[0]).toString());
}
/******
public static void main(String args[]) throws Exception {
net.i2p.data.SimpleDataStructure[] keys = KeyGenerator.getInstance().generateSigningKeys(TYPE);

View File

@ -42,7 +42,7 @@ public class BlindData {
_clearSPK = spk;
_blindType = blindType;
_secret = secret;
_authType = 0;
_authType = -1;
_authKey = null;
// defer until needed
//calculate();
@ -55,6 +55,13 @@ public class BlindData {
return _clearSPK;
}
/**
* @return The type of the blinded key
*/
public SigType getBlindedSigType() {
return _blindType;
}
/**
* @return The blinded key for the current day, non-null
*/
@ -115,12 +122,19 @@ public class BlindData {
}
/**
* @return 0 for no client auth
* @return -1 for no client auth
*/
public int getAuthType() {
return _authType;
}
/**
* @return null for no client auth
*/
public PrivateKey getAuthPrivKey() {
return _authKey;
}
private synchronized void calculate() {
if (_context.isRouterContext()) {
RoutingKeyGenerator gen = _context.routingKeyGenerator();
@ -147,16 +161,24 @@ public class BlindData {
@Override
public synchronized String toString() {
calculate();
StringBuilder buf = new StringBuilder(256);
StringBuilder buf = new StringBuilder(1024);
buf.append("[BlindData: ");
buf.append("\n\tSigningPublicKey: ").append(_clearSPK);
buf.append("\n\tAlpha : ").append(_alpha);
buf.append("\n\tBlindedPublicKey: ").append(_blindSPK);
buf.append("\n\tBlinded Hash : ").append(_blindHash);
buf.append("\n\tSecret: ").append(_secret);
if (_secret != null)
buf.append("\n\tSecret : \"").append(_secret).append('"');
buf.append("\n\tAuth Type : ");
if (_authType >= 0)
buf.append(_authType);
else
buf.append("none");
if (_authKey != null)
buf.append("\n\tAuth Key : ").append(_authKey);
if (_dest != null)
buf.append("\n\tDestination: ").append(_dest);
if (_dest != null)
else
buf.append("\n\tDestination: unknown");
buf.append(']');
return buf.toString();