diff options
| author | J08nY | 2018-10-22 01:28:20 +0200 |
|---|---|---|
| committer | J08nY | 2018-10-22 01:31:33 +0200 |
| commit | 3c6afa46b5fdf4efa9c4a5f2c30494036ddd6604 (patch) | |
| tree | 1bdcc3b778afc03c65b3fc148ca05a1ad8fe87a3 /src | |
| parent | c241bf27a9afc5ac8cb69072f3d732ae1dbf413c (diff) | |
| download | ECTester-3c6afa46b5fdf4efa9c4a5f2c30494036ddd6604.tar.gz ECTester-3c6afa46b5fdf4efa9c4a5f2c30494036ddd6604.tar.zst ECTester-3c6afa46b5fdf4efa9c4a5f2c30494036ddd6604.zip | |
Add methods to parse hash and sig type out of idents.
Diffstat (limited to 'src')
3 files changed, 51 insertions, 4 deletions
diff --git a/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java b/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java index 66d8235..808f298 100644 --- a/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java +++ b/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java @@ -11,6 +11,8 @@ import java.util.List; */ public class KeyAgreementIdent extends Ident { private boolean requiresKeyAlgo; + private String kdf; + private String algo; private static final List<KeyAgreementIdent> ALL = new LinkedList<>(); @@ -73,6 +75,19 @@ public class KeyAgreementIdent extends Ident { private KeyAgreementIdent(String name, String... aliases) { super(name, aliases); + if (name.contains("with")) { + int split = name.indexOf("with"); + this.algo = name.substring(0, split); + this.kdf = name.substring(split + 4); + } else { + for (String alias : aliases) { + if (alias.contains("with")) { + int split = alias.indexOf("with"); + this.algo = alias.substring(0, split); + this.kdf = alias.substring(split + 4); + } + } + } } private KeyAgreementIdent(String name, boolean requiresKeyAlgo, String... aliases) { @@ -84,6 +99,14 @@ public class KeyAgreementIdent extends Ident { return requiresKeyAlgo; } + public String getKdfAlgo() { + return kdf; + } + + public String getBaseAlgo() { + return algo; + } + public KeyAgreement getInstance(Provider provider) throws NoSuchAlgorithmException { KeyAgreement instance = getInstance((algorithm, provider1) -> { try { diff --git a/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java b/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java index 93b7f99..e40731b 100644 --- a/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java +++ b/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java @@ -10,6 +10,9 @@ import java.util.List; * @author Jan Jancar johny@neuromancer.sk */ public class SignatureIdent extends Ident { + private String hash; + private String sig; + private static final List<SignatureIdent> ALL = new LinkedList<>(); static { @@ -53,8 +56,7 @@ public class SignatureIdent extends Ident { ALL.add(new SignatureIdent("GOST3411-2012-512withECGOST3410-2012-512", "GOST3411-2012-512/ECGOST3410-2012-5120", "1.2.643.7.1.1.3.3")); ALL.add(new SignatureIdent("SM3withSM2")); // ECDDSA (rfc6979?) - ALL.add(new SignatureIdent("ECDDSA", "DETECDSA", "ECDETDSA")); - ALL.add(new SignatureIdent("SHA1withECDDSA", "SHA1withDETECDSA")); + ALL.add(new SignatureIdent("ECDDSA", "SHA1withECDDSA", "SHA1withDETECDSA", "DETECDSA", "ECDETDSA")); ALL.add(new SignatureIdent("SHA224withECDDSA", "SHA224withDETECDSA")); ALL.add(new SignatureIdent("SHA256withECDDSA", "SHA256withDETECDSA")); ALL.add(new SignatureIdent("SHA384withECDDSA", "SHA384withDETECDSA")); @@ -92,6 +94,19 @@ public class SignatureIdent extends Ident { private SignatureIdent(String name, String... aliases) { super(name, aliases); + if (name.contains("with")) { + int split = name.indexOf("with"); + this.hash = name.substring(0, split); + this.sig = name.substring(split + 4); + } else { + for (String alias : aliases) { + if (alias.contains("with")) { + int split = alias.indexOf("with"); + this.hash = alias.substring(0, split); + this.sig = alias.substring(split + 4); + } + } + } } public Signature getInstance(Provider provider) throws NoSuchAlgorithmException { @@ -105,4 +120,12 @@ public class SignatureIdent extends Ident { instance.getProvider(); return instance; } + + public String getHashAlgo() { + return hash; + } + + public String getSigType() { + return sig; + } } diff --git a/src/cz/crcs/ectester/standalone/output/TextTestWriter.java b/src/cz/crcs/ectester/standalone/output/TextTestWriter.java index bf9ec7d..d7be4dc 100644 --- a/src/cz/crcs/ectester/standalone/output/TextTestWriter.java +++ b/src/cz/crcs/ectester/standalone/output/TextTestWriter.java @@ -33,10 +33,11 @@ public class TextTestWriter extends BaseTextTestWriter { protected String testableString(Testable t) { if (t instanceof StandaloneTestable) { StandaloneTestable<?> testable = (StandaloneTestable) t; - String stage = testable.getStage().name(); + Enum<?> stage = testable.getStage(); + String stageName = stage.name(); String exception = causeString(testable.getException()); String errorCause = causeString(testable.errorCause()); - return stage + exception + errorCause; + return String.format("[%d/%d] %s %s %s", stage.ordinal() + 1, stage.getClass().getEnumConstants().length, stageName, exception, errorCause); } return ""; } |
