From 5097e783310242cfb782c62d84d65a4b3a387a72 Mon Sep 17 00:00:00 2001 From: J08nY Date: Sun, 11 Feb 2018 03:04:40 +0100 Subject: Allow outputing test suite results into more formats and files. --- .../ectester/reader/output/FileTestWriter.java | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/cz/crcs/ectester/reader/output/FileTestWriter.java (limited to 'src/cz/crcs/ectester/reader/output/FileTestWriter.java') diff --git a/src/cz/crcs/ectester/reader/output/FileTestWriter.java b/src/cz/crcs/ectester/reader/output/FileTestWriter.java new file mode 100644 index 0000000..6cfece1 --- /dev/null +++ b/src/cz/crcs/ectester/reader/output/FileTestWriter.java @@ -0,0 +1,54 @@ +package cz.crcs.ectester.reader.output; + +import cz.crcs.ectester.common.output.TeeTestWriter; +import cz.crcs.ectester.common.output.TestWriter; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.util.regex.Pattern; + +/** + * @author Jan Jancar johny@neuromancer.sk + */ +public class FileTestWriter extends TeeTestWriter { + + private static final Pattern PREFIX = Pattern.compile("(text|xml|yaml|yml):.+"); + + public FileTestWriter(String defaultFormat, boolean systemOut, String[] files) throws ParserConfigurationException, FileNotFoundException { + int fLength = files == null ? 0 : files.length; + writers = new TestWriter[systemOut ? fLength + 1 : fLength]; + System.err.println(writers.length); + if (systemOut) { + writers[0] = createWriter(defaultFormat, System.out); + } + for (int i = 0; i < fLength; ++i) { + String fName = files[i]; + String format = null; + if (PREFIX.matcher(fName).matches()) { + String[] split = fName.split(":",2); + format = split[0]; + fName = split[1]; + } + writers[i + 1] = createWriter(format, new PrintStream(new FileOutputStream(fName))); + } + } + + private TestWriter createWriter(String format, PrintStream out) throws ParserConfigurationException { + if (format == null) { + return new TextTestWriter(out); + } + switch (format) { + case "text": + return new TextTestWriter(out); + case "xml": + return new XMLTestWriter(out); + case "yaml": + case "yml": + return new YAMLTestWriter(out); + default: + return null; + } + } +} -- cgit v1.3.1 From 30e29e6244aad9e28aacb187d6e2bc1f44ed322c Mon Sep 17 00:00:00 2001 From: J08nY Date: Sat, 3 Mar 2018 20:03:04 +0100 Subject: Add information about more output files for a test run. --- README.md | 19 +++++++++++++++++-- docs/FORMAT.md | 6 +++++- .../crcs/ectester/reader/output/FileTestWriter.java | 1 - 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/cz/crcs/ectester/reader/output/FileTestWriter.java') diff --git a/README.md b/README.md index 1af8a21..c34da5d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build status](https://api.travis-ci.org/crocs-muni/ECTester.svg?branch=master)](https://travis-ci.org/crocs-muni/ECTester) [![GitHub release](https://img.shields.io/github/release/crocs-muni/ECTEster.svg)](https://github.com/crocs-muni/ECTester/releases) [![license](https://img.shields.io/github/license/crocs-muni/ECTester.svg)](https://github.com/crocs-muni/ECTester/blob/master/LICENSE) [![docs](https://img.shields.io/badge/docs-github.io-brightgreen.svg)](https://crocs-muni.github.io/ECTester/) Tests support and behavior of elliptic curve cryptography implementations on JavaCards (`TYPE_EC_FP` and `TYPE_EC_F2M`) and on selected software libraries. -For more information on ECC support on JavaCards see the [github page](https://crocs-muni.github.io/ECTester/). +For more information on ECC support on JavaCards see the [github page](https://crocs-muni.github.io/ECTester/), with results, tables and docs. ## Build @@ -106,6 +106,8 @@ For format of this file see [FORMAT](docs/FORMAT.md). Perform support and performance tests of ECC. +Use with `-o / --output [out_type:]` to output the test results to a file. +For possible formats of this file see [FORMAT](docs/FORMAT.md). For more info about the test suites see [TESTS](docs/TESTS.md). #### Generate @@ -206,6 +208,19 @@ Currently supported libraries include: For more information on ECC libraries see [LIBS](docs/LIBS.md). +### Setup + +Installing the Java Cryptography Extension Unlimited Strength policy files is necessary to do testing +with quite a lot of practical key sizes, they are available for download: + + * [Java 6](http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html) + * [Java 7](http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html) + * [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html) + +To install, place them in `${java.home}/jre/lib/security/`. + +### Options + ``` usage: ECTesterStandalone.jar [-V] [-h] [ (ecdh [-t ] [-n ] [-b ] [-nc ]) | (ecdsa [-t ] [-n ] [-b ] [-nc ] [-f ]) | @@ -251,5 +266,5 @@ usage: ECTesterStandalone.jar [-V] [-h] [ (ecdh [-t ] [-n ] [-b Set the Signature object [type]. -b,--bits What size of curve to use. -nc,--named-curve Use a named curve, from CurveDB: +``` -``` \ No newline at end of file diff --git a/docs/FORMAT.md b/docs/FORMAT.md index 849a62c..bde2543 100644 --- a/docs/FORMAT.md +++ b/docs/FORMAT.md @@ -56,4 +56,8 @@ Output of the `-dsa/--ecdsa` option. ## Test runs By default test runs are output in a human readable format, however YAML and XML is also supported and can be selected -by using the `-o/--output` option. +by using the `--format` option. Also, prefixing the output file name when using the `-o/--output` option allows to output +the same test run in different formats to different files. + +For example: +`--format yaml -o default_output.yaml -o xml:output_file.xml -o text:readable_text_file.txt ` diff --git a/src/cz/crcs/ectester/reader/output/FileTestWriter.java b/src/cz/crcs/ectester/reader/output/FileTestWriter.java index 6cfece1..e4ef9b8 100644 --- a/src/cz/crcs/ectester/reader/output/FileTestWriter.java +++ b/src/cz/crcs/ectester/reader/output/FileTestWriter.java @@ -19,7 +19,6 @@ public class FileTestWriter extends TeeTestWriter { public FileTestWriter(String defaultFormat, boolean systemOut, String[] files) throws ParserConfigurationException, FileNotFoundException { int fLength = files == null ? 0 : files.length; writers = new TestWriter[systemOut ? fLength + 1 : fLength]; - System.err.println(writers.length); if (systemOut) { writers[0] = createWriter(defaultFormat, System.out); } -- cgit v1.3.1