Util: Add sigtype/enctype help to PKF

remove dead code from SU3File help
This commit is contained in:
zzz
2019-09-17 11:05:48 +00:00
parent 67cd6409a0
commit 0c2a8e9244
2 changed files with 28 additions and 4 deletions

View File

@ -688,8 +688,6 @@ public class SU3File {
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')'); buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
if (t.getCode() == DEFAULT_SIG_CODE) if (t.getCode() == DEFAULT_SIG_CODE)
buf.append(" DEFAULT"); buf.append(" DEFAULT");
if (!t.isAvailable())
buf.append(" UNAVAILABLE");
buf.append('\n'); buf.append('\n');
} }
buf.append("Available content types (-c):\n"); buf.append("Available content types (-c):\n");

View File

@ -12,6 +12,7 @@ import java.io.OutputStreamWriter;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Date; import java.util.Date;
import java.util.EnumSet;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -32,6 +33,7 @@ import net.i2p.crypto.DSAEngine;
import net.i2p.crypto.EncType; import net.i2p.crypto.EncType;
import net.i2p.crypto.KeyGenerator; import net.i2p.crypto.KeyGenerator;
import net.i2p.crypto.KeyPair; import net.i2p.crypto.KeyPair;
import net.i2p.crypto.SigAlgo;
import net.i2p.crypto.SigType; import net.i2p.crypto.SigType;
import net.i2p.util.OrderedProperties; import net.i2p.util.OrderedProperties;
import net.i2p.util.RandomSource; import net.i2p.util.RandomSource;
@ -332,13 +334,13 @@ public class PrivateKeyFile {
private static void usage() { private static void usage() {
System.err.println("Usage: PrivateKeyFile filename (generates if nonexistent, then prints)\n" + System.err.println("Usage: PrivateKeyFile filename (generates if nonexistent, then prints)\n" +
" \ncertificate options:\n" + "\ncertificate options:\n" +
" -h (generates if nonexistent, adds hashcash cert)\n" + " -h (generates if nonexistent, adds hashcash cert)\n" +
" -n (changes to null cert)\n" + " -n (changes to null cert)\n" +
" -s signwithdestfile (generates if nonexistent, adds cert signed by 2nd dest)\n" + " -s signwithdestfile (generates if nonexistent, adds cert signed by 2nd dest)\n" +
" -u (changes to unknown cert)\n" + " -u (changes to unknown cert)\n" +
" -x (changes to hidden cert)\n" + " -x (changes to hidden cert)\n" +
" \nother options:\n" + "\nother options:\n" +
" -a example.i2p (generate addressbook authentication string)\n" + " -a example.i2p (generate addressbook authentication string)\n" +
" -c sigtype (specify sig type of destination)\n" + " -c sigtype (specify sig type of destination)\n" +
" -d days (specify expiration in days of offline sig, default 365)\n" + " -d days (specify expiration in days of offline sig, default 365)\n" +
@ -348,6 +350,30 @@ public class PrivateKeyFile {
" -r sigtype (specify sig type of transient key, default Ed25519)\n" + " -r sigtype (specify sig type of transient key, default Ed25519)\n" +
" -t sigtype (changes to KeyCertificate of the given sig type)\n" + " -t sigtype (changes to KeyCertificate of the given sig type)\n" +
""); "");
StringBuilder buf = new StringBuilder(256);
buf.append("Available signature types:\n");
for (SigType t : EnumSet.allOf(SigType.class)) {
if (!t.isAvailable())
continue;
if (t.getBaseAlgorithm().equals(SigAlgo.RSA))
continue;
if (t.getCode() == 8)
continue;
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
if (t.getCode() == 0)
buf.append(" DEFAULT");
buf.append('\n');
}
buf.append("\nAvailable encryption types:\n");
for (EncType t : EnumSet.allOf(EncType.class)) {
if (!t.isAvailable())
continue;
buf.append(" ").append(t).append("\t(code: ").append(t.getCode()).append(')');
if (t.getCode() == 0)
buf.append(" DEFAULT");
buf.append('\n');
}
System.out.println(buf.toString());
} }
public PrivateKeyFile(String file) { public PrivateKeyFile(String file) {