diff options
| author | J08nY | 2017-12-27 18:29:52 +0100 |
|---|---|---|
| committer | J08nY | 2017-12-27 18:29:52 +0100 |
| commit | f40db310cdb28d39e1bb050e9adb920f4b35a8ed (patch) | |
| tree | d4a97d56aa5bf274569fe0cf1aa9645a6ebe9d31 /src/cz/crcs/ectester/common | |
| parent | 71006eb01c60b3556b620b7d4579d65ed6f86926 (diff) | |
| download | ECTester-f40db310cdb28d39e1bb050e9adb920f4b35a8ed.tar.gz ECTester-f40db310cdb28d39e1bb050e9adb920f4b35a8ed.tar.zst ECTester-f40db310cdb28d39e1bb050e9adb920f4b35a8ed.zip | |
Cleanup the applet ECKA and Signature objects.
Diffstat (limited to '')
| -rw-r--r-- | src/cz/crcs/ectester/common/ec/EC_KAResult.java | 18 | ||||
| -rw-r--r-- | src/cz/crcs/ectester/common/output/BaseTextTestWriter.java | 2 | ||||
| -rw-r--r-- | src/cz/crcs/ectester/common/util/CardUtil.java | 52 |
3 files changed, 47 insertions, 25 deletions
diff --git a/src/cz/crcs/ectester/common/ec/EC_KAResult.java b/src/cz/crcs/ectester/common/ec/EC_KAResult.java index a7b3cd5..8a5fcb4 100644 --- a/src/cz/crcs/ectester/common/ec/EC_KAResult.java +++ b/src/cz/crcs/ectester/common/ec/EC_KAResult.java @@ -8,15 +8,14 @@ import cz.crcs.ectester.common.util.CardUtil; * @author Jan Jancar johny@neuromancer.sk */ public class EC_KAResult extends EC_Data { - - private byte ka; + private String ka; private String curve; private String oneKey; private String otherKey; private String desc; - public EC_KAResult(byte ka, String curve, String oneKey, String otherKey) { + public EC_KAResult(String ka, String curve, String oneKey, String otherKey) { super(1); this.ka = ka; this.curve = curve; @@ -24,20 +23,24 @@ public class EC_KAResult extends EC_Data { this.otherKey = otherKey; } - public EC_KAResult(String id, byte ka, String curve, String oneKey, String otherKey) { + public EC_KAResult(String id, String ka, String curve, String oneKey, String otherKey) { this(ka, curve, oneKey, otherKey); this.id = id; } - public EC_KAResult(String id, byte ka, String curve, String oneKey, String otherKey, String desc) { + public EC_KAResult(String id, String ka, String curve, String oneKey, String otherKey, String desc) { this(id, ka, curve, oneKey, otherKey); this.desc = desc; } - public byte getKA() { + public String getKA() { return ka; } + public byte getJavaCardKA() { + return CardUtil.getKA(ka); + } + public String getCurve() { return curve; } @@ -56,8 +59,7 @@ public class EC_KAResult extends EC_Data { @Override public String toString() { - String algo = CardUtil.getKA(ka); - return "<" + getId() + "> " + algo + " result over " + curve + ", " + oneKey + " + " + otherKey + (desc == null ? "" : ": " + desc); + return "<" + getId() + "> " + ka + " result over " + curve + ", " + oneKey + " + " + otherKey + (desc == null ? "" : ": " + desc); } } diff --git a/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java b/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java index 9635d0c..7e0e1a3 100644 --- a/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java +++ b/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java @@ -10,7 +10,7 @@ import java.io.PrintStream; public abstract class BaseTextTestWriter implements TestWriter { private PrintStream output; - public static int BASE_WIDTH = 76; + public static int BASE_WIDTH = 80; public BaseTextTestWriter(PrintStream output) { this.output = output; diff --git a/src/cz/crcs/ectester/common/util/CardUtil.java b/src/cz/crcs/ectester/common/util/CardUtil.java index edcb510..55c4277 100644 --- a/src/cz/crcs/ectester/common/util/CardUtil.java +++ b/src/cz/crcs/ectester/common/util/CardUtil.java @@ -12,6 +12,18 @@ import static cz.crcs.ectester.applet.ECTesterApplet.*; * @author Jan Jancar johny@neuromancer.sk */ public class CardUtil { + public static byte getKA(String name) { + switch (name) { + case "DH": + case "ECDH": + return ECTesterApplet.KeyAgreement_ALG_EC_SVDP_DH; + case "DHC": + case "ECDHC": + return ECTesterApplet.KeyAgreement_ALG_EC_SVDP_DHC; + } + return ECTesterApplet.KeyAgreement_ALG_EC_SVDP_DH; + } + public static String getSWSource(short sw) { switch (sw) { case ISO7816.SW_NO_ERROR: @@ -214,22 +226,6 @@ public class CardUtil { return corrupt; } - public static String getKA(byte ka) { - String algo = ""; - if ((ka & EC_Consts.KA_ECDH) != 0 || ka == EC_Consts.KA_ANY) { - algo += "ECDH"; - } - if (ka == EC_Consts.KA_BOTH) { - algo += "+"; - } else if (ka == EC_Consts.KA_ANY) { - algo += "/"; - } - if ((ka & EC_Consts.KA_ECDHC) != 0 || ka == EC_Consts.KA_ANY) { - algo += "ECDHC"; - } - return algo; - } - public static String getKATypeString(byte kaType) { String kaTypeString; switch (kaType) { @@ -256,4 +252,28 @@ public class CardUtil { } return kaTypeString; } + + public static String getSigTypeString(byte sigType) { + String sigTypeString; + switch (sigType) { + case Signature_ALG_ECDSA_SHA: + sigTypeString = "ALG_ECDSA_SHA"; + break; + case Signature_ALG_ECDSA_SHA_224: + sigTypeString = "ALG_ECDSA_SHA_224"; + break; + case Signature_ALG_ECDSA_SHA_256: + sigTypeString = "ALG_ECDSA_SHA_256"; + break; + case Signature_ALG_ECDSA_SHA_384: + sigTypeString = "ALG_ECDSA_SHA_384"; + break; + case Signature_ALG_ECDSA_SHA_512: + sigTypeString = "ALG_ECDSA_SHA_512"; + break; + default: + sigTypeString = "unknown"; + } + return sigTypeString; + } } |
