I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit aacdba1b authored by zzz's avatar zzz
Browse files

KeyGenerator: main() test improvements

Allow specification of sig types on command line
parent c28d060d
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,9 @@ import java.security.spec.ECPublicKeySpec; ...@@ -26,6 +26,9 @@ import java.security.spec.ECPublicKeySpec;
import java.security.spec.EllipticCurve; import java.security.spec.EllipticCurve;
import java.security.spec.RSAKeyGenParameterSpec; import java.security.spec.RSAKeyGenParameterSpec;
import java.security.spec.RSAPublicKeySpec; import java.security.spec.RSAPublicKeySpec;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.crypto.eddsa.EdDSAPrivateKey; import net.i2p.crypto.eddsa.EdDSAPrivateKey;
...@@ -334,6 +337,9 @@ public class KeyGenerator { ...@@ -334,6 +337,9 @@ public class KeyGenerator {
} }
} }
/**
* Usage: KeyGenerator [sigtype...]
*/
public static void main(String args[]) { public static void main(String args[]) {
try { try {
main2(args); main2(args);
...@@ -342,14 +348,35 @@ public class KeyGenerator { ...@@ -342,14 +348,35 @@ public class KeyGenerator {
} }
} }
public static void main2(String args[]) { /**
* Usage: KeyGenerator [sigtype...]
*/
private static void main2(String args[]) {
RandomSource.getInstance().nextBoolean(); RandomSource.getInstance().nextBoolean();
try { Thread.sleep(1000); } catch (InterruptedException ie) {} try { Thread.sleep(1000); } catch (InterruptedException ie) {}
int runs = 200; // warmup int runs = 200; // warmup
Collection<SigType> toTest;
if (args.length > 0) {
toTest = new ArrayList<SigType>();
for (int i = 0; i < args.length; i++) {
SigType type = SigType.parseSigType(args[i]);
if (type != null)
toTest.add(type);
else
System.out.println("Unknown type: " + args[i]);
}
if (toTest.isEmpty()) {
System.out.println("No types to test");
return;
}
} else {
toTest = Arrays.asList(SigType.values());
}
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
for (SigType type : SigType.values()) { for (SigType type : toTest) {
if (!type.isAvailable()) { if (!type.isAvailable()) {
System.out.println("Skipping unavailable: " + type); System.out.println("Skipping unavailable: " + type);
continue;
} }
try { try {
System.out.println("Testing " + type); System.out.println("Testing " + type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment