diff options
| -rw-r--r-- | !uploader/ectester.cap | bin | 16008 -> 15192 bytes | |||
| -rw-r--r-- | README.md | 105 | ||||
| -rw-r--r-- | docs/LIBS.md | 31 | ||||
| -rw-r--r-- | src/cz/crcs/ectester/reader/ECTesterReader.java | 8 |
4 files changed, 110 insertions, 34 deletions
diff --git a/!uploader/ectester.cap b/!uploader/ectester.cap Binary files differindex b883965..8077260 100644 --- a/!uploader/ectester.cap +++ b/!uploader/ectester.cap @@ -1,4 +1,5 @@ # ECTester +[](https://travis-ci.org/crocs-muni/ECTester) [](https://github.com/crocs-muni/ECTester/releases) [](https://github.com/crocs-muni/ECTester/blob/master/LICENSE) Tests support and behavior of elliptic curve cryptography implementations on JavaCards (`TYPE_EC_FP` and `TYPE_EC_F2M`) and on selected software libraries. @@ -6,14 +7,14 @@ Tests support and behavior of elliptic curve cryptography implementations on Jav ECTester uses ant. There are three parts of ECTester, the JavaCard applet used for testing, the reader app which controls it and the standalone app which tests software libraries. ```bash -ant -f build-reader.xml package # To build the reader tool (jar). -ant -f build-standalone.xml package # To build the standalone tool (jar). -ant -f build-applet.xml build # To build the applet (cap). +ant -f build-reader.xml package # To build the reader tool (jar) -> "dist/ECTesterReader.jar" +ant -f build-standalone.xml package # To build the standalone tool (jar) -> "dist/ECTesterStandalone.jar" +ant -f build-applet.xml build # To build the applet (cap) -> "!uploader/ectester.cap". ``` +Build produces both a lightweight version of the JARs and a full version of the JARs with dependencies included, the latter has the `*-dist.jar` suffix. +The standalone build tries building test binaries for all the supported libraries, and silently fails if the library is not properly supported. -## Usage - -### JavaCard testing +## JavaCard testing 1. Upload `!uploader/ectester.cap` using your favorite tool (e.g., [GlobalPlatformPro tool](https://github.com/martinpaljak/GlobalPlatform)) 2. Run `java -jar dist/ECTesterReader.jar -t -a` @@ -29,23 +30,31 @@ Following operations are tested: See `java -jar ECTesterReader.jar -h` for more. -#### Options +### Options ``` - -ln,--list-named <what> Print the list of supported named - curves and keys. -dsa,--ecdsa <count> Sign data with ECDSA, [count] times. - -t,--test <test_case> Test ECC support. - -dh,--ecdh <count> Do ECDH, [count] times. + -t,--test <test_suite> Test ECC support. [test_suite]: + - default: + - invalid: + - wrong: + - composite: + - test-vectors: + -dh,--ecdh <count> Do EC KeyAgreement (ECDH...), [count] + times. -e,--export Export the defaut curve parameters of the card(if any). - -g,--generate <amount> Generate [amount] of EC keys. + -V,--version Print version info. + -ln,--list-named <what> Print the list of supported named + curves and keys. -h,--help Print help. - -dhc,--ecdhc <count> Do ECDHC, [count] times. + -a,--all Test all curve sizes. -b,--bit-size <bits> Set curve size. + -fp,--prime-field Use a prime field. -f2m,--binary-field Use a binary field. + -c,--curve <curve_file> Use curve from file <curve_file> (field,a,b,gx,gy,r,k). -nc,--named-curve <cat/id> Use a named curve, from CurveDB: @@ -61,20 +70,25 @@ See `java -jar ECTesterReader.jar -h` for more. -k,--key <key_file> Use keyPair from fileĀ <key_file> (wx,wy,s). -nk,--named-key <cat/id> Use keyPair from KeyDB: <cat/id> + -i,--input <input_file> Input from fileĀ <input_file>, for ECDSA signing. -o,--output <output_file> Output into file <output_file>. -l,--log <log_file> Log output into file [log_file]. -v,--verbose Turn on verbose logging. - --format <format> Output format to use. + --format <format> Output format to use. One of: + text,yml,xml. -f,--fresh Generate fresh keys (set domain parameters before every generation). -s,--simulate Simulate a card with jcardsim instead of using a terminal. -y,--yes Accept all warnings and prompts. + -ka,--ka-type <type> Set KeyAgreement object [type], corresponds to JC.KeyAgreement - constants. + constants. + -sig,--sig-type <type> Set Signature object [type], + corresponds to JC.Signature constants. ``` ### Actions @@ -101,10 +115,10 @@ Use with `-o / --output [out_file]` to output the generated keys to a file. #### ECDH `-dh / --ecdh [count]` -`-dhc / --ecdhc [count]` Performs ECDH. Use with `-o / --output [out_file]` to output into a file. +Respects the KeyAgreement type specified in `-ka / --ka-type [type]`. #### ECDSA `-dsa / --ecdsa [count]` @@ -112,6 +126,7 @@ Use with `-o / --output [out_file]` to output into a file. Performs ECDSA. Useful with `-i / --input [in_file]` to sign the contents of a file. Use with `-o / --output [out_file]` to output into a file. +Respects the Signature type specified in `-sig / --sig-type [type]`. #### List named curves `-ln / --list-named []` @@ -149,6 +164,62 @@ For more info about the curves see [CURVES](docs/CURVES.md). *Explanation: ALG_EC_FP with 256b curve was tested. Is supported by card (KeyPair object allocation: OK), don't have preset default curve (Generate key with def curve: fail), custom curve can be set (Set valid custom curve: OK), new keypair can be generated (Generate key with valid curve: OK), ECDH key agreement failed to execute (ECDH agreement with valid point: fail) although it was supposed to succeed (log line is therefore marked with !!), ECDH wil fail (expected behavior) if invalid point is provided (ECDH agreement with invalid point: fail), ECDSA signature worked and verified correctly (ECDSA signature on random data: OK), anomalous curve can be set (Set anomalous custom curve: OK), however generating a key on it will fail (Generate key with anomalous curve: fail), ECDH with small-order public key provided will fail as intended (ECDH agreement with small order point: fail), invalid custom curve could be set (Set invalid custom curve: OK), new keypair cannot be generated with invalid curve (Generate key with invalid curve: fail), invalid field (non-prime) could be set (Set invalid field: OK), however a key could not be generated (Generate key with invalid field: fail).* - If you are interested in testing support for other JavaCard algorithms, please visit JCAlgTester project: https://github.com/crocs-muni/JCAlgTest + +## Standalone library testing + +Currently supported libraries include: + - BouncyCastle + - SunEC + - libtomcrypt + - botan + + +``` +usage: ECTesterStandalone.jar [-V] [-h] [ (ecdh [-t <type>] [-n <amount>] [-b <n>] [-nc <cat/id>]) | +(ecdsa [-t <type>] [-n <amount>] [-b <n>] [-nc <cat/id>] [-f <file>]) | +(export [-t <type>] [-b <n>]) | (generate [-nc <cat/id>] [-n <amount>] [-t +<type>] [-b <n>]) | (list-data [what]) | (list-libs) | (test [-gt <type>] +[-kt <type>] [-st <type>] [-b <n>] [-nc <cat/id>]) ] [lib] + + -V,--version Print version info. + -h,--help Print help. + [lib] What library to use. + + ecdh: + -t,--type <type> Set KeyAgreement object [type]. + -n,--amount <amount> Do ECDH [amount] times. + -b,--bits <n> What size of curve to use. + -nc,--named-curve <cat/id> Use a named curve, from CurveDB: <cat/id> + + ecdsa: + -t,--type <type> Set Signature object [type]. + -n,--amount <amount> Do ECDSA [amount] times. + -b,--bits <n> What size of curve to use. + -nc,--named-curve <cat/id> Use a named curve, from CurveDB: <cat/id> + -f,--file <file> Input [file] to sign. + + export: + -t,--type <type> Set KeyPair object [type]. + -b,--bits <n> What size of curve to use. + + generate: + -nc,--named-curve <cat/id> Use a named curve, from CurveDB: <cat/id> + -n,--amount <amount> Generate [amount] of EC keys. + -t,--type <type> Set KeyPairGenerator object [type]. + -b,--bits <n> What size of curve to use. + + list-data: + [what] what to list. + + list-libs: + + test: + -gt,--kpg-type <type> Set the KeyPairGenerator object [type]. + -kt,--ka-type <type> Set the KeyAgreement object [type]. + -st,--sig-type <type> Set the Signature object [type]. + -b,--bits <n> What size of curve to use. + -nc,--named-curve <cat/id> Use a named curve, from CurveDB: <cat/id> + +```
\ No newline at end of file diff --git a/docs/LIBS.md b/docs/LIBS.md index 3635fef..4fac57b 100644 --- a/docs/LIBS.md +++ b/docs/LIBS.md @@ -1,26 +1,31 @@ -# Libraries +# Libraries with ECC Libraries with at least some ECC support: + - [Crypto++](https://cryptopp.com/) + - [libgcrypt](https://www.gnupg.org/related_software/libgcrypt/) + + - [mbedTLS](https://tls.mbed.org/) + - [Nettle](http://www.lysator.liu.se/~nisse/nettle/) + - [OpenSSL](https://www.openssl.org/) + - [OpenSSL (FIPS mode)](https://www.openssl.org/docs/fipsnotes.html) + + - [Microsoft CNG](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376210(v=vs.85).aspx) + - [Microsoft .NET crypto](https://docs.microsoft.com/en-us/dotnet/standard/security/cryptography-model) + +# Supported libraries + - [BouncyCastle](https://bouncycastle.org/java.html) - Java - - [Botan](https://botan.randombit.net/) + - [Sun EC](https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunEC) + - Java + C + - [Botan](https://botan.randombit.net/), since 2.4.0 (unreleased) - C++ - Uses blinded(randomized) Montgomery ladder. - https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-1998-cmo-2 - https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-1986-cc - https://eprint.iacr.org/2015/657 - - [Crypto++](https://cryptopp.com/) - - [libgcrypt](https://www.gnupg.org/related_software/libgcrypt/) - [libtomcrypt](http://www.libtom.net/LibTomCrypt/) - C - Uses Jacobian coordinates. - - Sliding window scalar multiplication algorithm. - - [mbedTLS](https://tls.mbed.org/) - - [Nettle](http://www.lysator.liu.se/~nisse/nettle/) - - [OpenSSL](https://www.openssl.org/) - - [OpenSSL (FIPS mode)](https://www.openssl.org/docs/fipsnotes.html) - - [Sun EC](https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunEC) - - Java + C - - [Microsoft CNG](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376210(v=vs.85).aspx) - - [Microsoft .NET crypto](https://docs.microsoft.com/en-us/dotnet/standard/security/cryptography-model)
\ No newline at end of file + - Sliding window scalar multiplication algorithm.
\ No newline at end of file diff --git a/src/cz/crcs/ectester/reader/ECTesterReader.java b/src/cz/crcs/ectester/reader/ECTesterReader.java index 4e62f3f..215afbd 100644 --- a/src/cz/crcs/ectester/reader/ECTesterReader.java +++ b/src/cz/crcs/ectester/reader/ECTesterReader.java @@ -263,7 +263,7 @@ public class ECTesterReader { actions.addOption(Option.builder("e").longOpt("export").desc("Export the defaut curve parameters of the card(if any).").build()); actions.addOption(Option.builder("g").longOpt("generate").desc("Generate [amount] of EC keys.").hasArg().argName("amount").optionalArg(true).build()); actions.addOption(Option.builder("t").longOpt("test").desc("Test ECC support. [test_suite]:\n- default:\n- invalid:\n- wrong:\n- composite:\n- test-vectors:").hasArg().argName("test_suite").optionalArg(true).build()); - actions.addOption(Option.builder("ka").longOpt("ecka").desc("Do EC KeyAgreement (ECDH...), [count] times.").hasArg().argName("count").optionalArg(true).build()); + actions.addOption(Option.builder("dh").longOpt("ecdh").desc("Do EC KeyAgreement (ECDH...), [count] times.").hasArg().argName("count").optionalArg(true).build()); actions.addOption(Option.builder("dsa").longOpt("ecdsa").desc("Sign data with ECDSA, [count] times.").hasArg().argName("count").optionalArg(true).build()); opts.addOptionGroup(actions); @@ -782,7 +782,7 @@ public class ECTesterReader { return false; } - } else if (cli.hasOption("ecka")) { + } else if (cli.hasOption("ecdh")) { if (primeField == binaryField) { System.err.print("Need to specify field with -fp or -f2m. (not both)"); return false; @@ -792,9 +792,9 @@ public class ECTesterReader { return false; } - ECKACount = Integer.parseInt(cli.getOptionValue("ecka", "1")); + ECKACount = Integer.parseInt(cli.getOptionValue("ecdh", "1")); if (ECKACount <= 0) { - System.err.println("ECKA count cannot be <= 0."); + System.err.println("ECDH count cannot be <= 0."); return false; } |
