From dd2d9ecc725796c5c590fe56b16cc86f3a595cd7 Mon Sep 17 00:00:00 2001 From: Martin Paljak Date: Wed, 27 Jan 2016 17:04:15 +0200 Subject: [PATCH] Remove things --- src/org/esteid/EstEID.java | 16 ++++++++-------- src/org/esteid/hacker/CLI.java | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/org/esteid/EstEID.java b/src/org/esteid/EstEID.java index c51c344..8a1da3b 100644 --- a/src/org/esteid/EstEID.java +++ b/src/org/esteid/EstEID.java @@ -48,6 +48,7 @@ // Instance of this class keeps state and throws EstEIDException if the response from card is not what it is supposed to be. // Static methods can be used in a stateless manner. // Methods throw CardException if card communication fails. +// This class requires some love. public final class EstEID { // Commands @@ -192,7 +193,6 @@ public static enum CardType { // Instance fields private CardChannel channel = null; private CardType type = null; - protected boolean strict = true; private int currentFID = FID_3F00; private EstEID(CardChannel c) { @@ -524,9 +524,9 @@ public String toString() { } public void crypto_tests(String pin1, String pin2) throws WrongPINException, CardException { - Map pins = getPINCounters(); - if (strict && (pins.get(PIN1) < 3 || pins.get(PIN2) < 3)) { - throw new RuntimeException("Will not run crypto tests on a card with not-known or blocked PINs!"); + Map retries = getPINCounters(); + if (retries.get(PIN1) < 3 || retries.get(PIN2) < 3) { + throw new IllegalStateException("Will not run crypto tests on a card with not-known or blocked PINs!"); } System.out.println("Testing certificates and crypto ..."); @@ -583,15 +583,15 @@ static String make_random_pin(int len) { try { return hex2numbers(new BigInteger(len*8, SecureRandom.getInstanceStrong()).toString(16)).substring(0, len); } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); + throw new RuntimeException("Bad environment", e); } } public void pin_tests(String pin1, String pin2, String puk) throws CardException, WrongPINException { - Map pins = getPINCounters(); - if (strict && (pins.get(PIN1) < 3 || pins.get(PIN2) < 3 || pins.get(PUK) < 3)) { - throw new RuntimeException("Will not run pin tests on a card with not-known or blocked PINs!"); + Map retries = getPINCounters(); + if (retries.get(PIN1) < 3 || retries.get(PIN2) < 3 || retries.get(PUK) < 3) { + throw new IllegalStateException("Will not run pin tests on a card with not-known or blocked PINs!"); } System.out.println("Testing PIN codes ..."); String newpin1 = make_random_pin(4); diff --git a/src/org/esteid/hacker/CLI.java b/src/org/esteid/hacker/CLI.java index dd77b9d..51f9093 100644 --- a/src/org/esteid/hacker/CLI.java +++ b/src/org/esteid/hacker/CLI.java @@ -54,7 +54,6 @@ import org.esteid.EstEID.CardType; import org.esteid.EstEID.PIN; import org.esteid.EstEID.PersonalData; -import org.esteid.applet.FakeEstEID; import pro.javacard.gp.GlobalPlatform; import pro.javacard.vre.VJCREProvider; @@ -68,7 +67,6 @@ public class CLI { private static final String OPT_DEBUG = "debug"; private static final String OPT_VERBOSE = "verbose"; private static final String OPT_INFO = "info"; - private static final String OPT_RELAX = "relax"; private static final String OPT_CA = "ca"; private static final String OPT_RESIGN = "resign"; @@ -113,8 +111,6 @@ private static OptionSet parseArguments(String argv[]) throws IOException { parser.acceptsAll(Arrays.asList("i", OPT_INFO), "Show information about the EstEID token"); parser.acceptsAll(Arrays.asList("l", OPT_LIST), "List connected tokens"); - parser.accepts(OPT_RELAX, "Relax some checks"); - // FakeEstEIDManagerCA interface parser.accepts(OPT_CA, "Use or generate a CA").withRequiredArg().ofType(File.class); parser.accepts(OPT_RESIGN, "Re-sign cert (PEM) with CA").withRequiredArg().ofType(File.class);