diff --git a/.travis.yml b/.travis.yml index 453c5238..3ca102d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ script: - ant -f build-applet.xml build - ant -f build-reader.xml package - ant -f build-standalone.xml package + - ./util/test.sh before_deploy: - zip "dist/ECTester.zip" "dist/ECTesterReader-dist.jar" "dist/ECTesterReader.jar" "applet/ectester.cap" "dist/ECTesterStandalone-dist.jar" "dist/ECTesterStandalone.jar" diff --git a/README.md b/README.md index bed5e629..5118c31b 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,9 @@ For format of this file see [FORMAT](docs/FORMAT.md). Perform support,performance and vulnerability tests of ECC. +To select which tests will be performed, it is possible to enter the test suite name with a suffix +which specifies the number of the first test to be run, and optionally the number of the last test to be run as `-t [:start_index[:stop_index]]`. + 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). diff --git a/build.xml b/build.xml new file mode 100644 index 00000000..dd074f62 --- /dev/null +++ b/build.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/LIBS.md b/docs/LIBS.md index d1a68d00..00dcaaff 100644 --- a/docs/LIBS.md +++ b/docs/LIBS.md @@ -2,11 +2,12 @@ Popular libraries with at least some ECC support: + - [NSS](https://hg.mozilla.org/projects/nss) - [libgcrypt](https://www.gnupg.org/related_software/libgcrypt/) - [mbedTLS](https://tls.mbed.org/) - [Nettle](http://www.lysator.liu.se/~nisse/nettle/) - [OpenSSL (FIPS mode)](https://www.openssl.org/docs/fipsnotes.html) - - BoringSSL + - [BoringSSL](https://boringssl.googlesource.com/boringssl) - [Microsoft .NET crypto](https://docs.microsoft.com/en-us/dotnet/standard/security/cryptography-model) # Supported libraries diff --git a/docs/TESTS.md b/docs/TESTS.md index 5811577c..c639722a 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -4,14 +4,15 @@ - `test-vectors` - `compression` - `miscellaneous` + - `signature` - `wrong`* - - `composite`* - `invalid`* - `twist`* - `degenerate`* + - `composite`* - `cofactor`* - `edge-cases`* - + **\*NOTE: The `wrong`, `composite`, `invalid`,`twist`, `cofactor`, `edge-cases` and `degenerate` test suites caused temporary/permanent DoS of some cards. These test suites prompt you for confirmation before running, be cautious.** @@ -22,12 +23,6 @@ with a compressed public key to test support for compressed points. This test suite is run if no argument is provided to `-t / --test`. -For example: -```bash -java -jar ECTester.jar -t -``` -tests prime field and binary field curves, using the default test suite. - ## Test-Vectors Tests using known test vectors provided by NIST/SECG/Brainpool: @@ -40,53 +35,65 @@ Tests using known test vectors provided by NIST/SECG/Brainpool: [Brainpool - RFC7027](https://tools.ietf.org/html/rfc7027#appendix-A) -For example: -```bash -java -jar ECTester.jar -t test-vectors -``` -tests all curves for which test-vectors are provided. ## Compression Tests support for compression of public points in ECDH as specified in ANSI X9.62. Tests ECDH with points in compressed and hybrid form. Also tests card response to a hybrid point with wrong `y` coordinate and to the point at infinity(as public key in ECDH). -For example: -```bash -java -jar ECTester.jar -t compression -``` + +## Miscellaneous +Some miscellaneous tests, tries ECDH and ECDSA over supersingular curves, anomalous curves and Barreto-Naehrig curves with small embedding degree and CM discriminant. + + +## Signature +Tests ECDSA verification, with invalid signatures. + + - Well-formed(DER) invalid signatures: + - r = random, s = random + - r = 0, s = random + - r = random, s = 0 + - r = 1, s = random + - r = random, s = 1 + - r = 0, s = 0 + - r = 0, s = 1 + - r = 1, s = 0 + - r = 1, s = 1 + - s = p + - s = 2 * p + - Invalid signatures: + - Signature shorter than specified in ASN.1 SEQUENCE header. + - Signature longer than specified in ASN.1 SEQUENCE header. + - r shorter/longer than specified in its ASN.1 header. + - s shorter/longer than specified in its ASN.1 header. + ## Wrong Tests on a category of wrong curves. These curves are not really curves as they have: + - non-prime field in the prime-field case - reducible polynomial as the field polynomial in the binary case This test suite also does some additional tests with corrupting the parameters: - - Fp: - - p = 0 - - p = 1 - - p = q^2; q prime - - p = q * s; q and s prime - - G = random point not on curve - - G = random data - - G = infinity - - r = 0 - - r = 1 - - r = some prime larger than original r (and \[r\]G != infinity) - - r = some prime smaller than original r (and \[r\]G != infninity) - - r = some composite number (and \[r\]G != infinity) - - k = 0xff - - k = 0 - - F2m: - - e1 = e2 = e3 = 0 - - m < e1 < e2 < e3 -These tests should fail generally. + - Fp: + - p = 0 + - p = 1 + - p = q^2; q prime + - p = q * s; q and s prime + - G = random point not on curve + - G = random data + - G = infinity + - r = 0 + - r = 1 + - r = some prime larger than original r (and \[r\]G != infinity) + - r = some prime smaller than original r (and \[r\]G != infninity) + - r = some composite number (and \[r\]G != infinity) + - k = 0xff + - k = 0 -For example: -```bash -java -jar ECTester.jar -t wrong -``` -does all wrong curve tests. + - F2m: + - e1 = e2 = e3 = 0 + - m < e1 < e2 < e3 ## Composite @@ -94,16 +101,16 @@ Tests using curves that don't have a prime order/nearly prime order. These tests should generally fail, a success here implies the card will use a non-secure curve if such curve is set by the applet. Operations over such curves are susceptible to small-subgroup attacks. - - r = quite a smooth number, many small factors, r = |G| - - r = small prime(of increasing bit lengths), r = |G| - - r = p * q = |G| + - r = quite a smooth number, many small factors, r = \|G\| + - r = prime(of increasing bit lengths), r = \|G\| + + This is performed over a 160 bit field size, in two passes: + - First pass tests the full range from 2 bits to 152, with more frequent tests towards the beginning and end. + - The second pass tests the range 140 - 158 bits with one bit steps. + + - r = p * q = \|G\| - r = G = Carmichael number = p * q * s - - \[r\]G = infinity but r != |G|, so |G| divides r - -For example: -```bash -java -jar ECTester.jar -t composite -``` + - \[r\]G = infinity but r != \|G\|, so \|G\| divides r ## Invalid @@ -112,12 +119,6 @@ ECDH should definitely fail, a success here implies the card is susceptible to i See [Practical Invalid Curve Attacks on TLS-ECDH](https://www.nds.rub.de/media/nds/veroeffentlichungen/2015/09/14/main-full.pdf) for more information. -For example: -```bash -java -jar ECTester.jar -t invalid -``` -tests using all curves with pregenerated *invalid* public keys for these curves. - ## Twist Tests using known named curves froms several categories(SECG/NIST) against pre-generated points on twists of said curves. @@ -126,10 +127,6 @@ the card might compute on the twist, if a point on the twist is supplied. See [SafeCurves on twist security](https://safecurves.cr.yp.to/twist.html) for more information. -For example: -```bash -java -jar ECTester.jar -t twist -``` ## Degenerate Tests using known named curves froms several categories(SECG/NIST) against pre-generated points on the degenerate line @@ -138,46 +135,31 @@ and uses a curve model vulnerable to such degenerate points. See [Degenerate Curve Attacks - Extending Invalid Curve Attacks to Edwards Curves and Other Models](https://eprint.iacr.org/2015/1233.pdf) for more information. -For example: -```bash -java -jar ECTester.jar -t degenerate -``` ## Cofactor Tests whether the card correctly rejects points that lie on the curve but not on the subgroup generated by the specified generator during ECDH. Does this with curves where the cofactor subgroup has small order, then with curves that have order equal to the product of two large primes, sets the generator with order of one prime and tries points on the subgroup of the other prime order. -For example: -```bash -java -jar ECTester.jar -t cofactor -``` ## Edge-Cases -Tests various inputs to ECDH which may cause an implementation to achieve a certain edge-case state during ECDH. -Some of the data is from the google/Wycheproof project. Tests include [CVE-2017-10176](https://nvd.nist.gov/vuln/detail/CVE-2017-10176) and [CVE-2017-8932](https://nvd.nist.gov/vuln/detail/CVE-2017-8932). +Tests various inputs to ECDH which may cause an implementation to achieve a certain edge-case state during ECDH. +Some of the data is from the google/Wycheproof project. Tests include [CVE-2017-10176](https://nvd.nist.gov/vuln/detail/CVE-2017-10176) and [CVE-2017-8932](https://nvd.nist.gov/vuln/detail/CVE-2017-8932) and an OpenSSL modular reduction bug +presented in [Practical realisation and elimination of an ECC-related software bug attack](https://eprint.iacr.org/2011/633). Various custom edge private key values are also tested. -CVE-2017-10176 was in implementation issue in the SunEC Java library that caused the implementation to reach the point at infinity during ECDH computation. +CVE-2017-10176 was in implementation issue in the SunEC Java library (and NSS ([CVE-2017-7781](https://nvd.nist.gov/vuln/detail/CVE-2017-7781)), thus also anything that used it) that caused the implementation to reach the point at infinity during ECDH computation. +See [blog](http://blog.intothesymmetry.com/2017/08/cve-2017-7781cve-2017-10176-issue-with.html) for more info. CVE-2017-8932 was an implementation issue in the Go standard library, in particular its scalar multiplication algorithm on the P-256 curve which leaked information about the private key. -Custom private key values over SECG curves are tested: +Custom edge-case private key values over SECG curves are tested: + - s = 0, s = 1 - s < r, s = r, s > r - s = r - 1, s = r + 1 - - s = k\*r - 1, s = k\*r, s = k\*r + 1 - -For example: -```bash -java -jar ECTester.jar -t edge-cases -``` - -## Miscellaneous -Some miscellaneous tests, tries ECDH and ECDSA over supersingular curves and Barreto-Naehrig curves with small embedding degree and CM discriminant. - -For example: -```bash -java -jar ECTester.jar -t miscellaneous -``` \ No newline at end of file + - s = k\*r - 1, s = k\*r, s = k\*r + 1 + - s around r (s < r, on a curve where \|r\| > \|p\|) + - s around p (on a curve where where \|r\| > \|p\|) + - s around 0 (s > 0, on a curve where \|r\| > \|p\|) diff --git a/src/cz/crcs/ectester/applet/ECKeyGenerator.java b/src/cz/crcs/ectester/applet/ECKeyGenerator.java index 9150248a..7c52e8f3 100644 --- a/src/cz/crcs/ectester/applet/ECKeyGenerator.java +++ b/src/cz/crcs/ectester/applet/ECKeyGenerator.java @@ -39,7 +39,6 @@ public KeyPair allocatePair(byte keyClass, short keyLength) { } /** - * * @param keypair * @param key * @return @@ -70,7 +69,6 @@ public short generatePair(KeyPair keypair) { } /** - * * @param keypair * @param curve * @param buffer @@ -82,7 +80,6 @@ public short setCurve(KeyPair keypair, byte curve, byte[] buffer, short offset) } /** - * * @param keypair * @param curve * @param params @@ -95,7 +92,6 @@ public short setCurve(KeyPair keypair, byte curve, short params, byte[] buffer, } /** - * * @param keypair * @param key * @param curve diff --git a/src/cz/crcs/ectester/applet/ECKeyTester.java b/src/cz/crcs/ectester/applet/ECKeyTester.java index 7c091e31..6b5aa6b5 100644 --- a/src/cz/crcs/ectester/applet/ECKeyTester.java +++ b/src/cz/crcs/ectester/applet/ECKeyTester.java @@ -46,13 +46,13 @@ public short allocateSig(byte algorithm) { * Uses {@code pubkeyBuffer} at {@code pubkeyOffset} for computations. * Output should equal with ECDHC output. * - * @param privatePair KeyPair from which the private key is used - * @param publicPair KeyPair from which the public key is used - * @param pubkeyBuffer buffer to be used for the public key - * @param pubkeyOffset offset into pubkeyBuffer that can be used for the public key - * @param outputBuffer buffer to be used for the secret output - * @param outputOffset offset into the outputBuffer - * @param transformation (EC_Consts.TRANSFORMATION_* | ...) + * @param privatePair KeyPair from which the private key is used + * @param publicPair KeyPair from which the public key is used + * @param pubkeyBuffer buffer to be used for the public key + * @param pubkeyOffset offset into pubkeyBuffer that can be used for the public key + * @param outputBuffer buffer to be used for the secret output + * @param outputOffset offset into the outputBuffer + * @param transformation (EC_Consts.TRANSFORMATION_* | ...) * @return derived secret length **/ public short testKA(KeyPair privatePair, KeyPair publicPair, byte[] pubkeyBuffer, short pubkeyOffset, byte[] outputBuffer, short outputOffset, short transformation) { @@ -131,7 +131,6 @@ public short testECDSA(ECPrivateKey signKey, ECPublicKey verifyKey, byte[] input } /** - * * @param signKey * @param inputBuffer * @param inputOffset @@ -154,7 +153,6 @@ public short testECDSA_sign(ECPrivateKey signKey, byte[] inputBuffer, short inpu } /** - * * @param verifyKey * @param inputBuffer * @param inputOffset diff --git a/src/cz/crcs/ectester/applet/ECTesterApplet.java b/src/cz/crcs/ectester/applet/ECTesterApplet.java index d0ca8f54..17c8faf9 100644 --- a/src/cz/crcs/ectester/applet/ECTesterApplet.java +++ b/src/cz/crcs/ectester/applet/ECTesterApplet.java @@ -477,7 +477,6 @@ private short insECDSA(APDU apdu) { } /** - * * @param apdu P1 = byte keyPair (KEYPAIR_*) * P2 = byte export (EXPORT_TRUE || EXPORT_FALSE) * DATA = byte sigType @@ -502,7 +501,6 @@ private short insECDSA_sign(APDU apdu) { } /** - * * @param apdu P1 = byte keyPair (KEYPAIR_*) * P2 = byte sigType * DATA = short dataLength (00 = random data generated, !00 = data length) @@ -609,12 +607,12 @@ private short set(KeyPair keyPair, byte curve, short params, byte[] inBuffer, sh } /** - * @param keyPair KeyPair to transform - * @param key key to transform (EC_Consts.KEY_* | ...) - * @param params parameters to transform (EC_Consts.PARAMETER_* | ...) + * @param keyPair KeyPair to transform + * @param key key to transform (EC_Consts.KEY_* | ...) + * @param params parameters to transform (EC_Consts.PARAMETER_* | ...) * @param transformation transformation type (EC_Consts.TRANSFORMATION_*) - * @param outBuffer buffer to output sw to - * @param outOffset output offset in buffer + * @param outBuffer buffer to output sw to + * @param outOffset output offset in buffer * @return length of data written to the buffer */ private short transform(KeyPair keyPair, byte key, short params, short transformation, byte[] outBuffer, short outOffset) { @@ -665,13 +663,13 @@ private short export(KeyPair keyPair, byte key, short params, byte[] outBuffer, } /** - * @param pubkey keyPair to use for public key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) - * @param privkey keyPair to use for private key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) - * @param export whether to export ECDH secret + * @param pubkey keyPair to use for public key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) + * @param privkey keyPair to use for private key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) + * @param export whether to export ECDH secret * @param transformation whether to transform the pubkey before ECDH - * @param type KeyAgreement type to test - * @param outBuffer buffer to write sw to, and export ECDH secret {@code if(export == EXPORT_TRUE)} - * @param outOffset output offset in buffer + * @param type KeyAgreement type to test + * @param outBuffer buffer to write sw to, and export ECDH secret {@code if(export == EXPORT_TRUE)} + * @param outOffset output offset in buffer * @return length of data written to the buffer */ private short ecdh(byte pubkey, byte privkey, byte export, short transformation, byte type, byte[] outBuffer, short outOffset) { @@ -813,9 +811,9 @@ private short ecdsa_verify(KeyPair verify, byte sigType, byte[] inBuffer, short short length = 0; short dataLength = Util.getShort(inBuffer, inOffset); - short dataOffset = (short)(inOffset + 2); - short sigLength = Util.getShort(inBuffer, (short)(dataOffset + dataLength)); - short sigOffset = (short)(dataOffset + dataLength + 2); + short dataOffset = (short) (inOffset + 2); + short sigLength = Util.getShort(inBuffer, (short) (dataOffset + dataLength)); + short sigOffset = (short) (dataOffset + dataLength + 2); if (keyTester.getSigType() == sigType) { keyTester.testECDSA_verify((ECPublicKey) verify.getPublic(), inBuffer, dataOffset, dataLength, inBuffer, sigOffset, sigLength); diff --git a/src/cz/crcs/ectester/common/cli/CLITools.java b/src/cz/crcs/ectester/common/cli/CLITools.java index a9d036e6..82ab530c 100644 --- a/src/cz/crcs/ectester/common/cli/CLITools.java +++ b/src/cz/crcs/ectester/common/cli/CLITools.java @@ -25,6 +25,12 @@ public static void help(String prog, String header, Options options, String foot help.printHelp(Colors.bold(prog), header, options, footer, usage); } + private static void help(HelpFormatter help, PrintWriter pw, String cmd, ParserOptions parser, int depth) { + String description = parser.getDescription() == null ? "" : " | " + parser.getDescription() + " |"; + help.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, String.format("%" + depth + "s" + cmd + ":" + description, " ")); + CLITools.help(help, pw, parser.getParser(), parser.getOptions(), depth + 1); + } + private static void help(HelpFormatter help, PrintWriter pw, CommandLineParser cli, Options opts, int depth) { if (opts.getOptions().size() > 0) { help.printOptions(pw, HelpFormatter.DEFAULT_WIDTH, opts, HelpFormatter.DEFAULT_LEFT_PAD + depth, HelpFormatter.DEFAULT_DESC_PAD); @@ -37,9 +43,7 @@ private static void help(HelpFormatter help, PrintWriter pw, CommandLineParser c } tp.getParsers().forEach((key, value) -> { pw.println(); - String description = value.getDescription() == null ? "" : " | " + value.getDescription() + " |"; - help.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, String.format("%" + depth + "s" + key + ":" + description, " ")); - CLITools.help(help, pw, value.getParser(), value.getOptions(), depth + 1); + help(help, pw, key, value, depth); }); } } @@ -107,6 +111,22 @@ public static void help(String prog, String header, Options baseOpts, TreeParser System.out.println(sw.toString()); } + public static void help(String header, TreeParser baseParser, String footer, String command) { + ParserOptions opts = baseParser.getParsers().get(command); + if (opts == null) { + System.err.println("Command not found: " + command); + return; + } + HelpFormatter help = new HelpFormatter(); + help.setOptionComparator(null); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + help.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, header); + help(help, pw, command, opts, 1); + help.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, footer); + System.out.println(sw.toString()); + } + /** * Print version info. */ diff --git a/src/cz/crcs/ectester/common/cli/TreeParser.java b/src/cz/crcs/ectester/common/cli/TreeParser.java index 23f59b16..657318da 100644 --- a/src/cz/crcs/ectester/common/cli/TreeParser.java +++ b/src/cz/crcs/ectester/common/cli/TreeParser.java @@ -100,9 +100,10 @@ public TreeCommandLine parse(Options options, String[] arguments, Properties pro if (lastCli.getArgs().length < requiredArgs) { throw new MissingArgumentException("Not enough arguments: " + reqArgs); - } else if (lastCli.getArgs().length > maxArgs) { - throw new MissingArgumentException("Too many arguments."); } + //else if (lastCli.getArgs().length > maxArgs) { + // throw new MissingArgumentException("Too many arguments."); + //} subTreeCli.setName(sub); return new TreeCommandLine(cli, subTreeCli); @@ -118,9 +119,10 @@ public TreeCommandLine parse(Options options, String[] arguments, Properties pro } else { if (cliArgs.length < requiredArgs) { throw new MissingArgumentException("Not enough arguments: " + reqArgs); - } else if (cliArgs.length > maxArgs) { - throw new MissingArgumentException("Too many arguments."); } + //else if (cliArgs.length > maxArgs) { + // throw new MissingArgumentException("Too many arguments."); + //} return new TreeCommandLine(cli, null); } diff --git a/src/cz/crcs/ectester/common/ec/EC_Category.java b/src/cz/crcs/ectester/common/ec/EC_Category.java index 9c65f3b4..8af308c1 100644 --- a/src/cz/crcs/ectester/common/ec/EC_Category.java +++ b/src/cz/crcs/ectester/common/ec/EC_Category.java @@ -10,6 +10,7 @@ /** * A category of EC_Data objects, has a name, description and represents a directory in * the cz.crcs.ectester.data package. + * * @author Jan Jancar johny@neuromancer.sk */ public class EC_Category { @@ -116,11 +117,24 @@ public String toString() { out.append(System.lineSeparator()); } - Map results = getObjects(EC_KAResult.class); - size = results.size(); + Map kaResults = getObjects(EC_KAResult.class); + size = kaResults.size(); if (size > 0) { - out.append(Colors.bold("\t\tResults: ")); - for (Map.Entry result : results.entrySet()) { + out.append(Colors.bold("\t\tResults(KA): ")); + for (Map.Entry result : kaResults.entrySet()) { + out.append(result.getKey()); + size--; + if (size > 0) + out.append(", "); + } + out.append(System.lineSeparator()); + } + + Map sigResults = getObjects(EC_SigResult.class); + size = sigResults.size(); + if (size > 0) { + out.append(Colors.bold("\t\tResults(SIG): ")); + for (Map.Entry result : sigResults.entrySet()) { out.append(result.getKey()); size--; if (size > 0) diff --git a/src/cz/crcs/ectester/common/ec/EC_Data.java b/src/cz/crcs/ectester/common/ec/EC_Data.java index abe6e93b..14ae1c5a 100644 --- a/src/cz/crcs/ectester/common/ec/EC_Data.java +++ b/src/cz/crcs/ectester/common/ec/EC_Data.java @@ -95,7 +95,7 @@ private static byte[] pad(byte[] data) { return null; } - private static byte[] parse(String param) { + protected static byte[] parse(String param) { byte[] data; if (param.startsWith("0x") || param.startsWith("0X")) { data = ByteUtil.hexToBytes(param.substring(2)); diff --git a/src/cz/crcs/ectester/common/ec/EC_SigResult.java b/src/cz/crcs/ectester/common/ec/EC_SigResult.java new file mode 100644 index 00000000..f1ab0f5b --- /dev/null +++ b/src/cz/crcs/ectester/common/ec/EC_SigResult.java @@ -0,0 +1,75 @@ +package cz.crcs.ectester.common.ec; + +import cz.crcs.ectester.common.util.CardUtil; + +/** + * A result of EC based Signature operation. + * + * @author Jan Jancar johny@neuromancer.sk + */ +public class EC_SigResult extends EC_Data { + private String sig; + private String curve; + private String signKey; + private String verifyKey; + + private String data; + private String desc; + + public EC_SigResult(String sig, String curve, String signKey, String verifyKey, String raw) { + super(1); + this.sig = sig; + this.curve = curve; + this.signKey = signKey; + this.verifyKey = verifyKey; + this.data = raw; + } + + public EC_SigResult(String id, String sig, String curve, String signKey, String verifyKey, String data) { + this(sig, curve, signKey, verifyKey, data); + this.id = id; + } + + public EC_SigResult(String id, String sig, String curve, String signKey, String verifyKey, String data, String desc) { + this(id, sig, curve, signKey, verifyKey, data); + this.desc = desc; + } + + public String getSig() { + return sig; + } + + public byte getJavaCardSig() { + return CardUtil.getSig(sig); + } + + public String getCurve() { + return curve; + } + + public String getSignKey() { + return signKey; + } + + public String getVerifyKey() { + return verifyKey; + } + + public byte[] getSigData() { + if (data == null) { + return null; + } else { + return parse(data); + } + } + + public String getDesc() { + return desc; + } + + @Override + public String toString() { + return "<" + getId() + "> " + sig + " result over " + curve + ", " + signKey + " + " + verifyKey + (data == null ? "" : " of data \"" + data + "\"") + (desc == null ? "" : ": " + desc) + System.lineSeparator() + super.toString(); + } + +} diff --git a/src/cz/crcs/ectester/common/ec/RawECPrivateKey.java b/src/cz/crcs/ectester/common/ec/RawECPrivateKey.java new file mode 100644 index 00000000..f4556a0c --- /dev/null +++ b/src/cz/crcs/ectester/common/ec/RawECPrivateKey.java @@ -0,0 +1,45 @@ +package cz.crcs.ectester.common.ec; + +import cz.crcs.ectester.common.util.ECUtil; + +import java.math.BigInteger; +import java.security.interfaces.ECPrivateKey; +import java.security.spec.ECParameterSpec; + +/** + * @author Jan Jancar johny@neuromancer.sk + */ +public class RawECPrivateKey implements ECPrivateKey { + private BigInteger scalar; + private ECParameterSpec params; + + public RawECPrivateKey(BigInteger scalar, ECParameterSpec params) { + this.scalar = scalar; + this.params = params; + } + + @Override + public BigInteger getS() { + return scalar; + } + + @Override + public String getAlgorithm() { + return "EC"; + } + + @Override + public String getFormat() { + return "Raw"; + } + + @Override + public byte[] getEncoded() { + return ECUtil.toByteArray(scalar, params.getOrder().bitLength()); + } + + @Override + public ECParameterSpec getParams() { + return params; + } +} diff --git a/src/cz/crcs/ectester/common/ec/RawECPublicKey.java b/src/cz/crcs/ectester/common/ec/RawECPublicKey.java new file mode 100644 index 00000000..f09feef8 --- /dev/null +++ b/src/cz/crcs/ectester/common/ec/RawECPublicKey.java @@ -0,0 +1,45 @@ +package cz.crcs.ectester.common.ec; + +import cz.crcs.ectester.common.util.ECUtil; + +import java.security.interfaces.ECPublicKey; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; + +/** + * @author Jan Jancar johny@neuromancer.sk + */ +public class RawECPublicKey implements ECPublicKey { + private ECPoint point; + private ECParameterSpec params; + + public RawECPublicKey(ECPoint point, ECParameterSpec params) { + this.point = point; + this.params = params; + } + + @Override + public ECPoint getW() { + return point; + } + + @Override + public String getAlgorithm() { + return "EC"; + } + + @Override + public String getFormat() { + return "Raw"; + } + + @Override + public byte[] getEncoded() { + return ECUtil.toX962Uncompressed(point, params); + } + + @Override + public ECParameterSpec getParams() { + return params; + } +} diff --git a/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java b/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java index ee55069a..f60f8bb7 100644 --- a/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java +++ b/src/cz/crcs/ectester/common/output/BaseTextTestWriter.java @@ -54,17 +54,17 @@ private String testString(Test t, String prefix, int index) { Result result = t.getResult(); - String line = ""; - if (prefix.equals("")) { - char charLine[] = new char[BASE_WIDTH + 24]; - new String(new char[BASE_WIDTH + 24]).replace("\0", "━").getChars(0, charLine.length - 1, charLine, 0); - charLine[0] = '■'; - charLine[4] = '┳'; - charLine[BASE_WIDTH + 1] = '┳'; - charLine[BASE_WIDTH + 13] = '┳'; - charLine[BASE_WIDTH + 23] = '┓'; - line = new String(charLine) + System.lineSeparator(); - } + String line = ""; + if (prefix.equals("")) { + char charLine[] = new char[BASE_WIDTH + 24]; + new String(new char[BASE_WIDTH + 24]).replace("\0", "━").getChars(0, charLine.length - 1, charLine, 0); + charLine[0] = '■'; + charLine[4] = '┳'; + charLine[BASE_WIDTH + 1] = '┳'; + charLine[BASE_WIDTH + 13] = '┳'; + charLine[BASE_WIDTH + 23] = '┓'; + line = new String(charLine) + System.lineSeparator(); + } StringBuilder out = new StringBuilder(); out.append(t.ok() ? Colors.ok(" OK ") : Colors.error("NOK ")); diff --git a/src/cz/crcs/ectester/common/output/OutputLogger.java b/src/cz/crcs/ectester/common/output/OutputLogger.java index 09b8f734..effd1fd1 100644 --- a/src/cz/crcs/ectester/common/output/OutputLogger.java +++ b/src/cz/crcs/ectester/common/output/OutputLogger.java @@ -1,6 +1,9 @@ package cz.crcs.ectester.common.output; -import java.io.*; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; import java.util.LinkedList; import java.util.List; diff --git a/src/cz/crcs/ectester/common/output/TestWriter.java b/src/cz/crcs/ectester/common/output/TestWriter.java index eb95804f..67aeccbb 100644 --- a/src/cz/crcs/ectester/common/output/TestWriter.java +++ b/src/cz/crcs/ectester/common/output/TestWriter.java @@ -19,14 +19,13 @@ public interface TestWriter { void begin(TestSuite suite); /** - * * @param t * @param index */ void outputTest(Test t, int index); /** - * @param t + * @param t * @param cause * @param index */ diff --git a/src/cz/crcs/ectester/common/test/TestCallback.java b/src/cz/crcs/ectester/common/test/TestCallback.java index ce6000b8..c5a49f37 100644 --- a/src/cz/crcs/ectester/common/test/TestCallback.java +++ b/src/cz/crcs/ectester/common/test/TestCallback.java @@ -3,9 +3,8 @@ import java.util.function.Function; /** - * - * @author Jan Jancar johny@neuromancer.sk * @param + * @author Jan Jancar johny@neuromancer.sk */ public abstract class TestCallback implements Function { diff --git a/src/cz/crcs/ectester/common/util/ByteUtil.java b/src/cz/crcs/ectester/common/util/ByteUtil.java index daacabb5..4b4a2d6c 100644 --- a/src/cz/crcs/ectester/common/util/ByteUtil.java +++ b/src/cz/crcs/ectester/common/util/ByteUtil.java @@ -10,6 +10,7 @@ public class ByteUtil { /** * Gen a short from a byte array at offset, big-endian. + * * @return the short value */ public static short getShort(byte[] array, int offset) { @@ -26,6 +27,7 @@ public static void setShort(byte[] array, int offset, short value) { /** * Compare two byte arrays upto length and get first difference. + * * @return the position of the first difference in the two byte arrays, or length if they are equal. */ public static int diffBytes(byte[] one, int oneOffset, byte[] other, int otherOffset, int length) { @@ -41,6 +43,7 @@ public static int diffBytes(byte[] one, int oneOffset, byte[] other, int otherOf /** * Compare two byte arrays, upto length. + * * @return whether the arrays are equal upto length */ public static boolean compareBytes(byte[] one, int oneOffset, byte[] other, int otherOffset, int length) { @@ -77,6 +80,7 @@ public static byte[] shortToBytes(short[] shorts) { /** * Parse a hex string into a byte array, big-endian. + * * @param hex The String to parse. * @return the byte array from the hex string. */ @@ -86,7 +90,8 @@ public static byte[] hexToBytes(String hex) { /** * Parse a hex string into a byte-array, specify endianity. - * @param hex The String to parse. + * + * @param hex The String to parse. * @param bigEndian Whether to parse as big-endian. * @return the byte array from the hex string. */ diff --git a/src/cz/crcs/ectester/common/util/CardUtil.java b/src/cz/crcs/ectester/common/util/CardUtil.java index a628d5b9..e7b370ca 100644 --- a/src/cz/crcs/ectester/common/util/CardUtil.java +++ b/src/cz/crcs/ectester/common/util/CardUtil.java @@ -14,6 +14,23 @@ * @author Jan Jancar johny@neuromancer.sk */ public class CardUtil { + public static byte getSig(String name) { + switch (name) { + case "SHA1": + return EC_Consts.Signature_ALG_ECDSA_SHA; + case "SHA224": + return EC_Consts.Signature_ALG_ECDSA_SHA_224; + case "SHA256": + return EC_Consts.Signature_ALG_ECDSA_SHA_256; + case "SHA384": + return EC_Consts.Signature_ALG_ECDSA_SHA_384; + case "SHA512": + return EC_Consts.Signature_ALG_ECDSA_SHA_512; + default: + return EC_Consts.Signature_ALG_ECDSA_SHA; + } + } + public static byte getKA(String name) { switch (name) { case "DH": diff --git a/src/cz/crcs/ectester/common/util/ECUtil.java b/src/cz/crcs/ectester/common/util/ECUtil.java index 0979d91b..6c3ad58c 100644 --- a/src/cz/crcs/ectester/common/util/ECUtil.java +++ b/src/cz/crcs/ectester/common/util/ECUtil.java @@ -1,6 +1,13 @@ package cz.crcs.ectester.common.util; +import cz.crcs.ectester.applet.EC_Consts; +import cz.crcs.ectester.common.ec.*; +import cz.crcs.ectester.data.EC_Store; + import java.math.BigInteger; +import java.security.KeyPair; +import java.security.interfaces.ECPrivateKey; +import java.security.interfaces.ECPublicKey; import java.security.spec.*; /** @@ -33,12 +40,8 @@ public static byte[] toX962Compressed(ECPoint point, int bits) { return ByteUtil.concatenate(new byte[]{marker}, x); } - public static byte[] toX962Compressed(ECPoint point, EllipticCurve curve) { - return toX962Compressed(point, curve.getField().getFieldSize()); - } - public static byte[] toX962Compressed(ECPoint point, ECParameterSpec spec) { - return toX962Compressed(point, spec.getCurve()); + return toX962Compressed(point, spec.getOrder().bitLength()); } public static byte[] toX962Uncompressed(ECPoint point, int bits) { @@ -50,12 +53,8 @@ public static byte[] toX962Uncompressed(ECPoint point, int bits) { return ByteUtil.concatenate(new byte[]{0x04}, x, y); } - public static byte[] toX962Uncompressed(ECPoint point, EllipticCurve curve) { - return toX962Uncompressed(point, curve.getField().getFieldSize()); - } - public static byte[] toX962Uncompressed(ECPoint point, ECParameterSpec spec) { - return toX962Uncompressed(point, spec.getCurve()); + return toX962Uncompressed(point, spec.getOrder().bitLength()); } public static byte[] toX962Hybrid(ECPoint point, int bits) { @@ -146,7 +145,7 @@ public static ECPoint fromX962(byte[] data, EllipticCurve curve) { alpha = alpha.add(x.multiply(a)); alpha = alpha.add(b); - if(!isResidue(alpha, p)) { + if (!isResidue(alpha, p)) { throw new IllegalArgumentException(); } @@ -175,4 +174,44 @@ public static ECPoint fromX962(byte[] data, EllipticCurve curve) { throw new IllegalArgumentException(); } } + + private static ECPoint toPoint(EC_Params params) { + return new ECPoint( + new BigInteger(1, params.getParam(EC_Consts.PARAMETER_W)[0]), + new BigInteger(1, params.getParam(EC_Consts.PARAMETER_W)[1])); + } + + private static BigInteger toScalar(EC_Params params) { + return new BigInteger(1, params.getParam(EC_Consts.PARAMETER_S)[0]); + } + + public static ECPublicKey toPublicKey(EC_Key.Public pubkey) { + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, pubkey.getCurve()); + if (curve == null) { + throw new IllegalArgumentException("pubkey curve nor found: " + pubkey.getCurve()); + } + return new RawECPublicKey(toPoint(pubkey), curve.toSpec()); + } + + public static ECPrivateKey toPrivateKey(EC_Key.Private privkey) { + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, privkey.getCurve()); + if (curve == null) { + throw new IllegalArgumentException("privkey curve nor found: " + privkey.getCurve()); + } + return new RawECPrivateKey(toScalar(privkey), curve.toSpec()); + } + + public static KeyPair toKeyPair(EC_Keypair kp) { + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, kp.getCurve()); + if (curve == null) { + throw new IllegalArgumentException("keypair curve nor found: " + kp.getCurve()); + } + ECPublicKey pubkey = new RawECPublicKey(toPoint(kp), curve.toSpec()); + ECPrivateKey privkey = new RawECPrivateKey(toScalar(kp), curve.toSpec()); + return new KeyPair(pubkey, privkey); + } + + public static byte[] toDERSignature(byte[] r, byte[] s) { + return ByteUtil.concatenate(new byte[]{0x30, (byte) (r.length + s.length + 4), 0x02, (byte) r.length}, r, new byte[]{0x02, (byte) s.length}, s); + } } diff --git a/src/cz/crcs/ectester/data/EC_Store.java b/src/cz/crcs/ectester/data/EC_Store.java index cb65402c..f1d42603 100644 --- a/src/cz/crcs/ectester/data/EC_Store.java +++ b/src/cz/crcs/ectester/data/EC_Store.java @@ -203,27 +203,15 @@ private EC_Category parseCategory(String name, String dir, String desc) throws P if (direct instanceof Element) { Element elem = (Element) direct; - Node id = elem.getElementsByTagName("id").item(0); - Node ka = elem.getElementsByTagName("ka").item(0); - Node curve = elem.getElementsByTagName("curve").item(0); - Node onekey = elem.getElementsByTagName("onekey").item(0); - Node otherkey = elem.getElementsByTagName("otherkey").item(0); - - NodeList descc = elem.getElementsByTagName("desc"); - String descs = null; - if (descc.getLength() != 0) { - descs = descc.item(0).getTextContent(); + NodeList ids = elem.getElementsByTagName("id"); + if (ids.getLength() != 1) { + throw new SAXException("result no id?"); } + String id = ids.item(0).getTextContent(); - EC_KAResult kaResult = new EC_KAResult(id.getTextContent(), ka.getTextContent(), curve.getTextContent(), onekey.getTextContent(), otherkey.getTextContent(), descs); - - InputStream csv = parseDataElement(dir, elem); - if (!kaResult.readCSV(csv)) { - throw new IOException("Invalid csv data. " + id.getTextContent()); - } - csv.close(); + EC_Data result = parseResultlike(dir, elem); - objMap.put(id.getTextContent(), kaResult); + objMap.put(id, result); } else { throw new SAXException("?"); } @@ -234,6 +222,49 @@ private EC_Category parseCategory(String name, String dir, String desc) throws P return new EC_Category(name, dir, desc, objMap); } + private EC_Data parseResultlike(String dir, Element elem) throws SAXException, IOException { + String tag = elem.getTagName(); + Node id = elem.getElementsByTagName("id").item(0); + + NodeList descc = elem.getElementsByTagName("desc"); + String descs = null; + if (descc.getLength() != 0) { + descs = descc.item(0).getTextContent(); + } + + Node curve = elem.getElementsByTagName("curve").item(0); + + EC_Data result; + if (tag.equals("kaResult")) { + Node ka = elem.getElementsByTagName("ka").item(0); + Node onekey = elem.getElementsByTagName("onekey").item(0); + Node otherkey = elem.getElementsByTagName("otherkey").item(0); + + result = new EC_KAResult(id.getTextContent(), ka.getTextContent(), curve.getTextContent(), onekey.getTextContent(), otherkey.getTextContent(), descs); + } else if (tag.equals("sigResult")) { + Node sig = elem.getElementsByTagName("sig").item(0); + Node signkey = elem.getElementsByTagName("signkey").item(0); + Node verifykey = elem.getElementsByTagName("verifykey").item(0); + NodeList datas = elem.getElementsByTagName("raw"); + String data = null; + if (datas.getLength() != 0) { + data = datas.item(0).getTextContent(); + } + + result = new EC_SigResult(id.getTextContent(), sig.getTextContent(), curve.getTextContent(), signkey.getTextContent(), verifykey.getTextContent(), data, descs); + } else { + throw new SAXException("?"); + } + + InputStream csv = parseDataElement(dir, elem); + if (!result.readCSV(csv)) { + throw new IOException("Invalid csv data. " + id.getTextContent()); + } + csv.close(); + + return result; + } + private EC_Params parseKeylike(String dir, Element elem) throws SAXException, IOException { Node id = elem.getElementsByTagName("id").item(0); Node curve = elem.getElementsByTagName("curve").item(0); diff --git a/src/cz/crcs/ectester/data/categories.xml b/src/cz/crcs/ectester/data/categories.xml index 38ce6838..082f92c3 100644 --- a/src/cz/crcs/ectester/data/categories.xml +++ b/src/cz/crcs/ectester/data/categories.xml @@ -77,7 +77,7 @@ wrong wrong - Wrong field curves. These should definitely give an error when used. Since the "prime" used for the field is not prime, and the field polynomials are also not irreducible. Simply put these parameters don't specify a valid elliptic curve. + Wrong field curves and other wrong parameters. These should definitely give an error when used. Since the "prime" used for the field is not prime, and the field polynomials are also not irreducible. Simply put these parameters don't specify a valid elliptic curve. test diff --git a/src/cz/crcs/ectester/data/cofactor/curves.xml b/src/cz/crcs/ectester/data/cofactor/curves.xml index bb8a9053..7cf2a9a9 100644 --- a/src/cz/crcs/ectester/data/cofactor/curves.xml +++ b/src/cz/crcs/ectester/data/cofactor/curves.xml @@ -81,7 +81,13 @@ prime cofactor160p64.csv - + + + cofactor192p2 + 192 + prime + cofactor192p2.csv + cofactor163t2 diff --git a/src/cz/crcs/ectester/data/cofactor/keys.xml b/src/cz/crcs/ectester/data/cofactor/keys.xml index 8cf19a1e..b4c0c903 100644 --- a/src/cz/crcs/ectester/data/cofactor/keys.xml +++ b/src/cz/crcs/ectester/data/cofactor/keys.xml @@ -3,9 +3,7 @@ ]> + xsi:noNamespaceSchemaLocation="../schema.xsd"> cofactor128p2/0 diff --git a/src/cz/crcs/ectester/data/composite/curves.xml b/src/cz/crcs/ectester/data/composite/curves.xml index f77159c5..d4ef2cea 100644 --- a/src/cz/crcs/ectester/data/composite/curves.xml +++ b/src/cz/crcs/ectester/data/composite/curves.xml @@ -41,14 +41,18 @@ 384 prime composite384.csv - r = order = 0x05 * 0x0b * 0x3d * 0xb16aa7dc50145337cf1b2f38018ccb5cf44c22a2f7d7c22bbe5c572d2cb9a04cb1081357c6a1c97cc39ab62596867 + r = order = 0x05 * 0x0b * 0x3d * + 0xb16aa7dc50145337cf1b2f38018ccb5cf44c22a2f7d7c22bbe5c572d2cb9a04cb1081357c6a1c97cc39ab62596867 + whole/composite521 521 prime composite521.csv - r = order = 0x02 * 0x05 * 0x1f * 0x4a5aac4fac3ea253b66c3e650f5173b30467f28b8e841d37ce69bb0831a5939ad3dd082b750577ec4592d4d58916c87a9b732d8ddae435c26f8f779d2467f50f + r = order = 0x02 * 0x05 * 0x1f * + 0x4a5aac4fac3ea253b66c3e650f5173b30467f28b8e841d37ce69bb0831a5939ad3dd082b750577ec4592d4d58916c87a9b732d8ddae435c26f8f779d2467f50f + @@ -190,7 +194,7 @@ composite192_rg0.csv |G| divides r(so [r]G = infinity), but r != |G| = 0x302b72431ff070e7e06799 - + pq/composite224 224 @@ -252,11 +256,11 @@ - pp/carmichael128 - 128 - prime - carmichael_128.csv - r = Carmichael pseudoprime = 0x2ddbfe0f1f7 * 0x5bb7fc1e3ed * 0x8993fa2d5e3 + pp/carmichael128 + 128 + prime + carmichael_128.csv + r = Carmichael pseudoprime = 0x2ddbfe0f1f7 * 0x5bb7fc1e3ed * 0x8993fa2d5e3 pp/carmichael192 @@ -277,245 +281,388 @@ 256 prime carmichael_256.csv - r = Carmichael pseudoprime = 0x129e94800bf86bd2d04ce1 * 0x253d290017f0d7a5a099c1 * 0x37dbbd8023e9437870e6a1 + r = Carmichael pseudoprime = 0x129e94800bf86bd2d04ce1 * 0x253d290017f0d7a5a099c1 * + 0x37dbbd8023e9437870e6a1 + pp/carmichael384 384 prime carmichael_384.csv - r = Carmichael pseudoprime = 0x78b4fa97e97300a5c46b32fb522cf76f * 0xf169f52fd2e6014b88d665f6a459eedd * 0x16a1eefc7bc5901f14d4198f1f686e64b + r = Carmichael pseudoprime = 0x78b4fa97e97300a5c46b32fb522cf76f * 0xf169f52fd2e6014b88d665f6a459eedd * + 0x16a1eefc7bc5901f14d4198f1f686e64b + pp/carmichael512 512 prime carmichael_512.csv - r = Carmichael pseudoprime = 0x2f6e41969c169b4e97b0a1c46ca4fb3a8f294afaefb * 0x5edc832d382d369d2f614388d949f6751e5295f5df5 * 0x8e4ac4c3d443d1ebc711e54d45eef1afad7be0f0cef + r = Carmichael pseudoprime = 0x2f6e41969c169b4e97b0a1c46ca4fb3a8f294afaefb * + 0x5edc832d382d369d2f614388d949f6751e5295f5df5 * 0x8e4ac4c3d443d1ebc711e54d45eef1afad7be0f0cef + pp/carmichael521 521 prime carmichael_521.csv - r = Carmichael pseudoprime = 0x170ac4fd154250e674f9ac6e0c29a214c6d6553e4f11 * 0x2e1589fa2a84a1cce9f358dc185344298dacaa7c9e21 * 0x45204ef73fc6f2b35eed054a247ce63e5482ffbaed31 + r = Carmichael pseudoprime = 0x170ac4fd154250e674f9ac6e0c29a214c6d6553e4f11 * + 0x2e1589fa2a84a1cce9f358dc185344298dacaa7c9e21 * 0x45204ef73fc6f2b35eed054a247ce63e5482ffbaed31 + - varying/160/1 + varying/160/first/1 160 prime - varying/160/2a.csv + varying/160/first/2a.csv r = 2 bit prime = 2 - varying/160/2 + varying/160/first/2 160 prime - varying/160/2b.csv + varying/160/first/2b.csv r = 2 bit prime = 3 - varying/160/3 + varying/160/first/3 160 prime - varying/160/3.csv + varying/160/first/3.csv r = 3 bit prime - varying/160/4 + varying/160/first/4 160 prime - varying/160/4.csv + varying/160/first/4.csv r = 4 bit prime - varying/160/5 + varying/160/first/5 160 prime - varying/160/5.csv + varying/160/first/5.csv r = 5 bit prime - varying/160/6 + varying/160/first/6 160 prime - varying/160/6.csv + varying/160/first/6.csv r = 6 bit prime - varying/160/7 + varying/160/first/7 160 prime - varying/160/7.csv + varying/160/first/7.csv r = 7 bit prime - varying/160/8 + varying/160/first/8 160 prime - varying/160/8.csv + varying/160/first/8.csv r = 8 bit prime - varying/160/10 + varying/160/first/10 160 prime - varying/160/10.csv + varying/160/first/10.csv r = 10 bit prime - varying/160/12 + varying/160/first/12 160 prime - varying/160/12.csv + varying/160/first/12.csv r = 12 bit prime - varying/160/14 + varying/160/first/14 160 prime - varying/160/14.csv + varying/160/first/14.csv r = 14 bit prime - varying/160/16 + varying/160/first/16 160 prime - varying/160/16.csv + varying/160/first/16.csv r = 16 bit prime - varying/160/20 + varying/160/first/20 160 prime - varying/160/20.csv + varying/160/first/20.csv r = 20 bit prime - varying/160/25 + varying/160/first/25 160 prime - varying/160/25.csv + varying/160/first/25.csv r = 25 bit prime - varying/160/32 + varying/160/first/32 160 prime - varying/160/32.csv + varying/160/first/32.csv r = 32 bit prime - varying/160/48 + varying/160/first/48 160 prime - varying/160/48.csv + varying/160/first/48.csv r = 48 bit prime - varying/160/64 + varying/160/first/64 160 prime - varying/160/64.csv + varying/160/first/64.csv r = 64 bit prime - varying/160/70 + varying/160/first/70 160 prime - varying/160/70.csv + varying/160/first/70.csv r = 70 bit prime - varying/160/80 + varying/160/first/80 160 prime - varying/160/80.csv + varying/160/first/80.csv r = 80 bit prime - varying/160/90 + varying/160/first/90 160 prime - varying/160/90.csv + varying/160/first/90.csv r = 90 bit prime - varying/160/96 + varying/160/first/96 160 prime - varying/160/96.csv + varying/160/first/96.csv r = 96 bit prime - varying/160/112 + varying/160/first/112 160 prime - varying/160/112.csv + varying/160/first/112.csv r = 112 bit prime - varying/160/128 + varying/160/first/128 160 prime - varying/160/128.csv + varying/160/first/128.csv r = 128 bit prime - varying/160/135 + varying/160/first/135 160 prime - varying/160/135.csv + varying/160/first/135.csv r = 135 bit prime - varying/160/140 + varying/160/first/140 160 prime - varying/160/140.csv + varying/160/first/140.csv r = 140 bit prime - varying/160/144 + varying/160/first/144 160 prime - varying/160/144.csv + varying/160/first/144.csv r = 144 bit prime - varying/160/146 + varying/160/first/146 160 prime - varying/160/146.csv + varying/160/first/146.csv r = 146 bit prime - varying/160/148 + varying/160/first/148 160 prime - varying/160/148.csv + varying/160/first/148.csv r = 148 bit prime - varying/160/150 + varying/160/first/150 160 prime - varying/160/150.csv + varying/160/first/150.csv r = 150 bit prime - varying/160/152 + varying/160/first/152 160 prime - varying/160/152.csv + varying/160/first/152.csv r = 152 bit prime - varying/160/152cofactor + varying/160/first/152cofactor 160 prime - varying/160/152_cofactor.csv + varying/160/first/152_cofactor.csv r = 152 bit prime, with correct cofactor + + + varying/160/second/140 + 160 + prime + varying/160/second/140.csv + r = 140 bit prime. + + + varying/160/second/141 + 160 + prime + varying/160/second/141.csv + r = 141 bit prime. + + + varying/160/second/142 + 160 + prime + varying/160/second/142.csv + r = 142 bit prime. + + + varying/160/second/143 + 160 + prime + varying/160/second/143.csv + r = 143 bit prime. + + + varying/160/second/144 + 160 + prime + varying/160/second/144.csv + r = 144 bit prime. + + + varying/160/second/145 + 160 + prime + varying/160/second/145.csv + r = 145 bit prime. + + + varying/160/second/146 + 160 + prime + varying/160/second/146.csv + r = 146 bit prime. + + + varying/160/second/147 + 160 + prime + varying/160/second/147.csv + r = 147 bit prime. + + + varying/160/second/148 + 160 + prime + varying/160/second/148.csv + r = 148 bit prime. + + + varying/160/second/149 + 160 + prime + varying/160/second/149.csv + r = 149 bit prime. + + + varying/160/second/150 + 160 + prime + varying/160/second/150.csv + r = 150 bit prime. + + + varying/160/second/151 + 160 + prime + varying/160/second/151.csv + r = 151 bit prime. + + + varying/160/second/152 + 160 + prime + varying/160/second/152.csv + r = 152 bit prime. + + + varying/160/second/153 + 160 + prime + varying/160/second/153.csv + r = 153 bit prime. + + + varying/160/second/154 + 160 + prime + varying/160/second/154.csv + r = 154 bit prime. + + + varying/160/second/155 + 160 + prime + varying/160/second/155.csv + r = 155 bit prime. + + + varying/160/second/156 + 160 + prime + varying/160/second/156.csv + r = 156 bit prime. + + + varying/160/second/157 + 160 + prime + varying/160/second/157.csv + r = 157 bit prime. + + + varying/160/second/158 + 160 + prime + varying/160/second/158.csv + r = 158 bit prime. + + \ No newline at end of file diff --git a/src/cz/crcs/ectester/data/composite/keys.xml b/src/cz/crcs/ectester/data/composite/keys.xml index 8a98135a..da770d8d 100644 --- a/src/cz/crcs/ectester/data/composite/keys.xml +++ b/src/cz/crcs/ectester/data/composite/keys.xml @@ -1,8 +1,6 @@ + xsi:noNamespaceSchemaLocation="../schema.xsd"> composite128/1 0x746fa441b3a54d3c531bd59d119f400d,0x73aff68dbd96e1485cd2de0f6389cc70 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/10.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/10.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/10.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/10.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/112.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/112.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/112.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/112.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/12.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/12.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/12.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/12.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/128.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/128.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/128.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/128.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/135.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/135.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/135.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/135.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/14.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/14.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/14.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/14.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/140.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/140.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/140.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/140.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/144.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/144.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/144.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/144.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/146.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/146.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/146.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/146.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/148.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/148.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/148.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/148.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/150.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/150.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/150.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/150.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/152.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/152.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/152.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/152.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/152_cofactor.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/152_cofactor.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/152_cofactor.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/152_cofactor.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/16.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/16.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/16.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/16.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/20.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/20.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/20.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/20.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/25.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/25.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/25.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/25.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/2a.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/2a.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/2a.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/2a.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/2b.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/2b.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/2b.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/2b.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/3.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/3.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/3.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/3.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/32.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/32.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/32.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/32.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/4.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/4.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/4.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/4.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/48.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/48.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/48.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/48.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/5.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/5.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/5.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/5.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/6.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/6.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/6.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/6.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/64.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/64.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/64.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/64.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/7.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/7.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/7.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/7.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/70.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/70.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/70.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/70.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/8.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/8.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/8.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/8.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/80.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/80.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/80.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/80.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/90.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/90.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/90.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/90.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/96.csv b/src/cz/crcs/ectester/data/composite/varying/160/first/96.csv similarity index 100% rename from src/cz/crcs/ectester/data/composite/varying/160/96.csv rename to src/cz/crcs/ectester/data/composite/varying/160/first/96.csv diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/140.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/140.csv new file mode 100644 index 00000000..08f5ba15 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/140.csv @@ -0,0 +1 @@ +0xcb0fbd7d31f129c9445949ac2a53313dc664dcf5,0xbac859aab1168154552b678c5710381db579e093,0xa6bba8fe9ce31053ef6df534c0f51abf7f2b84f6,0x89ddb9394b1e7aa83435762bd9fb10b382112c9d,0x0195f79a927f4933fc96fd11d22f645fd2a6165e,0x00000d27f195fd2b5a2ce76e0a0883493af40f29,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/141.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/141.csv new file mode 100644 index 00000000..896493f3 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/141.csv @@ -0,0 +1 @@ +0xad848c5b6dd0a0a4069abc227c1067e0181b2737,0x19ee65c4d27dbb11e6209ca476e192d09b2d1c63,0x764d165a2dade5d7a08a76111d7fbbc2d11ef0e0,0x5bcd89823c97b60ad38738fe720f185f3b40b45e,0x09a715128167a9c88c740460bd69458fa9d4fe46,0x00001998e626a1aed4c95d9d4b4c2b7a7f7a9db7,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/142.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/142.csv new file mode 100644 index 00000000..cc5fd671 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/142.csv @@ -0,0 +1 @@ +0xb5d6a607a39940bc0048f4aa5ccdc4d5a5ce610d,0x2a1ae87f817fa325f32f2e0105f282027b2ba43f,0x659ed881b0d7116353d5f7a915d2f19e893d69aa,0x1b334db8e98df484ad04272df15f3e86d39ef22e,0x4cd77e9caad63bd4607eb0ed55e6beb23ff450ac,0x00003a204ba60e40fa9b658d3a1a8b2a9bc3cf59,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/143.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/143.csv new file mode 100644 index 00000000..9c4861e2 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/143.csv @@ -0,0 +1 @@ +0xd4b9159c7fc2792372543d143613b52f59998f97,0x2d42a2dfc137411a8c70ade2bdf0592b40943710,0x05e4b77414fb3c55c130f2bcaef25f3d151bd099,0x5a756a4341b6a3e22dead483df6f181e8b9a2a11,0xcd4da9413d50e4d5215e6bbcf6d5a7b0e3a3daad,0x000072ff5242224738c7ce5b71bc1f89fd2b4b37,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/144.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/144.csv new file mode 100644 index 00000000..db68fad0 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/144.csv @@ -0,0 +1 @@ +0xb1782dbf5f2c4021d8b9b5b363c82e0ca3b6777d,0x6076e1773b2c55518400dc32e80be429edcb965a,0x42ea1ee077a97b47a0e1e768e6926639b66ce893,0x9c662a05f65b34ddc7f87b6b7684a07b898a1c34,0x2845b2b399e0159f6096acb982ef4db0914088c9,0x0000c87bb99f30317e9dac369288e804184aa599,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/145.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/145.csv new file mode 100644 index 00000000..08c8c4fa --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/145.csv @@ -0,0 +1 @@ +0xb527a5bd64b0565b27ff7cf9602983f1614fffa3,0x19d78ae1d883b88aa6f0f7858d4e1be5a8f7e3fb,0x209c90f1e463fe85994da3a49bf1573b51174a1a,0x19d11cc60298336167b838b1980f7220c4a38ae4,0x370c05e2d1b3f2da9f0c7613a156c079ede829a7,0x0001dbc7f60ad202d5d0beea6a46ba5e0cfdb415,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/146.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/146.csv new file mode 100644 index 00000000..3afd1a09 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/146.csv @@ -0,0 +1 @@ +0xee5432006a4e6cbe37b806adb8caa4ea3db20871,0x8840485629c0217fe0c06136960a8ee0ff052cf6,0x4c2d28b41bf1195979928396a38349fba3f8790c,0x7d220bdba9cccd7ac1eff4c0faa15943df8c5661,0xafac34dd20bc52fc5d591ba7b3ba61804573cea7,0x0003e4f1ab7695bf568e94399144ba99087b8b43,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/147.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/147.csv new file mode 100644 index 00000000..895acfe0 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/147.csv @@ -0,0 +1 @@ +0xd4af3495a36eaecf01f5333d4ed9c0557e7d290f,0x8009417988238ec78161b22a5193683dd3a30db1,0x78194aed072799ea84118a326f19db81c96cc133,0x43c7510009f2a50acf960aee86f8e5f4680bb399,0x63e3c2609b3cb63a0bfabe048d4910b98806f986,0x000768a687b40a678e8b32a197c56a5e8e73c2e9,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/148.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/148.csv new file mode 100644 index 00000000..0e2221f9 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/148.csv @@ -0,0 +1 @@ +0xb4b26d3a176014e5e78384429e7cfb7fc54e5977,0x3314626f01d24d21beda9d48df49e3ecbc7cb71e,0x3756db6c83ddaa8e67c67e58359cc9a9cf0fd855,0x8622b6abfae956ec4340565a8441e3829553dc9d,0x548d45e6ed7673b271076e14c3d6e56b58edbc95,0x000c1b3ad6efad76b6c3bc52edecbe9558da19c5,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/149.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/149.csv new file mode 100644 index 00000000..2fb41e3b --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/149.csv @@ -0,0 +1 @@ +0xceceeaa7a8152749b1ecf9bc92f6fdc6e9b6090d,0x8ae42228a534ba5893260370f28090fb64e9946e,0x638476b65f061b9519065ca3dee37d03ee253b6f,0xca0c26fa582635625744d77e72134099aacc7d51,0x22342b88baf41bb6d4b8d61f9e7e2d767838ae49,0x001aa507af8faa15cf84906cef78d950265b459d,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/150.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/150.csv new file mode 100644 index 00000000..e38fe994 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/150.csv @@ -0,0 +1 @@ +0xb7adb7da47532691380d279b714329a18c73bf5b,0x62b5535930b3b6291724d2931c6d6e77b9e7603e,0xa6e5735c172868621e282c8606f0f7bf69196b98,0x936da9db53a9cdf04603e3e74dfd597e17159c47,0x0e57b546f6b8fce730f9eb62a15047533b0866e5,0x0038dbb1f277473e654a9df7571e61d3d954144d,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/151.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/151.csv new file mode 100644 index 00000000..9b665bca --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/151.csv @@ -0,0 +1 @@ +0xb43604e48b105f7a9a3b48c7bfd6d3e0ac093e29,0x444d3467678862170058dd92531a9e2bbe28ca79,0x89c6c1006cf8d019db1813b81549d7ddeff6bfd0,0x48faa03d1bd1142749c886ff0ed8cf990cfae57e,0x7188beb85a7c04ca83328b66f74d284b8d4ab1c5,0x006b0a1bda4f09218bf0b0c4db0eda6a4452e5e5,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/152.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/152.csv new file mode 100644 index 00000000..854a93ff --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/152.csv @@ -0,0 +1 @@ +0xd998f399cb387874de3a6a56d1babc55720e5abf,0x9c8f7ea6edb66b2570d884fd8eb6b7bfa832fe5a,0xa2a58c9670ac7a17713263ccf56187f4b3a9538c,0x37a374fcc33795ab48f2c5cefb55059e4047a5bd,0x688bb2276ffbdb652f5a9adb8f6861fa58f0a348,0x00ddee9ca918b3fc62cc35c868f2841bce9f9587,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/153.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/153.csv new file mode 100644 index 00000000..90ff7122 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/153.csv @@ -0,0 +1 @@ +0xcb5e3c67cebdcab6da9abee717934147f573e455,0x8528cb57477cb9daf1b39f210ec4305e38d59af9,0x625bc0553d8acf552224e9ef4a0d680bd097af1a,0x7cd27cf687a0f4cb8b192d2a301dc155e382a51a,0x79b81b30498366d71e34a6e73d7fc1acb70d887e,0x0199f05982a2c1179cef17249652a9866f31ffe5,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/154.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/154.csv new file mode 100644 index 00000000..1c45df7b --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/154.csv @@ -0,0 +1 @@ +0xc790ce0bbeb04fc50f56ffa90ac697664b33a0c5,0x3c27b2c2fef3181c1b7b342f5d0b141e9b1fa083,0x643c56c57d4dd643ce041ea26bf84ad607b768cf,0x03ac9106b43aefc2474993dc00ca435526e62dbd,0x218216a290e95e1d06ce4a633604067084226b3e,0x03458579e5bfbe29004061a83bdcbf9f03b740df,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/155.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/155.csv new file mode 100644 index 00000000..a3dcc8c2 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/155.csv @@ -0,0 +1 @@ +0xb291f1d68a548cb930da845e4dddde4a459fca55,0x3ff55740d89a34a571572edfd9603ac231420227,0x17109ebf052464e986afe2008ae70355b585b07d,0x27d235656b6608a9df667f7ee99f76e9c6001d8d,0x1cf7d6d12b86ef2fd9b9fb032ab38a902d28fcb2,0x062857c99ad6c70f36a668b6cb0b39ca3859ee3d,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/156.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/156.csv new file mode 100644 index 00000000..7614b13b --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/156.csv @@ -0,0 +1 @@ +0xb5753cb547a5fe317e9e85a7b0ecf7bcc8358b89,0x39c31f1f78b01c7ab7010de50026f25884ecfac1,0x5acf7eaab9c2bbb84dfdcf6253983c75e3f892a9,0x8c109fac40ecf79c874b1347c89bdd0b1e32bd58,0x198bc391b21d8be4e9b47250a86f03d3bfb4cd61,0x0df5537067f9138da74724f682ce1971c0319dff,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/157.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/157.csv new file mode 100644 index 00000000..06cd933b --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/157.csv @@ -0,0 +1 @@ +0xd7e7392c25ed14a0c4f61532461ebb36e8aac95d,0xbfa946439770d5832c224072c35a523550c63470,0x6cc6a5296eae2706bd6acfff1c6ca1e20be17f15,0x30fafbc8479b28fe86fe336f67035094e74deaaa,0x3621025307234ee276a45b78f101f88353d1ddf9,0x1ed7e39897b42784ae6c29501574867ebf7c3d5b,0x01 diff --git a/src/cz/crcs/ectester/data/composite/varying/160/second/158.csv b/src/cz/crcs/ectester/data/composite/varying/160/second/158.csv new file mode 100644 index 00000000..c35a6284 --- /dev/null +++ b/src/cz/crcs/ectester/data/composite/varying/160/second/158.csv @@ -0,0 +1 @@ +0xa686fb6e6f34c9e85dc6ae22a1d84a17b547b82d,0xa5c25d0cf5bd6443f3342843108b9b4b795be6ca,0x59c73b85c6591dd41f185e6cb009a3068717197b,0x4dc987eec93319f036dea2ec3d2ae58639c44574,0x6799aaad16a911c57f9643c38fe3cabf2e41644b,0x378253cf7a66edf81f41bedf086cec98847ad68b,0x01 diff --git a/src/cz/crcs/ectester/data/degenerate/keys.xml b/src/cz/crcs/ectester/data/degenerate/keys.xml index cbeecce3..b999ca00 100644 --- a/src/cz/crcs/ectester/data/degenerate/keys.xml +++ b/src/cz/crcs/ectester/data/degenerate/keys.xml @@ -4,9 +4,7 @@ ]> + xsi:noNamespaceSchemaLocation="../schema.xsd"> + secg/secp256r1 + other/openssl-bug/pkey + other/openssl-bug/skey + https://eprint.iacr.org/2011/633 + + \ No newline at end of file diff --git a/src/cz/crcs/ectester/data/schema.xsd b/src/cz/crcs/ectester/data/schema.xsd index 85e81079..99c9b765 100644 --- a/src/cz/crcs/ectester/data/schema.xsd +++ b/src/cz/crcs/ectester/data/schema.xsd @@ -51,8 +51,6 @@ - - @@ -70,7 +68,7 @@ - + @@ -82,10 +80,34 @@ + + + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/src/cz/crcs/ectester/data/test/keys.xml b/src/cz/crcs/ectester/data/test/keys.xml index 5f86b5b5..380aef19 100644 --- a/src/cz/crcs/ectester/data/test/keys.xml +++ b/src/cz/crcs/ectester/data/test/keys.xml @@ -1,8 +1,6 @@ + xsi:noNamespaceSchemaLocation="../schema.xsd"> secp160r1-U secg/secp160r1-keyU.csv diff --git a/src/cz/crcs/ectester/data/test/results.xml b/src/cz/crcs/ectester/data/test/results.xml index 11465007..64fa86a1 100644 --- a/src/cz/crcs/ectester/data/test/results.xml +++ b/src/cz/crcs/ectester/data/test/results.xml @@ -1,174 +1,174 @@ - + secp160r1-dh DH secg/secp160r1-dh-sha1.csv secg/secp160r1 test/secp160r1-U test/secp160r1-V - - + + sect163k1-dh DH secg/sect163k1-dh-sha1.csv secg/sect163k1 test/sect163k1-U test/sect163k1-V - + - + brainpoolP224r1-dh DH brainpool/brainpoolP224r1-dh-sha1.csv brainpool/brainpoolP224r1 test/brainpoolP224r1-A test/brainpoolP224r1-B - - + + brainpoolP256r1-dh DH brainpool/brainpoolP256r1-dh-sha1.csv brainpool/brainpoolP256r1 test/brainpoolP256r1-A test/brainpoolP256r1-B - - + + brainpoolP384r1-dh DH brainpool/brainpoolP384r1-dh-sha1.csv brainpool/brainpoolP384r1 test/brainpoolP384r1-A test/brainpoolP384r1-B - - + + brainpoolP512r1-dh DH brainpool/brainpoolP512r1-dh-sha1.csv brainpool/brainpoolP512r1 test/brainpoolP512r1-A test/brainpoolP512r1-B - + - + b163-dhc DHC nist/b163-dhc-sha1.csv nist/B-163 test/b163-A test/b163-B - - + + b233-dhc DHC nist/b233-dhc-sha1.csv nist/B-233 test/b233-A test/b233-B - - + + b283-dhc DHC nist/b283-dhc-sha1.csv nist/B-283 test/b283-A test/b283-B - - + + b409-dhc DHC nist/b409-dhc-sha1.csv nist/B-409 test/b409-A test/b409-B - - + + b571-dhc DHC nist/b571-dhc-sha1.csv nist/B-571 test/b571-A test/b571-B - - + + k163-dhc DHC nist/k163-dhc-sha1.csv nist/B-163 test/k163-A test/k163-B - - + + k233-dhc DHC nist/k233-dhc-sha1.csv nist/B-233 test/k233-A test/k233-B - - + + k283-dhc DHC nist/k283-dhc-sha1.csv nist/B-283 test/k283-A test/k283-B - - + + k409-dhc DHC nist/k409-dhc-sha1.csv nist/B-409 test/k409-A test/k409-B - - + + k571-dhc DHC nist/k571-dhc-sha1.csv nist/B-571 test/k571-A test/k571-B - - + + p192-dhc ANY nist/p192-dhc-sha1.csv nist/P-192 test/p192-A test/p192-B - - + + p224-dhc ANY nist/p224-dhc-sha1.csv nist/P-224 test/p224-A test/p224-B - - + + p256-dhc ANY nist/p256-dhc-sha1.csv nist/P-256 test/p256-A test/p256-B - - + + p384-dhc ANY nist/p384-dhc-sha1.csv nist/P-384 test/p384-A test/p384-B - - + + p521-dhc ANY nist/p521-dhc-sha1.csv nist/P-521 test/p521-A test/p521-B - + \ No newline at end of file diff --git a/src/cz/crcs/ectester/data/twist/keys.xml b/src/cz/crcs/ectester/data/twist/keys.xml index 1acbc31a..df208bf8 100644 --- a/src/cz/crcs/ectester/data/twist/keys.xml +++ b/src/cz/crcs/ectester/data/twist/keys.xml @@ -23,9 +23,7 @@ ]> + xsi:noNamespaceSchemaLocation="../schema.xsd"> &k163; &k233; &k283; diff --git a/src/cz/crcs/ectester/data/wrong/keys.xml b/src/cz/crcs/ectester/data/wrong/keys.xml new file mode 100644 index 00000000..4be8b4dd --- /dev/null +++ b/src/cz/crcs/ectester/data/wrong/keys.xml @@ -0,0 +1,28 @@ + + + + default_pub + 0x116d77bea845d4bd0204cb8b954c957431c23a7111a0eda94d41a3c774260e37,0x9589952dcc2034be9cb36411c59e8978fc40a7ebce5dc296d8c693a25b637969 + secg/secp256r1 + A random public key for default_priv. + + + default_priv + 0x92d375aebbc233bc9b60124ff7adf963917ab77bfc254418900f7ba51c85cc09 + secg/secp256r1 + A random private key for default_pub. + + + negated_pub + 0x116d77bea845d4bd0204cb8b954c957431c23a7111a0eda94d41a3c774260e37,0x6a766ad133dfcb42634c9bee3a61768703bf581531a23d6927396c5da49c8696 + secg/secp256r1 + A negation of default_pub(public key for negated_priv). + + + negated_priv + 0x6d2c8a50443dcc44649fedb00852069c2b6c4331aaf25a6c63aa4f1ddfdd5948 + secg/secp256r1 + A negation of default_priv(private key for negated_pub). + + \ No newline at end of file diff --git a/src/cz/crcs/ectester/data/wrong/results.xml b/src/cz/crcs/ectester/data/wrong/results.xml new file mode 100644 index 00000000..92f43df3 --- /dev/null +++ b/src/cz/crcs/ectester/data/wrong/results.xml @@ -0,0 +1,177 @@ + + + + ok/random + SHA1 + 0x304402203988322ab9f52c7f11d5d1aa92a2ac0b00275bcad8e934682257323fda672482022052231597382268e8f3b82b99e386ebb7c7db1a8b4a8bdacd496190314e4c5bad + 0xABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB + secg/secp256r1 + wrong/default_priv + wrong/default_pub + A correct signature by the default key. + + + nok/negated + SHA1 + 0x304402203988322ab9f52c7f11d5d1aa92a2ac0b00275bcad8e934682257323fda672482022052231597382268e8f3b82b99e386ebb7c7db1a8b4a8bdacd496190314e4c5bad + 0xABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB + secg/secp256r1 + wrong/negated_priv + wrong/negated_pub + A signature made by the default key, to be verified by the negated one. + + + nok/random + SHA1 + 0x30440220e641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c02206baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + A random, well-formed but invalid signature. + + + nok/r0 + SHA1 + 0x3044022000000000000000000000000000000000000000000000000000000000000000000220d0837b07fe63d225733391e6808a081fd8aeb1359511feba7ca4f266727f968e + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with r = 0. + + + nok/s0 + SHA1 + 0x304402206bea66d439da6b0b4a0e45b51e76d53336f27f7aa8e35f2008b77a8e021eff0a02200000000000000000000000000000000000000000000000000000000000000000 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with s = 0. + + + nok/r1 + SHA1 + 0x3044022000000000000000000000000000000000000000000000000000000000000000010220e660f19ddc20a30adda6ca175577b492e238ef8734b904a31045d453825974d4 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with r = 1. + + + nok/s1 + SHA1 + 0x30440220d30ab3301d7132edbead77c0d622bbb7be8626c9ac5ee6c536281e6c18e79ab002200000000000000000000000000000000000000000000000000000000000000001 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with s = 1. + + + nok/r0s0 + SHA1 + 0x30440220000000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000000 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with r = 0 and s = 0. + + + nok/r0s1 + SHA1 + 0x30440220000000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000001 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with r = 0 and s = 1. + + + nok/r1s0 + SHA1 + 0x30440220000000000000000000000000000000000000000000000000000000000000000102200000000000000000000000000000000000000000000000000000000000000000 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with r = 1 and s = 0. + + + nok/r1s1 + SHA1 + 0x30440220000000000000000000000000000000000000000000000000000000000000000102200000000000000000000000000000000000000000000000000000000000000001 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with r = 1 and s = 1. + + + nok/sp + SHA1 + 0x30440220fc48281b60b73752f3e20c25e8a06b335122d5890db28d2969d3145fcd384e7b0220ffffffff00000001000000000000000000000000ffffffffffffffffffffffff + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature s = p. + + + nok/s2p + SHA1 + 0x30450220feba982489753a51a69fd582673d2e62b6b07cc6374237c1424f1e469cb00a98022101fffffffe00000002000000000000000000000001fffffffffffffffffffffffe + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Well-formed invalid signature with s = 2 * p. + + + nok/long + SHA1 + 0x30420220e641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c02206baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Invalid signature, that is longer than specified in its ASN.1 SEQUENCE length header. + + + nok/short + SHA1 + 0x30460220e641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c02206baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Invalid signature, that is shorter than specified in its ASN.1 SEQUENCE length header. + + + nok/long_r + SHA1 + 0x3044021ee641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c02206baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Invalid signature, where r is longer than specified in its ASN.1 length header. + + + nok/long_s + SHA1 + 0x30440220e641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c021e6baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Invalid signature, where s is longer than specified in its ASN.1 length header. + + + nok/short_r + SHA1 + 0x30440222e641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c02206baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Invalid signature, where r is shorter than specified in its ASN.1 length header. + + + nok/short_s + SHA1 + 0x30440220e641671e6415629dc8398e35ae1362cb647f293a92553b1594d57fff58df302c02226baafface035e3758eea0dd9ef734976c70b6dd06f4d81d33f5e28bfb8730624 + secg/secp256r1 + wrong/default_priv + wrong/default_pub + Invalid signature, where s is shorter than specified in its ASN.1 length header. + + \ No newline at end of file diff --git a/src/cz/crcs/ectester/data/wycheproof/keys.xml b/src/cz/crcs/ectester/data/wycheproof/keys.xml index 46cd697d..46359df9 100644 --- a/src/cz/crcs/ectester/data/wycheproof/keys.xml +++ b/src/cz/crcs/ectester/data/wycheproof/keys.xml @@ -1,8 +1,6 @@ + xsi:noNamespaceSchemaLocation="../schema.xsd"> addsub/secp224r1/1s 0x0ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c29b7 diff --git a/src/cz/crcs/ectester/data/wycheproof/results.xml b/src/cz/crcs/ectester/data/wycheproof/results.xml index 5508f4cf..094043cf 100644 --- a/src/cz/crcs/ectester/data/wycheproof/results.xml +++ b/src/cz/crcs/ectester/data/wycheproof/results.xml @@ -1,71 +1,71 @@ - + addsub/secp224r1/1test DH_PLAIN 0x475fd96e0eb8cb8f100a5d7fe043a7a6851d1d611da2643a3c6ae708 secg/secp224r1 wycheproof/addsub/secp224r1/1s wycheproof/addsub/secp224r1/1w - - + + addsub/secp224r1/2test DH_PLAIN 0x41ef931d669d1f57d8bb95a01a92321da74be8c6cbc3bbe0b2e73ebd secg/secp224r1 wycheproof/addsub/secp224r1/2s wycheproof/addsub/secp224r1/2w - - + + addsub/secp224r1/3test DH_PLAIN 0x11ff15126411299cbd49e2b7542e69e91ef132e2551a16ecfebb23a3 secg/secp224r1 wycheproof/addsub/secp224r1/3s wycheproof/addsub/secp224r1/3w - - + + addsub/secp256r1/1test DH_PLAIN 0xf7407d61fdf581be4f564621d590ca9b7ba37f31396150f9922f1501da8c83ef secg/secp256r1 wycheproof/addsub/secp256r1/1s wycheproof/addsub/secp256r1/1w - - + + addsub/secp256r1/2test DH_PLAIN 0x82236fd272208693e0574555ca465c6cc512163486084fa57f5e1bd2e2ccc0b3 secg/secp256r1 wycheproof/addsub/secp256r1/2s wycheproof/addsub/secp256r1/2w - - + + addsub/secp256r1/3test DH_PLAIN 0x06537149664dba1a9924654cb7f787ed224851b0df25ef53fcf54f8f26cd5f3f secg/secp256r1 wycheproof/addsub/secp256r1/3s wycheproof/addsub/secp256r1/3w - - + + addsub/secp256r1/4test DH_PLAIN 0xf2b38539bce995d443c7bfeeefadc9e42cc2c89c60bf4e86eac95d51987bd112 secg/secp256r1 wycheproof/addsub/secp256r1/4s wycheproof/addsub/secp256r1/4w - - + + addsub/secp256r1/5test DH_PLAIN 0x027b013a6f166db655d69d643c127ef8ace175311e667dff2520f5b5c75b7659 secg/secp256r1 wycheproof/addsub/secp256r1/5s wycheproof/addsub/secp256r1/5w - - + + addsub/secp384r1/1test DH_PLAIN 0x2ecf9dc47e8b07ae61ddbd1680ead02698e9e8469f78d5a28328e48d0c9d7a2ac787e50cba58cc44a32fb1235d2d7027 @@ -73,8 +73,8 @@ secg/secp384r1 wycheproof/addsub/secp384r1/1s wycheproof/addsub/secp384r1/1w - - + + addsub/secp384r1/2test DH_PLAIN 0x06ee9f55079d3d3c18c683ba33e0d2521be97c4fbf7917bf3b6287d58ffcde2df88842e3f5530b39549ac20974b1b60e @@ -82,8 +82,8 @@ secg/secp384r1 wycheproof/addsub/secp384r1/2s wycheproof/addsub/secp384r1/2w - - + + addsub/secp384r1/3test DH_PLAIN 0x024c5281487216058270cd1cfe259e948310e4adc263a9edaa4da0bc3f5f8ce8ffc88ae41b2c050bf6dd9c8c66857237 @@ -91,8 +91,8 @@ secg/secp384r1 wycheproof/addsub/secp384r1/3s wycheproof/addsub/secp384r1/3w - - + + addsub/secp521r1/1test DH_PLAIN @@ -101,8 +101,8 @@ secg/secp521r1 wycheproof/addsub/secp521r1/1s wycheproof/addsub/secp521r1/1w - - + + addsub/secp521r1/2test DH_PLAIN @@ -111,8 +111,8 @@ secg/secp521r1 wycheproof/addsub/secp521r1/2s wycheproof/addsub/secp521r1/2w - - + + addsub/secp521r1/3test DH_PLAIN @@ -121,8 +121,8 @@ secg/secp521r1 wycheproof/addsub/secp521r1/3s wycheproof/addsub/secp521r1/3w - - + + addsub/secp521r1/4test DH_PLAIN @@ -131,8 +131,8 @@ secg/secp521r1 wycheproof/addsub/secp521r1/4s wycheproof/addsub/secp521r1/4w - - + + addsub/secp521r1/5test DH_PLAIN @@ -141,8 +141,8 @@ secg/secp521r1 wycheproof/addsub/secp521r1/5s wycheproof/addsub/secp521r1/5w - - + + addsub/secp521r1/6test DH_PLAIN @@ -151,160 +151,160 @@ secg/secp521r1 wycheproof/addsub/secp521r1/6s wycheproof/addsub/secp521r1/6w - - + + addsub/secp256k1/1test DH_PLAIN 0x09c7337df6c2b35edf3a21382511cc5add1a71a84cbf8d3396a5be548d92fa67 secg/secp256k1 wycheproof/addsub/secp256k1/1s wycheproof/addsub/secp256k1/1w - - + + addsub/secp256k1/2test DH_PLAIN 0xd16caedd25793666f9e26f5331382106f54095b3d20d40c745b68ca76c0e6983 secg/secp256k1 wycheproof/addsub/secp256k1/2s wycheproof/addsub/secp256k1/2w - - + + addsub/secp256k1/3test DH_PLAIN 0xb8ae1e21d8b34ce4caffed7167a26868ec80a7d4a6a98b639d4d05cd226504de secg/secp256k1 wycheproof/addsub/secp256k1/3s wycheproof/addsub/secp256k1/3w - - + + addsub/secp256k1/4test DH_PLAIN 0x02776315fe147a36a4b0987492b6503acdea60f926450e5eddb9f88fc82178d3 secg/secp256k1 wycheproof/addsub/secp256k1/4s wycheproof/addsub/secp256k1/4w - - + + addsub/secp256k1/5test DH_PLAIN 0x3988c9c7050a28794934e5bd67629b556d97a4858d22812835f4a37dca351943 secg/secp256k1 wycheproof/addsub/secp256k1/5s wycheproof/addsub/secp256k1/5w - - + + addsub/secp256k1/6test DH_PLAIN 0x4b52257d8b3ba387797fdf7a752f195ddc4f7d76263de61d0d52a5ec14a36cbf secg/secp256k1 wycheproof/addsub/secp256k1/6s wycheproof/addsub/secp256k1/6w - - + + addsub/brainpoolP224r1/1test DH_PLAIN 0x1be0d59d1f0f3a743ae19c5246099391098f71444223831e16cfa0c5 brainpool/brainpoolP224r1 wycheproof/addsub/brainpoolP224r1/1s wycheproof/addsub/brainpoolP224r1/1w - - + + addsub/brainpoolP224r1/2test DH_PLAIN 0x7e00a9267243cea4ba7617860b6fcf404e0357d1202d8c85dc5e07d3 brainpool/brainpoolP224r1 wycheproof/addsub/brainpoolP224r1/2s wycheproof/addsub/brainpoolP224r1/2w - - + + addsub/brainpoolP224r1/3test DH_PLAIN 0xaac6a805f4ce1b6dcc13ec4ed16a889dc4d708f7f6f1e23471338324 brainpool/brainpoolP224r1 wycheproof/addsub/brainpoolP224r1/3s wycheproof/addsub/brainpoolP224r1/3w - - + + addsub/brainpoolP256r1/1test DH_PLAIN 0x1950b7ce510d4d8648e80c6385a42d005433fc5ca61e2022a1405fe18142c246 brainpool/brainpoolP256r1 wycheproof/addsub/brainpoolP256r1/1s wycheproof/addsub/brainpoolP256r1/1w - - + + addsub/brainpoolP256r1/2test DH_PLAIN 0x5c05c4d877a0e2af5ffa004c122630bb87157cf346dbeb8ae13017162da208f4 brainpool/brainpoolP256r1 wycheproof/addsub/brainpoolP256r1/2s wycheproof/addsub/brainpoolP256r1/2w - - + + addsub/brainpoolP256r1/3test DH_PLAIN 0x9639bbd4e22194ce3892a814c82eddbd21dde05cfac20e99396e3d6ef0841f7c brainpool/brainpoolP256r1 wycheproof/addsub/brainpoolP256r1/3s wycheproof/addsub/brainpoolP256r1/3w - - + + addsub/brainpoolP256r1/4test DH_PLAIN 0x341cbdf61f9dd620ba6873a74804afe30a06b0a113a6916a4104d2d4cc196aec brainpool/brainpoolP256r1 wycheproof/addsub/brainpoolP256r1/4s wycheproof/addsub/brainpoolP256r1/4w - - + + addsub/brainpoolP320r1/1test DH_PLAIN 0xc0038da858441f559a864dcd6c4558437f9ad091a67c3fda69a9e0cb6f446a8b47ae95edc2f4eade brainpool/brainpoolP320r1 wycheproof/addsub/brainpoolP320r1/1s wycheproof/addsub/brainpoolP320r1/1w - - + + addsub/brainpoolP320r1/2test DH_PLAIN 0x8258131a80bc9f2b8ba532ef1253ef39dce25e6deb85227c670273521c311dbb9bf1a56dd29107b3 brainpool/brainpoolP320r1 wycheproof/addsub/brainpoolP320r1/2s wycheproof/addsub/brainpoolP320r1/2w - - + + addsub/brainpoolP320r1/3test DH_PLAIN 0xae752e75684a9adfc6198e6c1ce9249d26743104e8b0bd0417998c62982622ea2fdf6917413d547c brainpool/brainpoolP320r1 wycheproof/addsub/brainpoolP320r1/3s wycheproof/addsub/brainpoolP320r1/3w - - + + addsub/brainpoolP320r1/4test DH_PLAIN 0x37bfbb637fce27ee80b3af326546303e0bd8af01b72f591830a548609055bda489d9a4e6b5e3f43e brainpool/brainpoolP320r1 wycheproof/addsub/brainpoolP320r1/4s wycheproof/addsub/brainpoolP320r1/4w - - + + addsub/brainpoolP320r1/5test DH_PLAIN 0x854ce9516e73c6cc8d0d6ce3cdf933541a719578712440f02a86829af1398fcab2bb0949c1d63106 brainpool/brainpoolP320r1 wycheproof/addsub/brainpoolP320r1/5s wycheproof/addsub/brainpoolP320r1/5w - - + + addsub/brainpoolP320r1/6test DH_PLAIN 0x7dfd07c1cfe70db4772cf9f6bb6b58a10bbc9509e5ce86651d5c395f3544f62d6d8f8109edba441a brainpool/brainpoolP320r1 wycheproof/addsub/brainpoolP320r1/6s wycheproof/addsub/brainpoolP320r1/6w - - + + addsub/brainpoolP384r1/1test DH_PLAIN 0x3729bcd215b41c658b832686c81362b3485d75b09478c6dde3b5e278564ef4162bdd6ff65afc6e8213bba9b6c54ba1eb @@ -312,8 +312,8 @@ brainpool/brainpoolP384r1 wycheproof/addsub/brainpoolP384r1/1s wycheproof/addsub/brainpoolP384r1/1w - - + + addsub/brainpoolP384r1/2test DH_PLAIN 0x12ba4622daf1f2f950aad6d54aaab821885a47a98573afea49bc1896041ee9501acef82810f3755ff284e16665bd0f62 @@ -321,8 +321,8 @@ brainpool/brainpoolP384r1 wycheproof/addsub/brainpoolP384r1/2s wycheproof/addsub/brainpoolP384r1/2w - - + + addsub/brainpoolP384r1/3test DH_PLAIN 0x7fb5398519857f2c17cddd0a9d2c1660ac35b4723e4a049ba5c58c458b742dfa813a5c7175e1c0974b514bfaeb0039f8 @@ -330,8 +330,8 @@ brainpool/brainpoolP384r1 wycheproof/addsub/brainpoolP384r1/3s wycheproof/addsub/brainpoolP384r1/3w - - + + addsub/brainpoolP384r1/4test DH_PLAIN 0x0f0a1d20ba6a7b2c48154b43870be4890979d9261950736de96c29f371233b1ef94a79c2ab698868f00cea7e912deb94 @@ -339,8 +339,8 @@ brainpool/brainpoolP384r1 wycheproof/addsub/brainpoolP384r1/4s wycheproof/addsub/brainpoolP384r1/4w - - + + addsub/brainpoolP512r1/1test DH_PLAIN @@ -349,8 +349,8 @@ brainpool/brainpoolP512r1 wycheproof/addsub/brainpoolP512r1/1s wycheproof/addsub/brainpoolP512r1/1w - - + + addsub/brainpoolP512r1/2test DH_PLAIN @@ -359,8 +359,8 @@ brainpool/brainpoolP512r1 wycheproof/addsub/brainpoolP512r1/2s wycheproof/addsub/brainpoolP512r1/2w - - + + addsub/brainpoolP512r1/3test DH_PLAIN @@ -369,8 +369,8 @@ brainpool/brainpoolP512r1 wycheproof/addsub/brainpoolP512r1/3s wycheproof/addsub/brainpoolP512r1/3w - - + + addsub/brainpoolP512r1/4test DH_PLAIN @@ -379,112 +379,112 @@ brainpool/brainpoolP512r1 wycheproof/addsub/brainpoolP512r1/4s wycheproof/addsub/brainpoolP512r1/4w - - + + addsub/brainpoolP224t1/1test DH_PLAIN 0x97ded4c2e06b5a13c9109be3fa42dc2ca93a306fdf9e85ac4bb02e22 brainpool/brainpoolP224t1 wycheproof/addsub/brainpoolP224t1/1s wycheproof/addsub/brainpoolP224t1/1w - - + + addsub/brainpoolP224t1/2test DH_PLAIN 0x686798270c7e188e6ab3e28a10754f965d5d02f33d30d8faf38155f4 brainpool/brainpoolP224t1 wycheproof/addsub/brainpoolP224t1/2s wycheproof/addsub/brainpoolP224t1/2w - - + + addsub/brainpoolP224t1/3test DH_PLAIN 0xd64f68debaf751d63da1883668822031c69e913cc53b969e5fbae845 brainpool/brainpoolP224t1 wycheproof/addsub/brainpoolP224t1/3s wycheproof/addsub/brainpoolP224t1/3w - - + + addsub/brainpoolP256t1/1test DH_PLAIN 0x4875ed4b2bc7e7a0cb89d93b359fa72ddaf0377ddeddd33f62ec2450cd80e7cd brainpool/brainpoolP256t1 wycheproof/addsub/brainpoolP256t1/1s wycheproof/addsub/brainpoolP256t1/1w - - + + addsub/brainpoolP256t1/2test DH_PLAIN 0x315637f94d6776cc3928c1ffbe3c7004aa70b787cc0687faee1da5f9324a36c4 brainpool/brainpoolP256t1 wycheproof/addsub/brainpoolP256t1/2s wycheproof/addsub/brainpoolP256t1/2w - - + + addsub/brainpoolP256t1/3test DH_PLAIN 0x54d1009ab7d3cb9d4314ea7512f7bc4d916ecd47bc9e491ad4a6d65a40672554 brainpool/brainpoolP256t1 wycheproof/addsub/brainpoolP256t1/3s wycheproof/addsub/brainpoolP256t1/3w - - + + addsub/brainpoolP256t1/4test DH_PLAIN 0x892923527eb529de963e902641c01701a66cd999d1b665717d7b11cbb5a96f7c brainpool/brainpoolP256t1 wycheproof/addsub/brainpoolP256t1/4s wycheproof/addsub/brainpoolP256t1/4w - - + + addsub/brainpoolP320t1/1test DH_PLAIN 0x147c9b3b4880f7f6d4eb96f891672cb0d09a6bef15574ab2a43f09ae7f8090cdfa81517e098dac1e brainpool/brainpoolP320t1 wycheproof/addsub/brainpoolP320t1/1s wycheproof/addsub/brainpoolP320t1/1w - - + + addsub/brainpoolP320t1/2test DH_PLAIN 0x47f4412278edc51ba0635853a82e033b164a68194d4c3e2492017432daaa8c35684c343f701f6b02 brainpool/brainpoolP320t1 wycheproof/addsub/brainpoolP320t1/2s wycheproof/addsub/brainpoolP320t1/2w - - + + addsub/brainpoolP320t1/3test DH_PLAIN 0xa64c2b075abf446a9ba43f6ffcefda795835ab2e1c4d19bd9c9ede59cd9eaf9c831a520b1e0ce269 brainpool/brainpoolP320t1 wycheproof/addsub/brainpoolP320t1/3s wycheproof/addsub/brainpoolP320t1/3w - - + + addsub/brainpoolP320t1/4test DH_PLAIN 0xb3b25821ac9b07c614f6fce7f9a1c2325d3cbd51cac82dadeb79037a23bce03b0352407ccd447af8 brainpool/brainpoolP320t1 wycheproof/addsub/brainpoolP320t1/4s wycheproof/addsub/brainpoolP320t1/4w - - + + addsub/brainpoolP320t1/5test DH_PLAIN 0x594aebd8010757d15f79631af0e481310359e0086e4e988ab5525a9303aaf800cd4ef123ceb68875 brainpool/brainpoolP320t1 wycheproof/addsub/brainpoolP320t1/5s wycheproof/addsub/brainpoolP320t1/5w - - + + addsub/brainpoolP320t1/6test DH_PLAIN 0xc7e67dc2f64d0e66841777a6f014340b8a63f42024c6cd5ac5e10cec3b02a2d050c2fd8f078a754f brainpool/brainpoolP320t1 wycheproof/addsub/brainpoolP320t1/6s wycheproof/addsub/brainpoolP320t1/6w - - + + addsub/brainpoolP384t1/1test DH_PLAIN 0x22d772bd2104c3d24b8505b3e7d1f3f00ca2dacb493ca729170854ef2158407a0ffab006153d5cb7781e9cb57cda505f @@ -492,8 +492,8 @@ brainpool/brainpoolP384t1 wycheproof/addsub/brainpoolP384t1/1s wycheproof/addsub/brainpoolP384t1/1w - - + + addsub/brainpoolP384t1/2test DH_PLAIN 0x2b2c617f8c84713f8440e5e273341d69edf9e6ea2056af38ccfc6ee733a9c11e1f9aa63cb3615d2b3cebe69d8360a2bd @@ -501,8 +501,8 @@ brainpool/brainpoolP384t1 wycheproof/addsub/brainpoolP384t1/2s wycheproof/addsub/brainpoolP384t1/2w - - + + addsub/brainpoolP384t1/3test DH_PLAIN 0x28518f75e020e00095d47166f7825f1767b6425172decde390c9266764c8b631608dc323b8415c39c9d0b8a24cd337ac @@ -510,8 +510,8 @@ brainpool/brainpoolP384t1 wycheproof/addsub/brainpoolP384t1/3s wycheproof/addsub/brainpoolP384t1/3w - - + + addsub/brainpoolP384t1/4test DH_PLAIN 0x4424a1b48eba0524e4aa82455e282b35cf0d13d8536fe6c410cd5050f3d4d1739254945a8f580d43ee0245b1df67de56 @@ -519,8 +519,8 @@ brainpool/brainpoolP384t1 wycheproof/addsub/brainpoolP384t1/4s wycheproof/addsub/brainpoolP384t1/4w - - + + addsub/brainpoolP512t1/1test DH_PLAIN @@ -529,8 +529,8 @@ brainpool/brainpoolP512t1 wycheproof/addsub/brainpoolP512t1/1s wycheproof/addsub/brainpoolP512t1/1w - - + + addsub/brainpoolP512t1/2test DH_PLAIN @@ -539,8 +539,8 @@ brainpool/brainpoolP512t1 wycheproof/addsub/brainpoolP512t1/2s wycheproof/addsub/brainpoolP512t1/2w - - + + addsub/brainpoolP512t1/3test DH_PLAIN @@ -549,8 +549,8 @@ brainpool/brainpoolP512t1 wycheproof/addsub/brainpoolP512t1/3s wycheproof/addsub/brainpoolP512t1/3w - - + + addsub/brainpoolP512t1/4test DH_PLAIN @@ -559,8 +559,8 @@ brainpool/brainpoolP512t1 wycheproof/addsub/brainpoolP512t1/4s wycheproof/addsub/brainpoolP512t1/4w - - + + cve_2017_10176/secp521r1/1test DH_PLAIN @@ -569,21 +569,21 @@ secg/secp521r1 wycheproof/cve_2017_10176/secp521r1/1s wycheproof/cve_2017_10176/secp521r1/1w - - + + cve_2017_8932/secp256r1/1test DH_PLAIN 0x4d4de80f1534850d261075997e3049321a0864082d24a917863366c0724f5ae3 secg/secp256r1 wycheproof/cve_2017_8932/secp256r1/1s wycheproof/cve_2017_8932/secp256r1/1w - - + + cve_2017_8932/secp256r1/2test DH_PLAIN 0x831c3f6b5f762d2f461901577af41354ac5f228c2591f84f8a6e51e2e3f17991 secg/secp256r1 wycheproof/cve_2017_8932/secp256r1/2s wycheproof/cve_2017_8932/secp256r1/2w - + \ 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 4a7d7795..5c50bf21 100644 --- a/src/cz/crcs/ectester/reader/ECTesterReader.java +++ b/src/cz/crcs/ectester/reader/ECTesterReader.java @@ -26,7 +26,6 @@ import cz.crcs.ectester.applet.EC_Consts; import cz.crcs.ectester.common.cli.CLITools; import cz.crcs.ectester.common.cli.Colors; -import cz.crcs.ectester.common.ec.EC_Params; import cz.crcs.ectester.common.output.OutputLogger; import cz.crcs.ectester.common.output.TestWriter; import cz.crcs.ectester.common.util.ByteUtil; @@ -94,7 +93,6 @@ public class ECTesterReader { DESCRIPTION = "ECTesterReader " + VERSION + GIT_COMMIT + ", a javacard Elliptic Curve Cryptography support tester/utility."; CLI_HEADER = "\n" + DESCRIPTION + "\n\n"; - ; } private void run(String[] args) { @@ -276,18 +274,14 @@ private CommandLine parseArgs(String[] args) throws ParseException { actions.addOption(Option.builder("ln").longOpt("list-named").desc("Print the list of supported named curves and keys.").hasArg().argName("what").optionalArg(true).build()); 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 of EC keys.").hasArg().argName("amount").optionalArg(true).build()); - actions.addOption(Option.builder("t").longOpt("test").desc("Test ECC support. Optionally specify a test number to run only a part of a test suite. :\n- default:\n- compression:\n- invalid:\n- twist:\n- degenerate:\n- cofactor:\n- wrong:\n- composite:\n- test-vectors:\n- edge-cases:\n- miscellaneous:").hasArg().argName("test_suite[:from[:to]]").optionalArg(true).build()); + actions.addOption(Option.builder("t").longOpt("test").desc("Test ECC support. Optionally specify a test number to run only a part of a test suite. :\n- default:\n- compression:\n- invalid:\n- twist:\n- degenerate:\n- cofactor:\n- wrong:\n- signature:\n- composite:\n- test-vectors:\n- edge-cases:\n- miscellaneous:").hasArg().argName("test_suite[:from[:to]]").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()); actions.addOption(Option.builder("ls").longOpt("list-suites").desc("List supported test suites.").build()); opts.addOptionGroup(actions); - OptionGroup size = new OptionGroup(); - size.addOption(Option.builder("b").longOpt("bit-size").desc("Set curve size.").hasArg().argName("bits").build()); - size.addOption(Option.builder("a").longOpt("all").desc("Test all curve sizes.").build()); - opts.addOptionGroup(size); - + opts.addOption(Option.builder("b").longOpt("bit-size").desc("Set curve size.").hasArg().argName("bits").build()); opts.addOption(Option.builder("fp").longOpt("prime-field").desc("Use a prime field.").build()); opts.addOption(Option.builder("f2m").longOpt("binary-field").desc("Use a binary field.").build()); @@ -342,6 +336,7 @@ private void listSuites() { new CardCompositeSuite(null, null, null), new CardInvalidSuite(null, null, null), new CardEdgeCasesSuite(null, null, null), + new CardSignatureSuite(null, null, null), new CardTwistSuite(null, null, null), new CardMiscSuite(null, null, null)}; for (CardTestSuite suite : suites) { @@ -363,9 +358,15 @@ private void export() throws CardException, IOException { List sent = new LinkedList<>(); sent.add(new Command.Allocate(cardManager, ECTesterApplet.KEYPAIR_LOCAL, cfg.bits, keyClass).send()); - sent.add(new Command.Clear(cardManager, ECTesterApplet.KEYPAIR_LOCAL).send()); + //sent.add(new Command.Clear(cardManager, ECTesterApplet.KEYPAIR_LOCAL).send()); sent.add(new Command.Generate(cardManager, ECTesterApplet.KEYPAIR_LOCAL).send()); + // Also support exporting set parameters, to verify they are set correctly. + Command curve = Command.prepareCurve(cardManager, EC_Store.getInstance(), cfg, ECTesterApplet.KEYPAIR_LOCAL, cfg.bits, keyClass); + if (curve != null) { + sent.add(curve.send()); + } + // Cofactor generally isn't set on the default curve parameters on cards, // since its not necessary for ECDH, only ECDHC which not many cards implement // TODO: check if its assumend to be == 1? @@ -476,6 +477,9 @@ private void test() throws ParserConfigurationException, IOException { case "miscellaneous": suite = new CardMiscSuite(writer, cfg, cardManager); break; + case "signature": + suite = new CardSignatureSuite(writer, cfg, cardManager); + break; default: // These run are dangerous, prompt before them. System.out.println("The test you selected (" + cfg.testSuite + ") is potentially dangerous."); @@ -804,10 +808,6 @@ boolean readOptions(CommandLine cli) { System.err.println(Colors.error("Keys should not be specified when exporting curve params.")); return false; } - if (namedCurve != null || customCurve || curveFile != null) { - System.err.println(Colors.error("Specifying a curve for curve export makes no sense.")); - return false; - } if (outputs == null) { System.err.println(Colors.error("You have to specify an output file for curve parameter export.")); return false; @@ -873,7 +873,7 @@ boolean readOptions(CommandLine cli) { testFrom = 0; testTo = -1; } - String[] tests = new String[]{"default", "composite", "compression", "invalid", "degenerate", "test-vectors", "wrong", "twist", "cofactor", "edge-cases", "miscellaneous"}; + String[] tests = new String[]{"default", "composite", "compression", "invalid", "degenerate", "test-vectors", "wrong", "twist", "cofactor", "edge-cases", "miscellaneous", "signature"}; if (!Arrays.asList(tests).contains(testSuite)) { System.err.println(Colors.error("Unknown test suite " + testSuite + ". Should be one of: " + Arrays.toString(tests))); return false; diff --git a/src/cz/crcs/ectester/reader/command/Command.java b/src/cz/crcs/ectester/reader/command/Command.java index 858b05fa..5a4af210 100644 --- a/src/cz/crcs/ectester/reader/command/Command.java +++ b/src/cz/crcs/ectester/reader/command/Command.java @@ -417,11 +417,11 @@ public static class Transform extends Command { private short transformation; /** - * @param cardManager cardManager to send APDU through - * @param keyPair which keyPair to transform, local/remote (KEYPAIR_* || ...) - * @param key key to transform (EC_Consts.KEY_* | ...) - * @param params parameters to transform (EC_Consts.PARAMETER_* | ...) - * @param transformation transformation type (EC_Consts.TRANSFORMATION_*) + * @param cardManager cardManager to send APDU through + * @param keyPair which keyPair to transform, local/remote (KEYPAIR_* || ...) + * @param key key to transform (EC_Consts.KEY_* | ...) + * @param params parameters to transform (EC_Consts.PARAMETER_* | ...) + * @param transformation transformation type (EC_Consts.TRANSFORMATION_*) */ public Transform(CardMngr cardManager, byte keyPair, byte key, short params, short transformation) { super(cardManager); @@ -568,12 +568,12 @@ public static class ECDH extends Command { /** * Creates the INS_ECDH instruction. * - * @param cardManager cardManager to send APDU through - * @param pubkey keyPair to use for public key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) - * @param privkey keyPair to use for private key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) - * @param export whether to export ECDH secret - * @param transformation whether to transform the pubkey before ECDH (EC_Consts.TRANSFORMATION_* | ...) - * @param type ECDH algorithm type (EC_Consts.KA_* | ...) + * @param cardManager cardManager to send APDU through + * @param pubkey keyPair to use for public key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) + * @param privkey keyPair to use for private key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) + * @param export whether to export ECDH secret + * @param transformation whether to transform the pubkey before ECDH (EC_Consts.TRANSFORMATION_* | ...) + * @param type ECDH algorithm type (EC_Consts.KA_* | ...) */ public ECDH(CardMngr cardManager, byte pubkey, byte privkey, byte export, short transformation, byte type) { super(cardManager); @@ -627,12 +627,12 @@ public static class ECDH_direct extends Command { /** * Creates the INS_ECDH_DIRECT instruction. * - * @param cardManager cardManager to send APDU through - * @param privkey keyPair to use for private key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) - * @param export whether to export ECDH secret - * @param transformation whether to transform the pubkey before ECDH (EC_Consts.TRANSFORMATION_* | ...) - * @param type EC KeyAgreement type - * @param pubkey pubkey data to do ECDH with. + * @param cardManager cardManager to send APDU through + * @param privkey keyPair to use for private key, (KEYPAIR_LOCAL || KEYPAIR_REMOTE) + * @param export whether to export ECDH secret + * @param transformation whether to transform the pubkey before ECDH (EC_Consts.TRANSFORMATION_* | ...) + * @param type EC KeyAgreement type + * @param pubkey pubkey data to do ECDH with. */ public ECDH_direct(CardMngr cardManager, byte privkey, byte export, short transformation, byte type, byte[] pubkey) { super(cardManager); diff --git a/src/cz/crcs/ectester/reader/output/FileTestWriter.java b/src/cz/crcs/ectester/reader/output/FileTestWriter.java index e4ef9b83..69e5f411 100644 --- a/src/cz/crcs/ectester/reader/output/FileTestWriter.java +++ b/src/cz/crcs/ectester/reader/output/FileTestWriter.java @@ -26,7 +26,7 @@ public FileTestWriter(String defaultFormat, boolean systemOut, String[] files) t String fName = files[i]; String format = null; if (PREFIX.matcher(fName).matches()) { - String[] split = fName.split(":",2); + String[] split = fName.split(":", 2); format = split[0]; fName = split[1]; } diff --git a/src/cz/crcs/ectester/reader/output/YAMLTestWriter.java b/src/cz/crcs/ectester/reader/output/YAMLTestWriter.java index 080fa8bd..7c99a4ac 100644 --- a/src/cz/crcs/ectester/reader/output/YAMLTestWriter.java +++ b/src/cz/crcs/ectester/reader/output/YAMLTestWriter.java @@ -13,7 +13,10 @@ import javax.smartcardio.CardException; import java.io.PrintStream; -import java.util.*; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** * @author Jan Jancar johny@neuromancer.sk diff --git a/src/cz/crcs/ectester/reader/test/CardCofactorSuite.java b/src/cz/crcs/ectester/reader/test/CardCofactorSuite.java index 39024b89..710b7043 100644 --- a/src/cz/crcs/ectester/reader/test/CardCofactorSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardCofactorSuite.java @@ -6,7 +6,9 @@ import cz.crcs.ectester.common.ec.EC_Key; import cz.crcs.ectester.common.output.TestWriter; import cz.crcs.ectester.common.test.CompoundTest; +import cz.crcs.ectester.common.test.Result; import cz.crcs.ectester.common.test.Test; +import cz.crcs.ectester.common.util.CardUtil; import cz.crcs.ectester.data.EC_Store; import cz.crcs.ectester.reader.CardMngr; import cz.crcs.ectester.reader.ECTesterReader; @@ -15,7 +17,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Random; import static cz.crcs.ectester.common.test.Result.ExpectedValue; @@ -43,34 +44,20 @@ protected void runTests() throws Exception { List ecdhTests = new LinkedList<>(); for (EC_Key.Public pub : keys) { + Test setPub = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()), Result.ExpectedValue.FAILURE); + Test ecdh = CommandTest.expect(new Command.ECDH(this.card, ECTesterApplet.KEYPAIR_REMOTE, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH), Result.ExpectedValue.FAILURE); + Test objectEcdh = CompoundTest.all(Result.ExpectedValue.SUCCESS, CardUtil.getKATypeString(EC_Consts.KeyAgreement_ALG_EC_SVDP_DH) + " test with degenerate pubkey.", setPub, ecdh); Command ecdhCommand = new Command.ECDH_direct(this.card, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH, pub.flatten()); - ecdhTests.add(CommandTest.expect(ecdhCommand, ExpectedValue.FAILURE, "Card correctly rejected point on non-generator subgroup.", "Card incorrectly accepted point on non-generator subgroup.")); + Test rawEcdh = CommandTest.expect(ecdhCommand, ExpectedValue.FAILURE, "Card correctly rejected point on non-generator subgroup.", "Card incorrectly accepted point on non-generator subgroup."); + ecdhTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, pub.getId() + " cofactor key test.", objectEcdh, rawEcdh)); } Test ecdh = CompoundTest.all(ExpectedValue.SUCCESS, "Perform ECDH with public points on non-generator subgroup.", ecdhTests.toArray(new Test[0])); - Random r = new Random(); - byte[] raw = new byte[128]; - byte[] sig = new byte[40]; - r.nextBytes(raw); - r.nextBytes(sig); - - List ecdsaTests = new LinkedList<>(); - for (EC_Key.Public pub : keys) { - Command setCommand = new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()); - Test setTest = CommandTest.expect(setCommand, ExpectedValue.ANY); - Command ecdsaCommand = new Command.ECDSA_verify(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.Signature_ALG_ECDSA_SHA, raw, sig); - Test ecdsaTest = CommandTest.expect(ecdsaCommand, ExpectedValue.FAILURE); - ecdsaTests.add(CompoundTest.all(ExpectedValue.SUCCESS, "Verify random ECDSA signature by " + pub.getId() + ".", setTest, ecdsaTest)); - } - Test ecdsa = CompoundTest.all(ExpectedValue.SUCCESS, "Verify random ECDSA signature by public points on non-generator subgroup.", ecdsaTests.toArray(new Test[0])); - - Test tests = CompoundTest.all(ExpectedValue.SUCCESS, "Perform ECDH and ECDSA tests.", ecdh, ecdsa); - if (cfg.cleanup) { - Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.SUCCESS); - doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Cofactor test of " + curve.getId() + ".", prepare, tests, cleanup)); + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.ANY); + doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Cofactor test of " + curve.getId() + ".", prepare, ecdh, cleanup)); } else { - doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Cofactor test of " + curve.getId() + ".", prepare, tests)); + doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Cofactor test of " + curve.getId() + ".", prepare, ecdh)); } } } diff --git a/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java b/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java index ec569017..336b371d 100644 --- a/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java @@ -97,6 +97,7 @@ private void testGroup(List curves, String testName, ExpectedValue dhV Test set = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_BOTH, EC_Consts.CURVE_external, curve.getParams(), curve.flatten()), ExpectedValue.ANY); Test generate = CommandTest.expect(new Command.Generate(this.card, ECTesterApplet.KEYPAIR_BOTH), ExpectedValue.ANY); Test ecdh = CommandTest.expect(new Command.ECDH(this.card, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.KEYPAIR_REMOTE, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH), dhValue, ok, nok); + Test ecdsa = CommandTest.expect(new Command.ECDSA(this.card, ECTesterApplet.KEYPAIR_LOCAL, EC_Consts.Signature_ALG_ECDSA_SHA, ECTesterApplet.EXPORT_FALSE, null), dhValue, ok, nok); String description; if (testName == null) { @@ -104,11 +105,14 @@ private void testGroup(List curves, String testName, ExpectedValue dhV } else { description = testName + " test of " + curve.getId() + "."; } + + Test perform = CompoundTest.all(ExpectedValue.SUCCESS, "Perform ECDH and ECDSA.", ecdh, ecdsa); + if (cfg.cleanup) { - Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.SUCCESS); - doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, description, allocate, set, generate, ecdh, cleanup)); + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.ANY); + doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, description, allocate, set, generate, perform, cleanup)); } else { - doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, description, allocate, set, generate, ecdh)); + doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, description, allocate, set, generate, perform)); } } diff --git a/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java b/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java index 5e8f600e..ae25bf1b 100644 --- a/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java @@ -113,7 +113,7 @@ private void runCompression(byte field) throws Exception { } compressionTests.addAll(kaTests); if (cfg.cleanup) { - compressionTests.add(CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.SUCCESS)); + compressionTests.add(CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY)); } doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Compression test of " + spec + ".", compressionTests.toArray(new Test[0]))); diff --git a/src/cz/crcs/ectester/reader/test/CardDefaultSuite.java b/src/cz/crcs/ectester/reader/test/CardDefaultSuite.java index fa9bfd02..e495b00c 100644 --- a/src/cz/crcs/ectester/reader/test/CardDefaultSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardDefaultSuite.java @@ -131,7 +131,7 @@ private void runDefault(byte field) throws Exception { ExpectedValue[] testExpects = {ExpectedValue.SUCCESS, ExpectedValue.ANY, ExpectedValue.SUCCESS, ExpectedValue.SUCCESS, ExpectedValue.SUCCESS, ExpectedValue.SUCCESS, ExpectedValue.SUCCESS}; List expects = Stream.of(testExpects).collect(Collectors.toList()); if (cfg.cleanup) { - supportTests.add(CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.SUCCESS)); + supportTests.add(CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY)); expects.add(ExpectedValue.ANY); } diff --git a/src/cz/crcs/ectester/reader/test/CardDegenerateSuite.java b/src/cz/crcs/ectester/reader/test/CardDegenerateSuite.java index 064c6cb2..c926a4d9 100644 --- a/src/cz/crcs/ectester/reader/test/CardDegenerateSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardDegenerateSuite.java @@ -8,6 +8,7 @@ import cz.crcs.ectester.common.test.CompoundTest; import cz.crcs.ectester.common.test.Result; import cz.crcs.ectester.common.test.Test; +import cz.crcs.ectester.common.util.CardUtil; import cz.crcs.ectester.data.EC_Store; import cz.crcs.ectester.reader.CardMngr; import cz.crcs.ectester.reader.ECTesterReader; @@ -43,12 +44,16 @@ protected void runTests() throws Exception { List ecdhTests = new LinkedList<>(); for (EC_Key.Public pub : keys) { + Test setPub = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()), Result.ExpectedValue.FAILURE); + Test ecdh = CommandTest.expect(new Command.ECDH(this.card, ECTesterApplet.KEYPAIR_REMOTE, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH), Result.ExpectedValue.FAILURE); + Test objectEcdh = CompoundTest.any(Result.ExpectedValue.SUCCESS, CardUtil.getKATypeString(EC_Consts.KeyAgreement_ALG_EC_SVDP_DH) + " test with degenerate pubkey.", setPub, ecdh); Command ecdhCommand = new Command.ECDH_direct(this.card, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH, pub.flatten()); - ecdhTests.add(CommandTest.expect(ecdhCommand, Result.ExpectedValue.FAILURE, "Card correctly rejected point on degenerate curve.", "Card incorrectly accepted point on degenerate curve.")); + Test rawEcdh = CommandTest.expect(ecdhCommand, Result.ExpectedValue.FAILURE, "Card correctly rejected point on degenerate curve.", "Card incorrectly accepted point on degenerate curve."); + ecdhTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, pub.getId() + " degenerate key test.", objectEcdh, rawEcdh)); } Test ecdh = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform ECDH with degenerate public points", ecdhTests.toArray(new Test[0])); if (cfg.cleanup) { - Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.SUCCESS); + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY); doTest(CompoundTest.greedyAllTry(Result.ExpectedValue.SUCCESS, "Degenerate curve test of " + curve.getId(), prepare, ecdh, cleanup)); } else { doTest(CompoundTest.greedyAllTry(Result.ExpectedValue.SUCCESS, "Degenerate curve test of " + curve.getId(), prepare, ecdh)); diff --git a/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java b/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java index dc489a01..b68b2ec7 100644 --- a/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java @@ -21,11 +21,9 @@ import javacard.security.CryptoException; import javacard.security.KeyPair; +import java.math.BigDecimal; import java.math.BigInteger; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Random; +import java.util.*; import java.util.stream.Collectors; /** @@ -112,8 +110,37 @@ public Result apply(CommandTestable testable) { doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, description, groupTests.toArray(new Test[0]))); } + { + EC_KAResult openssl_bug = EC_Store.getInstance().getObject(EC_KAResult.class, "other", "openssl-bug"); + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, openssl_bug.getCurve()); + EC_Key.Private skey = EC_Store.getInstance().getObject(EC_Key.Private.class, openssl_bug.getOtherKey()); + EC_Key.Public pkey = EC_Store.getInstance().getObject(EC_Key.Public.class, openssl_bug.getOneKey()); + Test key = CommandTest.expect(new Command.Allocate(this.card, ECTesterApplet.KEYPAIR_BOTH, curve.getBits(), KeyPair.ALG_EC_FP), Result.ExpectedValue.SUCCESS); + Test set = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_BOTH, EC_Consts.CURVE_external, curve.getParams(), curve.flatten()), Result.ExpectedValue.SUCCESS); + Test setPrivate = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_LOCAL, EC_Consts.CURVE_external, EC_Consts.PARAMETER_S, skey.flatten(EC_Consts.PARAMETER_S)), Result.ExpectedValue.SUCCESS); + Test setPublic = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, EC_Consts.PARAMETER_W, pkey.flatten(EC_Consts.PARAMETER_W)), Result.ExpectedValue.SUCCESS); + Test ecdh = CommandTest.function(new Command.ECDH(this.card, ECTesterApplet.KEYPAIR_REMOTE, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_TRUE, EC_Consts.TRANSFORMATION_NONE, openssl_bug.getJavaCardKA()), new TestCallback() { + @Override + public Result apply(CommandTestable testable) { + Response.ECDH dh = (Response.ECDH) testable.getResponse(); + if (!dh.successful()) + return new Result(Result.Value.FAILURE, "ECDH was unsuccessful."); + if (!dh.hasSecret()) + return new Result(Result.Value.FAILURE, "ECDH response did not contain the derived secret."); + if (ByteUtil.compareBytes(dh.getSecret(), 0, openssl_bug.getData(0), 0, dh.secretLength())) { + return new Result(Result.Value.FAILURE, "OpenSSL bug is present, derived secret matches example."); + } + return new Result(Result.Value.SUCCESS); + } + }); + + doTest(CompoundTest.greedyAll(Result.ExpectedValue.SUCCESS, "Test OpenSSL modular reduction bug.", key, set, setPrivate, setPublic, ecdh)); + } + Map curveMap = EC_Store.getInstance().getObjects(EC_Curve.class, "secg"); List curves = curveMap.entrySet().stream().filter((e) -> e.getKey().endsWith("r1") && e.getValue().getField() == KeyPair.ALG_EC_FP).map(Map.Entry::getValue).collect(Collectors.toList()); + curves.add(EC_Store.getInstance().getObject(EC_Curve.class, "cofactor/cofactor128p2")); + curves.add(EC_Store.getInstance().getObject(EC_Curve.class, "cofactor/cofactor160p4")); Random rand = new Random(); for (EC_Curve curve : curves) { Test key = runTest(CommandTest.expect(new Command.Allocate(this.card, ECTesterApplet.KEYPAIR_BOTH, curve.getBits(), KeyPair.ALG_EC_FP), Result.ExpectedValue.SUCCESS)); @@ -128,13 +155,18 @@ public Result apply(CommandTestable testable) { Test zeroS = ecdhTest(new Command.Transform(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, EC_Consts.PARAMETER_S, EC_Consts.TRANSFORMATION_ZERO), "ECDH with S = 0.", Result.ExpectedValue.FAILURE, Result.ExpectedValue.FAILURE); Test oneS = ecdhTest(new Command.Transform(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, EC_Consts.PARAMETER_S, EC_Consts.TRANSFORMATION_ONE), "ECDH with S = 1.", Result.ExpectedValue.FAILURE, Result.ExpectedValue.FAILURE); - byte[] r = curve.getParam(EC_Consts.PARAMETER_R)[0]; - BigInteger R = new BigInteger(1, r); + byte[] rParam = curve.getParam(EC_Consts.PARAMETER_R)[0]; + BigInteger R = new BigInteger(1, rParam); BigInteger smaller = new BigInteger(curve.getBits(), rand).mod(R); BigInteger diff = R.divide(BigInteger.valueOf(10)); BigInteger randDiff = new BigInteger(diff.bitLength(), rand).mod(diff); BigInteger larger = R.add(randDiff); + BigInteger full = BigInteger.valueOf(1).shiftLeft(R.bitLength() - 1).subtract(BigInteger.ONE); + + EC_Params fullParams = makeParams(full); + Test fullS = ecdhTest(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, fullParams.getParams(), fullParams.flatten()), "ECDH with S = 2^((log2 r) - 1) - 1.", Result.ExpectedValue.SUCCESS, Result.ExpectedValue.SUCCESS); + EC_Params smallerParams = makeParams(smaller); Test smallerS = ecdhTest(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, smallerParams.getParams(), smallerParams.flatten()), "ECDH with S < r.", Result.ExpectedValue.SUCCESS, Result.ExpectedValue.SUCCESS); @@ -168,8 +200,75 @@ public Result apply(CommandTestable testable) { EC_Params krp1Params = makeParams(krp1); Test krp1S = ecdhTest(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, krp1Params.getParams(), krp1Params.flatten()), "ECDH with S = (k * r) + 1.", Result.ExpectedValue.FAILURE, Result.ExpectedValue.FAILURE); - doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with edge-case private key values over " + curve.getId() + ".", setup, zeroS, oneS, smallerS, exactS, largerS, rm1S, rp1S, krS, krm1S, krp1S)); + if (cfg.cleanup) { + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY); + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with edge-case private key values over " + curve.getId() + ".", setup, zeroS, oneS, fullS, smallerS, exactS, largerS, rm1S, rp1S, krS, krm1S, krp1S, cleanup)); + } else { + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with edge-case private key values over " + curve.getId() + ".", setup, zeroS, oneS, fullS, smallerS, exactS, largerS, rm1S, rp1S, krS, krm1S, krp1S)); + } + } + + EC_Curve secp160r1 = EC_Store.getInstance().getObject(EC_Curve.class, "secg/secp160r1"); + byte[] pData = secp160r1.getParam(EC_Consts.PARAMETER_FP)[0]; + BigInteger p = new BigInteger(1, pData); + byte[] rData = secp160r1.getParam(EC_Consts.PARAMETER_R)[0]; + BigInteger r = new BigInteger(1, rData); + + BigInteger range = r.subtract(p); + BigInteger deviation = range.divide(BigInteger.valueOf(5)); + BigDecimal dev = new BigDecimal(deviation); + BigDecimal smallDev = new BigDecimal(10000); + int n = 10; + BigInteger[] rs = new BigInteger[n]; + BigInteger[] ps = new BigInteger[n]; + BigInteger[] zeros = new BigInteger[n]; + for (int i = 0; i < n; ++i) { + double sample; + do { + sample = rand.nextGaussian(); + } while (sample >= -1 && sample <= 1); + BigInteger where = dev.multiply(new BigDecimal(sample)).toBigInteger(); + rs[i] = where.add(r); + ps[i] = where.add(p); + zeros[i] = smallDev.multiply(new BigDecimal(sample)).toBigInteger().abs(); + } + Arrays.sort(rs); + Arrays.sort(ps); + Arrays.sort(zeros); + + Test key = runTest(CommandTest.expect(new Command.Allocate(this.card, ECTesterApplet.KEYPAIR_BOTH, secp160r1.getBits(), KeyPair.ALG_EC_FP), Result.ExpectedValue.SUCCESS)); + if (!key.ok()) { + doTest(CompoundTest.all(Result.ExpectedValue.FAILURE, "No support for " + secp160r1.getBits() + "b ALG_EC_FP.", key)); + return; + } + Test set = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_BOTH, EC_Consts.CURVE_external, secp160r1.getParams(), secp160r1.flatten()), Result.ExpectedValue.SUCCESS); + Test generate = CommandTest.expect(new Command.Generate(this.card, ECTesterApplet.KEYPAIR_LOCAL), Result.ExpectedValue.SUCCESS); + Test setup = CompoundTest.all(Result.ExpectedValue.SUCCESS, "KeyPair setup.", key, set, generate); + + Test[] zeroTests = new Test[n]; + int i = 0; + for (BigInteger nearZero : zeros) { + EC_Params params = makeParams(nearZero); + zeroTests[i++] = ecdhTest(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, params.getParams(), params.flatten()), nearZero.toString(16), Result.ExpectedValue.ANY, Result.ExpectedValue.ANY); + } + Test zeroTest = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Near zero.", zeroTests); + + Test[] pTests = new Test[n]; + i = 0; + for (BigInteger nearP : ps) { + EC_Params params = makeParams(nearP); + pTests[i++] = ecdhTest(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, params.getParams(), params.flatten()), nearP.toString(16) + (nearP.compareTo(p) > 0 ? " (>p)" : " (<=p)"), Result.ExpectedValue.ANY, Result.ExpectedValue.ANY); + } + Test pTest = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Near p.", pTests); + + Test[] rTests = new Test[n]; + i = 0; + for (BigInteger nearR : rs) { + EC_Params params = makeParams(nearR); + rTests[i++] = ecdhTest(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, params.getParams(), params.flatten()), nearR.toString(16) + (nearR.compareTo(r) > 0 ? " (>r)" : " (<=r)"), Result.ExpectedValue.ANY, Result.ExpectedValue.ANY); } + Test rTest = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Near r.", rTests); + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Test private key values near zero, near p and near/larger than the order.", setup, zeroTest, pTest, rTest)); } private Test ecdhTest(Command setPriv, String desc, Result.ExpectedValue setExpect, Result.ExpectedValue ecdhExpect) { diff --git a/src/cz/crcs/ectester/reader/test/CardInvalidSuite.java b/src/cz/crcs/ectester/reader/test/CardInvalidSuite.java index 59a427fc..17c5d4b3 100644 --- a/src/cz/crcs/ectester/reader/test/CardInvalidSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardInvalidSuite.java @@ -8,6 +8,7 @@ import cz.crcs.ectester.common.test.CompoundTest; import cz.crcs.ectester.common.test.Result; import cz.crcs.ectester.common.test.Test; +import cz.crcs.ectester.common.util.CardUtil; import cz.crcs.ectester.data.EC_Store; import cz.crcs.ectester.reader.CardMngr; import cz.crcs.ectester.reader.ECTesterReader; @@ -16,7 +17,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Random; import static cz.crcs.ectester.common.test.Result.ExpectedValue; @@ -48,33 +48,20 @@ protected void runTests() throws Exception { List ecdhTests = new LinkedList<>(); for (EC_Key.Public pub : keys) { + Test setPub = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()), Result.ExpectedValue.FAILURE); + Test ecdh = CommandTest.expect(new Command.ECDH(this.card, ECTesterApplet.KEYPAIR_REMOTE, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH), Result.ExpectedValue.FAILURE); + Test objectEcdh = CompoundTest.any(Result.ExpectedValue.SUCCESS, CardUtil.getKATypeString(EC_Consts.KeyAgreement_ALG_EC_SVDP_DH) + " test with invalid pubkey.", setPub, ecdh); Command ecdhCommand = new Command.ECDH_direct(this.card, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH, pub.flatten()); - ecdhTests.add(CommandTest.expect(ecdhCommand, ExpectedValue.FAILURE, "Card correctly rejected point on invalid curve.", "Card incorrectly accepted point on invalid curve.")); + Test rawEcdh = CommandTest.expect(ecdhCommand, ExpectedValue.FAILURE, "Card correctly rejected point on invalid curve.", "Card incorrectly accepted point on invalid curve."); + ecdhTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, pub.getId() + " invalid key test.", objectEcdh, rawEcdh)); } Test ecdh = CompoundTest.all(ExpectedValue.SUCCESS, "Perform ECDH with invalid public points", ecdhTests.toArray(new Test[0])); - Random r = new Random(); - byte[] raw = new byte[128]; - byte[] sig = new byte[40]; - r.nextBytes(raw); - r.nextBytes(sig); - - List ecdsaTests = new LinkedList<>(); - for (EC_Key.Public pub : keys) { - Command setCommand = new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()); - Test setTest = CommandTest.expect(setCommand, Result.ExpectedValue.ANY); - Command ecdsaCommand = new Command.ECDSA_verify(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.Signature_ALG_ECDSA_SHA, raw, sig); - Test ecdsaTest = CommandTest.expect(ecdsaCommand, Result.ExpectedValue.FAILURE); - ecdsaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Verify random ECDSA signature by " + pub.getId(), setTest, ecdsaTest)); - } - Test ecdsa = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Verify random ECDSA signature by invalid public points", ecdsaTests.toArray(new Test[0])); - - Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Test ECDH and ECDSA with points on invalid curves.", ecdh, ecdsa); if (cfg.cleanup) { - Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.SUCCESS); - doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Invalid curve test of " + curve.getId(), prepare, tests, cleanup)); + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.ANY); + doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Invalid curve test of " + curve.getId(), prepare, ecdh, cleanup)); } else { - doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Invalid curve test of " + curve.getId(), prepare, tests)); + doTest(CompoundTest.greedyAllTry(ExpectedValue.SUCCESS, "Invalid curve test of " + curve.getId(), prepare, ecdh)); } } } diff --git a/src/cz/crcs/ectester/reader/test/CardMiscSuite.java b/src/cz/crcs/ectester/reader/test/CardMiscSuite.java index e568f67e..8623e363 100644 --- a/src/cz/crcs/ectester/reader/test/CardMiscSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardMiscSuite.java @@ -50,7 +50,7 @@ private void testCurves(Map curves, String catName, Result.Exp Test perform = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform ECDH and ECDSA", ka, sig); if (cfg.cleanup) { - Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.SUCCESS); + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY); doTest(CompoundTest.greedyAll(Result.ExpectedValue.SUCCESS, "Tests over " + curve.getBits() + " " + catName + " curve: " + curve.getId() + ".", allocateFirst, set, generate, perform, cleanup)); } else { doTest(CompoundTest.greedyAll(Result.ExpectedValue.SUCCESS, "Tests over " + curve.getBits() + " " + catName + " curve: " + curve.getId() + ".", allocateFirst, set, generate, perform)); diff --git a/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java b/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java new file mode 100644 index 00000000..59def746 --- /dev/null +++ b/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java @@ -0,0 +1,68 @@ +package cz.crcs.ectester.reader.test; + +import cz.crcs.ectester.applet.ECTesterApplet; +import cz.crcs.ectester.applet.EC_Consts; +import cz.crcs.ectester.common.ec.EC_Curve; +import cz.crcs.ectester.common.ec.EC_Key; +import cz.crcs.ectester.common.ec.EC_SigResult; +import cz.crcs.ectester.common.output.TestWriter; +import cz.crcs.ectester.common.test.CompoundTest; +import cz.crcs.ectester.common.test.Result; +import cz.crcs.ectester.common.test.Test; +import cz.crcs.ectester.data.EC_Store; +import cz.crcs.ectester.reader.CardMngr; +import cz.crcs.ectester.reader.ECTesterReader; +import cz.crcs.ectester.reader.command.Command; + +import java.util.List; +import java.util.Map; + +/** + * @author Jan Jancar johny@neuromancer.sk + */ +public class CardSignatureSuite extends CardTestSuite { + public CardSignatureSuite(TestWriter writer, ECTesterReader.Config cfg, CardMngr cardManager) { + super(writer, cfg, cardManager, "signature", "Test verifying various wrong ECDSA values."); + } + + @Override + protected void runTests() throws Exception { + Map results = EC_Store.getInstance().getObjects(EC_SigResult.class, "wrong"); + List>> groupList = EC_Store.mapToPrefix(results.values()); + + List nok = groupList.stream().filter((e) -> e.getKey().equals("nok")).findFirst().get().getValue(); + + byte[] data = "Some stuff that is not the actual data".getBytes(); + for (EC_SigResult sig : nok) { + ecdsaTest(sig, Result.ExpectedValue.FAILURE, data); + } + + List ok = groupList.stream().filter((e) -> e.getKey().equals("ok")).findFirst().get().getValue(); + for (EC_SigResult sig : ok) { + ecdsaTest(sig, Result.ExpectedValue.SUCCESS, null); + } + } + + private void ecdsaTest(EC_SigResult sig, Result.ExpectedValue expected, byte[] defaultData) { + EC_Key.Public pubkey = EC_Store.getInstance().getObject(EC_Key.Public.class, sig.getVerifyKey()); + + byte[] data = sig.getSigData(); + if (data == null) { + data = defaultData; + } + + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, sig.getCurve()); + Test allocate = CommandTest.expect(new Command.Allocate(this.card, ECTesterApplet.KEYPAIR_LOCAL, curve.getBits(), curve.getField()), Result.ExpectedValue.SUCCESS); + Test set = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_LOCAL, EC_Consts.CURVE_external, curve.getParams(), curve.flatten()), Result.ExpectedValue.SUCCESS); + Test setVerifyKey = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_LOCAL, EC_Consts.CURVE_external, pubkey.getParams(), pubkey.flatten()), Result.ExpectedValue.SUCCESS); + Test ecdsaVerify = CommandTest.expect(new Command.ECDSA_verify(this.card, ECTesterApplet.KEYPAIR_LOCAL, sig.getJavaCardSig(), data, sig.getData(0)), expected); + + if (cfg.cleanup) { + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY); + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "ECDSA test of " + sig.getId() + ".", allocate, set, setVerifyKey, ecdsaVerify, cleanup)); + } else { + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "ECDSA test of " + sig.getId() + ".", allocate, set, setVerifyKey, ecdsaVerify)); + } + + } +} diff --git a/src/cz/crcs/ectester/reader/test/CardTestVectorSuite.java b/src/cz/crcs/ectester/reader/test/CardTestVectorSuite.java index 052e480d..fbdf103c 100644 --- a/src/cz/crcs/ectester/reader/test/CardTestVectorSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardTestVectorSuite.java @@ -73,7 +73,7 @@ public Result apply(CommandTestable testable) { } })); if (cfg.cleanup) { - testVector.add(CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.SUCCESS)); + testVector.add(CommandTest.expect(new Command.Cleanup(this.card), ExpectedValue.ANY)); } doTest(CompoundTest.greedyAll(ExpectedValue.SUCCESS, "Test vector " + result.getId(), testVector.toArray(new Test[0]))); } diff --git a/src/cz/crcs/ectester/reader/test/CardTwistSuite.java b/src/cz/crcs/ectester/reader/test/CardTwistSuite.java index 1e1f5f34..6ad4ce6c 100644 --- a/src/cz/crcs/ectester/reader/test/CardTwistSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardTwistSuite.java @@ -8,6 +8,7 @@ import cz.crcs.ectester.common.test.CompoundTest; import cz.crcs.ectester.common.test.Result; import cz.crcs.ectester.common.test.Test; +import cz.crcs.ectester.common.util.CardUtil; import cz.crcs.ectester.data.EC_Store; import cz.crcs.ectester.reader.CardMngr; import cz.crcs.ectester.reader.ECTesterReader; @@ -16,7 +17,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Random; /** * @author Jan Jancar johny@neuromancer.sk @@ -42,30 +42,18 @@ protected void runTests() throws Exception { List ecdhTests = new LinkedList<>(); for (EC_Key.Public pub : keys) { + Test setPub = CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()), Result.ExpectedValue.FAILURE); + Test ecdh = CommandTest.expect(new Command.ECDH(this.card, ECTesterApplet.KEYPAIR_REMOTE, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH), Result.ExpectedValue.FAILURE); + Test objectEcdh = CompoundTest.any(Result.ExpectedValue.SUCCESS, CardUtil.getKATypeString(EC_Consts.KeyAgreement_ALG_EC_SVDP_DH) + " test with twist pubkey.", setPub, ecdh); Command ecdhCommand = new Command.ECDH_direct(this.card, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH, pub.flatten()); - ecdhTests.add(CommandTest.expect(ecdhCommand, Result.ExpectedValue.FAILURE, "Card correctly rejected point on twist.", "Card incorrectly accepted point on twist.")); + Test rawEcdh = CommandTest.expect(ecdhCommand, Result.ExpectedValue.FAILURE, "Card correctly rejected point on twist.", "Card incorrectly accepted point on twist."); + ecdhTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, pub.getId() + " twist key test.", objectEcdh, rawEcdh)); } Test ecdh = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform ECDH with public points on twist", ecdhTests.toArray(new Test[0])); - Random r = new Random(); - byte[] raw = new byte[128]; - byte[] sig = new byte[40]; - r.nextBytes(raw); - r.nextBytes(sig); - - List ecdsaTests = new LinkedList<>(); - for (EC_Key.Public pub : keys) { - Command setCommand = new Command.Set(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.CURVE_external, pub.getParams(), pub.flatten()); - Test setTest = CommandTest.expect(setCommand, Result.ExpectedValue.ANY); - Command ecdsaCommand = new Command.ECDSA_verify(this.card, ECTesterApplet.KEYPAIR_REMOTE, EC_Consts.Signature_ALG_ECDSA_SHA, raw, sig); - Test ecdsaTest = CommandTest.expect(ecdsaCommand, Result.ExpectedValue.FAILURE); - ecdsaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Verify random ECDSA signature by " + pub.getId(), setTest, ecdsaTest)); - } - Test ecdsa = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Verify random ECDSA signature by public points on twist", ecdsaTests.toArray(new Test[0])); - - Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, ecdh, ecdsa); + Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", ecdh); if (cfg.cleanup) { - Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.SUCCESS); + Test cleanup = CommandTest.expect(new Command.Cleanup(this.card), Result.ExpectedValue.ANY); doTest(CompoundTest.greedyAllTry(Result.ExpectedValue.SUCCESS, "Twist test of " + curve.getId(), prepare, tests, cleanup)); } else { doTest(CompoundTest.greedyAllTry(Result.ExpectedValue.SUCCESS, "Twist test of " + curve.getId(), prepare, tests)); diff --git a/src/cz/crcs/ectester/reader/test/CommandTest.java b/src/cz/crcs/ectester/reader/test/CommandTest.java index d57dc174..adad1918 100644 --- a/src/cz/crcs/ectester/reader/test/CommandTest.java +++ b/src/cz/crcs/ectester/reader/test/CommandTest.java @@ -6,6 +6,8 @@ import cz.crcs.ectester.reader.command.Command; import cz.crcs.ectester.reader.response.Response; +import java.util.Arrays; + /** * A simple test that runs one Command to get and evaluate one Response * to get a Result and compare it with the expected one. @@ -47,6 +49,23 @@ public static CommandTest expect(Command command, Result.ExpectedValue expectedV return expect(command, expectedValue, null, null); } + public static CommandTest expectSW(CommandTestable command, short... expectedSWS) { + return new CommandTest(command, new TestCallback() { + @Override + public Result apply(CommandTestable commandTestable) { + if (Arrays.equals(commandTestable.getResponse().getSWs(), expectedSWS)) { + return new Result(Result.Value.SUCCESS); + } else { + return new Result(Result.Value.FAILURE); + } + } + }); + } + + public static CommandTest expectSW(Command command, short... expectedSWS) { + return expectSW(new CommandTestable(command), expectedSWS); + } + public Command getCommand() { return testable.getCommand(); } diff --git a/src/cz/crcs/ectester/reader/test/PerformanceTest.java b/src/cz/crcs/ectester/reader/test/PerformanceTest.java index 9abaadcb..f9a44721 100644 --- a/src/cz/crcs/ectester/reader/test/PerformanceTest.java +++ b/src/cz/crcs/ectester/reader/test/PerformanceTest.java @@ -3,7 +3,6 @@ import cz.crcs.ectester.common.test.Result; import cz.crcs.ectester.common.test.SimpleTest; import cz.crcs.ectester.common.test.TestCallback; -import cz.crcs.ectester.common.test.TestException; import cz.crcs.ectester.reader.command.Command; import cz.crcs.ectester.reader.response.Response; diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java index 31d291c1..364fde43 100644 --- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java +++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java @@ -86,7 +86,12 @@ private void run(String[] args) { CLITools.version(DESCRIPTION, LICENSE); return; } else if (cli.hasOption("help") || cli.getNext() == null) { - CLITools.help("ECTesterStandalone.jar", CLI_HEADER, opts, optParser, CLI_FOOTER, true); + String command = cli.getOptionValue("help"); + if (command == null) { + CLITools.help("ECTesterStandalone.jar", CLI_HEADER, opts, optParser, CLI_FOOTER, true); + } else { + CLITools.help(CLI_HEADER, optParser, CLI_FOOTER, command); + } return; } @@ -204,7 +209,7 @@ private TreeCommandLine parseArgs(String[] args) throws ParseException { optParser = new TreeParser(actions, false, baseArgs); opts.addOption(Option.builder("V").longOpt("version").desc("Print version info.").build()); - opts.addOption(Option.builder("h").longOpt("help").desc("Print help.").build()); + opts.addOption(Option.builder("h").longOpt("help").desc("Print help(about ).").hasArg().argName("command").optionalArg(true).build()); opts.addOption(Option.builder("C").longOpt("color").desc("Print stuff with color, requires ANSI terminal.").build()); return optParser.parse(opts, args); @@ -264,16 +269,26 @@ private void ecdh() throws NoSuchAlgorithmException, InvalidAlgorithmParameterEx .findFirst() .orElse(null); + String baseAlgo; + if (algo.contains("with")) { + baseAlgo = algo.split("with")[0]; + } else { + baseAlgo = algo; + } + KeyPairGeneratorIdent kpIdent = lib.getKPGs().stream() .filter((ident) -> ident.contains(algo)) .findFirst() .orElse(lib.getKPGs().stream() - .filter((ident) -> ident.contains("ECDH")) + .filter((ident) -> ident.contains(baseAlgo)) .findFirst() .orElse(lib.getKPGs().stream() - .filter((ident) -> ident.contains("EC")) + .filter((ident) -> ident.contains("ECDH")) .findFirst() - .orElse(null))); + .orElse(lib.getKPGs().stream() + .filter((ident) -> ident.contains("EC")) + .findFirst() + .orElse(null)))); if (kaIdent == null || kpIdent == null) { throw new NoSuchAlgorithmException(algo); @@ -367,13 +382,26 @@ private void ecdsa() throws NoSuchAlgorithmException, InvalidAlgorithmParameterE .findFirst() .orElse(null); + String baseAlgo; + if (algo.contains("with")) { + baseAlgo = algo.split("with")[1]; + } else { + baseAlgo = algo; + } + KeyPairGeneratorIdent kpIdent = lib.getKPGs().stream() .filter((ident) -> ident.contains(algo)) .findFirst() .orElse(lib.getKPGs().stream() - .filter((ident) -> ident.contains("EC")) + .filter((ident) -> ident.contains(baseAlgo)) .findFirst() - .orElse(null)); + .orElse(lib.getKPGs().stream() + .filter((ident) -> ident.contains("ECDSA")) + .findFirst() + .orElse(lib.getKPGs().stream() + .filter((ident) -> ident.contains("EC")) + .findFirst() + .orElse(null)))); if (sigIdent == null || kpIdent == null) { throw new NoSuchAlgorithmException(algo); @@ -496,6 +524,8 @@ private void test() throws TestException, ParserConfigurationException { break; } + String suiteName = cli.getArg(0); + StandaloneTestSuite suite = new StandaloneDefaultSuite(writer, cfg, cli); suite.run(); } diff --git a/src/cz/crcs/ectester/standalone/consts/Ident.java b/src/cz/crcs/ectester/standalone/consts/Ident.java index 40a44ac2..29603c2e 100644 --- a/src/cz/crcs/ectester/standalone/consts/Ident.java +++ b/src/cz/crcs/ectester/standalone/consts/Ident.java @@ -36,6 +36,7 @@ T getInstance(BiFunction getter, Provider provider) thr try { instance = getter.apply(name, provider); } catch (Exception ignored) { + ignored.printStackTrace(); } if (instance == null) { @@ -46,6 +47,7 @@ T getInstance(BiFunction getter, Provider provider) thr break; } } catch (Exception ignored) { + ignored.printStackTrace(); } } } diff --git a/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java b/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java index 94e8c84d..66d8235a 100644 --- a/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java +++ b/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java @@ -22,7 +22,7 @@ public class KeyAgreementIdent extends Ident { // ECDH and ECDHC with SHA as KDF, OIDs from RFC 3278 ALL.add(new KeyAgreementIdent("ECDHwithSHA1KDF", true, "1.3.133.16.840.63.0.2")); ALL.add(new KeyAgreementIdent("ECCDHwithSHA1KDF", true, "1.3.133.16.840.63.0.3")); - ALL.add(new KeyAgreementIdent("ECDHwithSHA224KDF",true, "1.3.132.1.11.0")); + ALL.add(new KeyAgreementIdent("ECDHwithSHA224KDF", true, "1.3.132.1.11.0")); ALL.add(new KeyAgreementIdent("ECCDHwithSHA224KDF", true, "1.3.132.1.14.0")); ALL.add(new KeyAgreementIdent("ECDHwithSHA256KDF", true, "1.3.132.1.11.1")); ALL.add(new KeyAgreementIdent("ECCDHwithSHA256KDF", true, "1.3.132.1.14.1")); @@ -30,14 +30,20 @@ public class KeyAgreementIdent extends Ident { ALL.add(new KeyAgreementIdent("ECCDHwithSHA384KDF", true, "1.3.132.1.14.2")); ALL.add(new KeyAgreementIdent("ECDHwithSHA512KDF", true, "1.3.132.1.11.3")); ALL.add(new KeyAgreementIdent("ECCDHwithSHA512KDF", true, "1.3.132.1.14.3")); - ALL.add(new KeyAgreementIdent("ECDHwithSHA1CKDF", true)); - ALL.add(new KeyAgreementIdent("ECCDHwithSHA1CKDF", true)); - ALL.add(new KeyAgreementIdent("ECDHwithSHA256CKDF", true)); - ALL.add(new KeyAgreementIdent("ECCDHwithSHA256CKDF", true)); - ALL.add(new KeyAgreementIdent("ECDHwithSHA384CKDF", true)); - ALL.add(new KeyAgreementIdent("ECCDHwithSHA384CKDF", true)); - ALL.add(new KeyAgreementIdent("ECDHwithSHA512CKDF", true)); - ALL.add(new KeyAgreementIdent("ECCDHwithSHA512CKDF", true)); + // Microsoft specific KDF + ALL.add(new KeyAgreementIdent("ECDHwithSHA1KDF(CNG)")); + ALL.add(new KeyAgreementIdent("ECDHwithSHA256KDF(CNG)")); + ALL.add(new KeyAgreementIdent("ECDHwithSHA384KDF(CNG)")); + ALL.add(new KeyAgreementIdent("ECDHwithSHA512KDF(CNG)")); + // CKDF requires custom AlgorithmParameterSpec (only BouncyCastle) + //ALL.add(new KeyAgreementIdent("ECDHwithSHA1CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECCDHwithSHA1CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECDHwithSHA256CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECCDHwithSHA256CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECDHwithSHA384CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECCDHwithSHA384CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECDHwithSHA512CKDF", true)); + //ALL.add(new KeyAgreementIdent("ECCDHwithSHA512CKDF", true)); // ECMQV - Disable for now as it needs diferent params(too different from DH) //ALL.add(new KeyAgreementIdent("ECMQV")); //ALL.add(new KeyAgreementIdent("ECMQVwithSHA1KDF", true)); diff --git a/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java b/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java index 42ff0505..dea8abe4 100644 --- a/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java +++ b/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java @@ -64,7 +64,7 @@ public class SignatureIdent extends Ident { ALL.add(new SignatureIdent("SHA3-384withECDDSA", "SHA3-384withDETECDSA")); ALL.add(new SignatureIdent("SHA3-512withECDDSA", "SHA3-512withDETECDSA")); // ECKCDSA? Botan provides. - ALL.add(new SignatureIdent("ECKCDSA","SHA1withECKCDSA", "1.2.410.200004.1.100.4.3")); + ALL.add(new SignatureIdent("ECKCDSA", "SHA1withECKCDSA", "1.2.410.200004.1.100.4.3")); ALL.add(new SignatureIdent("NONEwithECKCDSA")); ALL.add(new SignatureIdent("RIPEMD160withECKCDSA")); ALL.add(new SignatureIdent("SHA224withECKCDSA", "1.2.410.200004.1.100.4.4")); @@ -79,7 +79,6 @@ public class SignatureIdent extends Ident { ALL.add(new SignatureIdent("SHA224withECGDSA", "1.3.36.3.3.2.5.4.4")); ALL.add(new SignatureIdent("SHA384withECGDSA", "1.3.36.3.3.2.5.4.5")); ALL.add(new SignatureIdent("SHA512withECGDSA", "1.3.36.3.3.2.5.4.6")); - } public static SignatureIdent get(String ident) { diff --git a/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java b/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java index 03a088b4..6b98cc1f 100644 --- a/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java +++ b/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java @@ -91,9 +91,9 @@ public boolean initialize() { System.setProperty("java.library.path", newPath); Field fieldSysPath; try { - fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" ); - fieldSysPath.setAccessible( true ); - fieldSysPath.set( null, null ); + fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); + fieldSysPath.setAccessible(true); + fieldSysPath.set(null, null); } catch (NoSuchFieldException | IllegalAccessException ignored) { } } diff --git a/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java b/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java index 57b273a0..78db00e3 100644 --- a/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java +++ b/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java @@ -9,7 +9,7 @@ public class TomcryptLib extends NativeECLibrary { public TomcryptLib() { - super("tomcrypt_provider", "tommath", "tomcrypt"); + super("tomcrypt_provider", "tommath", "tomcrypt"); } @Override diff --git a/src/cz/crcs/ectester/standalone/libs/jni/NativeECPublicKey.java b/src/cz/crcs/ectester/standalone/libs/jni/NativeECPublicKey.java index ccf21c07..33dd3ef9 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/NativeECPublicKey.java +++ b/src/cz/crcs/ectester/standalone/libs/jni/NativeECPublicKey.java @@ -4,7 +4,6 @@ import cz.crcs.ectester.common.util.ECUtil; import org.bouncycastle.util.Arrays; -import javax.swing.event.AncestorEvent; import java.security.interfaces.ECPublicKey; import java.security.spec.ECParameterSpec; import java.security.spec.ECPoint; diff --git a/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyAgreementSpi.java b/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyAgreementSpi.java index 4ed34698..fdbdccf4 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyAgreementSpi.java +++ b/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyAgreementSpi.java @@ -5,13 +5,12 @@ import javax.crypto.KeyAgreementSpi; import javax.crypto.SecretKey; import javax.crypto.ShortBufferException; -import javax.crypto.spec.SecretKeySpec; import java.security.*; import java.security.interfaces.ECPrivateKey; import java.security.interfaces.ECPublicKey; import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.ECParameterSpec; import java.security.spec.ECGenParameterSpec; +import java.security.spec.ECParameterSpec; /** * @author Jan Jancar johny@neuromancer.sk @@ -61,12 +60,6 @@ protected int engineGenerateSecret(byte[] sharedSecret, int offset) throws Illeg return secret.length; } - @Override - protected SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException { - // TODO: This is dangerous/not correct ! Need to actually implement KDF1 and KDF2 here probably. Or just pass it off to the libs through some different interface. - return new SecretKeySpec(engineGenerateSecret(), algorithm); - } - private abstract static class SimpleKeyAgreementSpi extends NativeKeyAgreementSpi { @Override @@ -78,24 +71,38 @@ protected void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom r this.params = params; } - @Override - protected byte[] engineGenerateSecret() throws IllegalStateException { - byte[] pubkey; + private byte[] getPubkey() { if (publicKey instanceof NativeECPublicKey) { - pubkey = ((NativeECPublicKey) publicKey).getData(); + return ((NativeECPublicKey) publicKey).getData(); } else { - pubkey = ECUtil.toX962Uncompressed(publicKey.getW(), ((ECParameterSpec) params).getCurve()); + return ECUtil.toX962Uncompressed(publicKey.getW(), ((ECParameterSpec) params)); } - byte[] privkey; + } + + private byte[] getPrivkey() { if (privateKey instanceof NativeECPrivateKey) { - privkey = ((NativeECPrivateKey) privateKey).getData(); + return ((NativeECPrivateKey) privateKey).getData(); } else { - privkey = ECUtil.toByteArray(privateKey.getS(), ((ECParameterSpec) params).getCurve().getField().getFieldSize()); + return ECUtil.toByteArray(privateKey.getS(), ((ECParameterSpec) params).getOrder().bitLength()); } - return generateSecret(pubkey, privkey, (ECParameterSpec) params); + } + + @Override + protected byte[] engineGenerateSecret() throws IllegalStateException { + return generateSecret(getPubkey(), getPrivkey(), (ECParameterSpec) params); } abstract byte[] generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params); + + @Override + protected SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException { + if (algorithm == null) { + throw new NoSuchAlgorithmException("Algorithm must not be null"); + } + return generateSecret(getPubkey(), getPrivkey(), (ECParameterSpec) params, algorithm); + } + + abstract SecretKey generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params, String algorithm); } private abstract static class ExtendedKeyAgreementSpi extends NativeKeyAgreementSpi { @@ -115,6 +122,16 @@ protected byte[] engineGenerateSecret() throws IllegalStateException { } abstract byte[] generateSecret(ECPublicKey pubkey, ECPrivateKey privkey, AlgorithmParameterSpec params); + + @Override + protected SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException { + if (algorithm == null) { + throw new NoSuchAlgorithmException("Algorithm must not be null"); + } + return generateSecret(publicKey, privateKey, params, algorithm); + } + + abstract SecretKey generateSecret(ECPublicKey pubkey, ECPrivateKey privkey, AlgorithmParameterSpec params, String algorithm); } @@ -122,6 +139,9 @@ public static class TomCrypt extends SimpleKeyAgreementSpi { @Override native byte[] generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params); + + @Override + native SecretKey generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params, String algorithm); } public abstract static class Botan extends SimpleKeyAgreementSpi { @@ -133,6 +153,9 @@ public Botan(String type) { @Override native byte[] generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params); + + @Override + native SecretKey generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params, String algorithm); } public static class BotanECDH extends Botan { @@ -180,6 +203,9 @@ public Cryptopp(String type) { @Override native byte[] generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params); + + @Override + native SecretKey generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params, String algorithm); } public static class CryptoppECDH extends Cryptopp { @@ -197,6 +223,9 @@ public Openssl(String type) { @Override native byte[] generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params); + + @Override + native SecretKey generateSecret(byte[] pubkey, byte[] privkey, ECParameterSpec params, String algorithm); } public static class OpensslECDH extends Openssl { @@ -214,29 +243,32 @@ public Mscng(String type) { @Override native byte[] generateSecret(ECPublicKey pubkey, ECPrivateKey privkey, AlgorithmParameterSpec params); + + @Override + native SecretKey generateSecret(ECPublicKey pubkey, ECPrivateKey privkey, AlgorithmParameterSpec params, String algorithm); } public static class MscngECDHwithSHA1KDF extends Mscng { public MscngECDHwithSHA1KDF() { - super("ECDHwithSHA1KDF"); + super("ECDHwithSHA1KDF(CNG)"); } } public static class MscngECDHwithSHA256KDF extends Mscng { public MscngECDHwithSHA256KDF() { - super("ECDHwithSHA256KDF"); + super("ECDHwithSHA256KDF(CNG)"); } } public static class MscngECDHwithSHA384KDF extends Mscng { public MscngECDHwithSHA384KDF() { - super("ECDHwithSHA384KDF"); + super("ECDHwithSHA384KDF(CNG)"); } } public static class MscngECDHwithSHA512KDF extends Mscng { public MscngECDHwithSHA512KDF() { - super("ECDHwithSHA512KDF"); + super("ECDHwithSHA512KDF(CNG)"); } } } diff --git a/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyPairGeneratorSpi.java b/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyPairGeneratorSpi.java index 7ca013a3..aa83479b 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyPairGeneratorSpi.java +++ b/src/cz/crcs/ectester/standalone/libs/jni/NativeKeyPairGeneratorSpi.java @@ -13,6 +13,8 @@ public abstract class NativeKeyPairGeneratorSpi extends KeyPairGeneratorSpi { private boolean useKeysize; private boolean useParams; + public static final int DEFAULT_KEYSIZE = 256; + @Override public void initialize(int keysize, SecureRandom random) { if (!keysizeSupported(keysize)) { @@ -37,6 +39,12 @@ public void initialize(AlgorithmParameterSpec params, SecureRandom random) throw @Override public KeyPair generateKeyPair() { + if (!useKeysize && !useParams) { + if (keysizeSupported(DEFAULT_KEYSIZE)) { + initialize(DEFAULT_KEYSIZE, new SecureRandom()); + } + } + if (useKeysize) { return generate(keysize, random); } else if (useParams) { @@ -57,7 +65,6 @@ public KeyPair generateKeyPair() { public static class TomCrypt extends NativeKeyPairGeneratorSpi { public TomCrypt() { - initialize(256, new SecureRandom());//TODO: maybe remove this default init? } @Override @@ -78,7 +85,6 @@ public static abstract class Botan extends NativeKeyPairGeneratorSpi { public Botan(String type) { this.type = type; - initialize(256, new SecureRandom());//TODO: maybe remove this default init? } @Override @@ -127,7 +133,6 @@ public static abstract class Cryptopp extends NativeKeyPairGeneratorSpi { public Cryptopp(String type) { this.type = type; - initialize(256, new SecureRandom());//TODO: maybe remove this default init? } @Override @@ -180,7 +185,6 @@ public static abstract class Mscng extends NativeKeyPairGeneratorSpi { public Mscng(String type) { this.type = type; - initialize(256, new SecureRandom()); } @Override diff --git a/src/cz/crcs/ectester/standalone/libs/jni/NativeSignatureSpi.java b/src/cz/crcs/ectester/standalone/libs/jni/NativeSignatureSpi.java index b60f2c68..602b1c4e 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/NativeSignatureSpi.java +++ b/src/cz/crcs/ectester/standalone/libs/jni/NativeSignatureSpi.java @@ -71,7 +71,7 @@ protected byte[] engineSign() throws SignatureException { if (signKey instanceof NativeECPrivateKey) { privkey = ((NativeECPrivateKey) signKey).getData(); } else { - privkey = ECUtil.toByteArray(signKey.getS(), params.getCurve().getField().getFieldSize()); + privkey = ECUtil.toByteArray(signKey.getS(), params.getOrder().bitLength()); } return sign(buffer.toByteArray(), privkey, params); } diff --git a/src/cz/crcs/ectester/standalone/libs/jni/botan.cpp b/src/cz/crcs/ectester/standalone/libs/jni/botan.cpp index d506ecd5..207532da 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/botan.cpp +++ b/src/cz/crcs/ectester/standalone/libs/jni/botan.cpp @@ -314,7 +314,37 @@ JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPai return generate_from_group(env, self, curve_group); } -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Botan_generateSecret(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params){ +static std::string get_kdf(const std::string& type_str, size_t *kdf_bits) { + std::string kdf; + size_t key_len = 0; + if (type_str == "ECDH") { + kdf = "Raw"; + //key len unused + } else if (type_str == "ECDHwithSHA1KDF") { + kdf = "KDF2(SHA-1)"; + key_len = 20; + } else if (type_str == "ECDHwithSHA224KDF") { + kdf = "KDF2(SHA-224)"; + key_len = 28; + } else if (type_str == "ECDHwithSHA256KDF") { + kdf = "KDF2(SHA-256)"; + key_len = 32; + } else if (type_str == "ECDHwithSHA384KDF") { + kdf = "KDF2(SHA-384)"; + key_len = 48; + } else if (type_str == "ECDHwithSHA512KDF") { + kdf = "KDF2(SHA-512)"; + key_len = 64; + } + + if (*kdf_bits == 0) { + *kdf_bits = key_len; + } + + return kdf; +} + +jbyteArray generate_secret(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params, jstring algorithm) { Botan::EC_Group curve_group = group_from_params(env, params); jsize privkey_length = env->GetArrayLength(privkey); @@ -341,27 +371,8 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey std::string type_str(type_data); env->ReleaseStringUTFChars(type, type_data); - std::string kdf; - size_t key_len = 0; - if (type_str == "ECDH") { - kdf = "Raw"; - //key len unused - } else if (type_str == "ECDHwithSHA1KDF") { - kdf = "KDF2(SHA-1)"; - key_len = 20; - } else if (type_str == "ECDHwithSHA224KDF") { - kdf = "KDF2(SHA-224)"; - key_len = 28; - } else if (type_str == "ECDHwithSHA256KDF") { - kdf = "KDF2(SHA-256)"; - key_len = 32; - } else if (type_str == "ECDHwithSHA384KDF") { - kdf = "KDF2(SHA-384)"; - key_len = 48; - } else if (type_str == "ECDHwithSHA512KDF") { - kdf = "KDF2(SHA-512)"; - key_len = 64; - } + size_t key_len = (get_kdf_bits(env, algorithm) + 7) / 8; + std::string kdf = get_kdf(type_str, &key_len); Botan::PK_Key_Agreement ka(skey, rng, kdf); @@ -380,6 +391,19 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey return result; } +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Botan_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params){ + return generate_secret(env, self, pubkey, privkey, params, NULL); +} + +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Botan_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params, jstring algorithm) { + jbyteArray secret = generate_secret(env, self, pubkey, privkey, params, algorithm); + if (secret == NULL) { + return NULL; + } + jmethodID spec_init = env->GetMethodID(secret_key_spec_class, "", ("([BLjava/lang/String;)V")); + return env->NewObject(secret_key_spec_class, spec_init, secret, algorithm); +} + JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Botan_sign(JNIEnv *env, jobject self, jbyteArray data, jbyteArray privkey, jobject params){ Botan::EC_Group curve_group = group_from_params(env, params); diff --git a/src/cz/crcs/ectester/standalone/libs/jni/c_utils.c b/src/cz/crcs/ectester/standalone/libs/jni/c_utils.c index 6954c365..49cab445 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/c_utils.c +++ b/src/cz/crcs/ectester/standalone/libs/jni/c_utils.c @@ -1,9 +1,11 @@ #include "c_utils.h" #define _ISOC99_SOURCE #include +#include jclass ec_parameter_spec_class; jclass ecgen_parameter_spec_class; +jclass secret_key_spec_class; jclass pubkey_class; jclass privkey_class; jclass keypair_class; @@ -21,6 +23,9 @@ void init_classes(JNIEnv *env, const char* lib_name) { jclass local_ecgen_parameter_spec_class = (*env)->FindClass(env, "java/security/spec/ECGenParameterSpec"); ecgen_parameter_spec_class = (*env)->NewGlobalRef(env, local_ecgen_parameter_spec_class); + jclass local_secret_key_spec_class = (*env)->FindClass(env, "javax/crypto/spec/SecretKeySpec"); + secret_key_spec_class = (*env)->NewGlobalRef(env, local_secret_key_spec_class); + const char *pubkey_base = "cz/crcs/ectester/standalone/libs/jni/NativeECPublicKey$"; char pubkey_class_name[2048] = { 0 }; //strlen(pubkey_base) + strlen(lib_name) + 1 pubkey_class_name[0] = 0; @@ -73,4 +78,31 @@ void throw_new_var(JNIEnv *env, const char *class, const char *format, ...) { int res = vsnprintf(buffer, 2048, format, args); va_end(args); throw_new(env, class, buffer); +} + +jint get_kdf_bits(JNIEnv *env, jstring algorithm) { + if (algorithm == NULL) { + return 0; + } + + const char *algo_data = (*env)->GetStringUTFChars(env, algorithm, NULL); + + jint result = 0; + if (strcmp(algo_data, "DES") == 0) { + result = 64; + } else if (strcmp(algo_data, "BLOWFISH") == 0) { + result = 128; + } else if (strcmp(algo_data, "DESEDE") == 0) { + result = 192; + } else if (strcmp(algo_data, "AES") == 0 || strcmp(algo_data, "CAMELLIA") == 0) { + result = 256; + } else { + char *end; + long bits = strtol(algo_data, &end, 10); + if (*end == 0) { + result = (jint) bits; + } + } + (*env)->ReleaseStringUTFChars(env, algorithm, algo_data); + return result; } \ No newline at end of file diff --git a/src/cz/crcs/ectester/standalone/libs/jni/c_utils.h b/src/cz/crcs/ectester/standalone/libs/jni/c_utils.h index 2e5fa1af..b767b618 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/c_utils.h +++ b/src/cz/crcs/ectester/standalone/libs/jni/c_utils.h @@ -7,6 +7,7 @@ */ extern jclass ec_parameter_spec_class; extern jclass ecgen_parameter_spec_class; +extern jclass secret_key_spec_class; extern jclass pubkey_class; extern jclass privkey_class; extern jclass keypair_class; @@ -32,6 +33,11 @@ void throw_new(JNIEnv *env, const char *class, const char *message); */ void throw_new_var(JNIEnv *env, const char *class, const char *format, ...); +/** + * Get the size of the specified key algorithm in bits, for ECDH KDF output size. + */ +jint get_kdf_bits(JNIEnv *env, jstring algorithm); + /** * Some useful defines to init the provider. */ diff --git a/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp b/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp index 2e93a717..20d9a3cf 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp +++ b/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp @@ -2,6 +2,7 @@ jclass ec_parameter_spec_class; jclass ecgen_parameter_spec_class; +jclass secret_key_spec_class; jclass pubkey_class; jclass privkey_class; jclass keypair_class; @@ -19,6 +20,9 @@ void init_classes(JNIEnv *env, std::string lib_name) { jclass local_ecgen_parameter_spec_class = env->FindClass("java/security/spec/ECGenParameterSpec"); ecgen_parameter_spec_class = (jclass) env->NewGlobalRef(local_ecgen_parameter_spec_class); + jclass local_secret_key_spec_class = env->FindClass("javax/crypto/spec/SecretKeySpec"); + secret_key_spec_class = (jclass) env->NewGlobalRef(local_secret_key_spec_class); + std::string pubkey_class_name("cz/crcs/ectester/standalone/libs/jni/NativeECPublicKey$"); pubkey_class_name += lib_name; @@ -58,6 +62,34 @@ void throw_new(JNIEnv *env, const std::string& klass, const std::string& message env->ThrowNew(clazz, message.c_str()); } +jint get_kdf_bits(JNIEnv *env, jstring algorithm) { + if (algorithm == NULL) { + return 0; + } + + const char *algo_data = env->GetStringUTFChars(algorithm, NULL); + std::string algo(algo_data); + + jint result = 0; + if (algo == "DES") { + result = 64; + } else if (algo == "BLOWFISH") { + result = 128; + } else if (algo == "DESEDE") { + result = 192; + } else if (algo == "AES" || algo == "CAMELLIA") { + result = 256; + } else { + char *end; + long bits = strtol(algo_data, &end, 10); + if (*end == 0) { + result = (jint) bits; + } + } + env->ReleaseStringUTFChars(algorithm, algo_data); + return result; +} + static void add_provider_property(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method) { jstring type_str = env->NewStringUTF(type.c_str()); jstring class_str = env->NewStringUTF(klass.c_str()); diff --git a/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp b/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp index f647bd66..ed26c01e 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp +++ b/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp @@ -8,6 +8,7 @@ */ extern jclass ec_parameter_spec_class; extern jclass ecgen_parameter_spec_class; +extern jclass secret_key_spec_class; extern jclass pubkey_class; extern jclass privkey_class; extern jclass keypair_class; @@ -28,8 +29,22 @@ void init_classes(JNIEnv *env, std::string lib_name); */ void throw_new(JNIEnv *env, const std::string& klass, const std::string& message); +/** + * Get the size of the specified key algorithm in bits, for ECDH KDF output size. + */ +jint get_kdf_bits(JNIEnv *env, jstring algorithm); + +/** + * Add a KeyPairGeneratorSpi class to this provider. + */ void add_kpg(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method); +/** + * Add a KeyAgreementSpi class to this provider. + */ void add_ka(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method); +/** + * Add a SignatureSpi class to this provider. + */ void add_sig(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method); \ No newline at end of file diff --git a/src/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp b/src/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp index 0107d0db..32121c5d 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp +++ b/src/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp @@ -57,6 +57,11 @@ using CryptoPP::SecByteBlock; #include "cryptopp/oids.h" using CryptoPP::OID; +#include "cryptopp/dsa.h" +using CryptoPP::DSAConvertSignatureFormat; +using CryptoPP::DSA_DER; +using CryptoPP::DSA_P1363; + // ASN1 is a namespace, not an object #include "cryptopp/asn.h" using namespace CryptoPP::ASN1; @@ -553,7 +558,7 @@ JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPai return NULL; } -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Cryptopp_generateSecret(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params) { +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Cryptopp_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params) { jsize privkey_length = env->GetArrayLength(privkey); jbyte *privkey_data = env->GetByteArrayElements(privkey, NULL); SecByteBlock private_key((byte *) privkey_data, privkey_length); @@ -598,6 +603,11 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey return result; } +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Cryptopp_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params, jstring algorithm){ + throw_new(env, "java/lang/UnsupportedOperationException", "Not supported."); + return NULL; +} + template jbyteArray sign_message(JNIEnv *env, DL_GroupParameters_EC group, jbyteArray data, const Integer & private_key_x) { AutoSeededRandomPool prng; @@ -614,9 +624,12 @@ jbyteArray sign_message(JNIEnv *env, DL_GroupParameters_EC group, jbyteArray env->ReleaseByteArrayElements(data, data_bytes, JNI_ABORT); signature.resize(len); - jbyteArray result = env->NewByteArray(len); + byte sig[4096]; + size_t sig_len = DSAConvertSignatureFormat(sig, sizeof(sig), DSA_DER, (byte *)signature.c_str(), len, DSA_P1363); + + jbyteArray result = env->NewByteArray(sig_len); jbyte *result_bytes = env->GetByteArrayElements(result, NULL); - std::copy(signature.begin(), signature.end(), result_bytes); + std::copy(sig, sig+sig_len, result_bytes); env->ReleaseByteArrayElements(result, result_bytes, 0); return result; @@ -680,14 +693,21 @@ jboolean verify_message(JNIEnv *env, DL_GroupParameters_EC group, jbyteArray pkey.Initialize(group, pkey_point); typename ECDSA::Verifier verifier(pkey); - jsize data_length = env->GetArrayLength(data); - jbyte *data_bytes = env->GetByteArrayElements(data, NULL); + size_t bit_length = group.GetCurve().GetField().MaxElementBitLength(); + size_t bytes = (bit_length + 7)/8; + jsize sig_length = env->GetArrayLength(signature); jbyte *sig_bytes = env->GetByteArrayElements(signature, NULL); - bool result = verifier.VerifyMessage((byte *)data_bytes, data_length, (byte *)sig_bytes, sig_length); - env->ReleaseByteArrayElements(data, data_bytes, JNI_ABORT); + + byte sig[bytes * 2]; + size_t sig_len = DSAConvertSignatureFormat(sig, bytes * 2, DSA_P1363, (byte *)sig_bytes, sig_length, DSA_DER); env->ReleaseByteArrayElements(signature, sig_bytes, JNI_ABORT); + jsize data_length = env->GetArrayLength(data); + jbyte *data_bytes = env->GetByteArrayElements(data, NULL); + bool result = verifier.VerifyMessage((byte *)data_bytes, data_length, sig, sig_len); + env->ReleaseByteArrayElements(data, data_bytes, JNI_ABORT); + return result; } diff --git a/src/cz/crcs/ectester/standalone/libs/jni/mscng.c b/src/cz/crcs/ectester/standalone/libs/jni/mscng.c index 16736d75..5820afd2 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/mscng.c +++ b/src/cz/crcs/ectester/standalone/libs/jni/mscng.c @@ -51,10 +51,10 @@ JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_ ADD_KPG(env, self, "ECDH", "MscngECDH"); ADD_KPG(env, self, "ECDSA", "MscngECDSA"); - ADD_KA(env, self, "ECDHwithSHA1KDF", "MscngECDHwithSHA1KDF"); - ADD_KA(env, self, "ECDHwithSHA256KDF", "MscngECDHwithSHA256KDF"); - ADD_KA(env, self, "ECDHwithSHA384KDF", "MscngECDHwithSHA384KDF"); - ADD_KA(env, self, "ECDHwithSHA512KDF", "MscngECDHwithSHA512KDF"); + ADD_KA(env, self, "ECDHwithSHA1KDF(CNG)", "MscngECDHwithSHA1KDF"); + ADD_KA(env, self, "ECDHwithSHA256KDF(CNG)", "MscngECDHwithSHA256KDF"); + ADD_KA(env, self, "ECDHwithSHA384KDF(CNG)", "MscngECDHwithSHA384KDF"); + ADD_KA(env, self, "ECDHwithSHA512KDF(CNG)", "MscngECDHwithSHA512KDF"); ADD_SIG(env, self, "SHA1withECDSA", "MscngECDSAwithSHA1"); ADD_SIG(env, self, "SHA256withECDSA", "MscngECDSAwithSHA256"); @@ -883,7 +883,7 @@ static jbyteArray get_meta(JNIEnv *env, jobject key) { } } -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Mscng_generateSecret(JNIEnv *env, jobject self, jobject pubkey, jobject privkey, jobject params) { +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Mscng_generateSecret__Ljava_security_interfaces_ECPublicKey_2Ljava_security_interfaces_ECPrivateKey_2Ljava_security_spec_AlgorithmParameterSpec_2(JNIEnv *env, jobject self, jobject pubkey, jobject privkey, jobject params) { NTSTATUS status; jclass mscng_ka_class = (*env)->FindClass(env, "cz/crcs/ectester/standalone/libs/jni/NativeKeyAgreementSpi$Mscng"); @@ -891,13 +891,13 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey jstring type = (jstring)(*env)->GetObjectField(env, self, type_id); const char* type_data = (*env)->GetStringUTFChars(env, type, NULL); LPCWSTR kdf_algo; - if (strcmp(type_data, "ECDHwithSHA1KDF") == 0) { + if (strcmp(type_data, "ECDHwithSHA1KDF(CNG)") == 0) { kdf_algo = BCRYPT_SHA1_ALGORITHM; - } else if (strcmp(type_data, "ECDHwithSHA256KDF") == 0) { + } else if (strcmp(type_data, "ECDHwithSHA256KDF(CNG)") == 0) { kdf_algo = BCRYPT_SHA256_ALGORITHM; - } else if (strcmp(type_data, "ECDHwithSHA384KDF") == 0) { + } else if (strcmp(type_data, "ECDHwithSHA384KDF(CNG)") == 0) { kdf_algo = BCRYPT_SHA384_ALGORITHM; - } else if (strcmp(type_data, "ECDHwithSHA512KDF") == 0) { + } else if (strcmp(type_data, "ECDHwithSHA512KDF(CNG)") == 0) { kdf_algo = BCRYPT_SHA512_ALGORITHM; } else { //unreachable @@ -973,7 +973,6 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey paramList.pBuffers = kdfParams; paramList.ulVersion = BCRYPTBUFFER_VERSION; - //TODO: Is this the actual KDF-1 or KDF-2 algo or something completely different? *This does not use the counter!!!* ULONG bufSize = 0; if (NT_FAILURE(status = BCryptDeriveKey(ka, BCRYPT_KDF_HASH, ¶mList, NULL, 0, &bufSize, 0))) { throw_new_var(env, "java/security/GeneralSecurityException", "Error 0x%x returned by BCryptDeriveKey(length only)\n", status); @@ -999,6 +998,11 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey return result; } +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Mscng_generateSecret__Ljava_security_interfaces_ECPublicKey_2Ljava_security_interfaces_ECPrivateKey_2Ljava_security_spec_AlgorithmParameterSpec_2Ljava_lang_String_2(JNIEnv *env, jobject self, jobject pubkey, jobject privkey, jobject params, jstring algorithm) { + throw_new(env, "java/lang/UnsupportedOperationException", "Not supported."); + return NULL; +} + static LPCWSTR get_sighash_algo(JNIEnv *env, jobject self) { jclass mscng_sig_class = (*env)->FindClass(env, "cz/crcs/ectester/standalone/libs/jni/NativeSignatureSpi$Mscng"); jfieldID type_id = (*env)->GetFieldID(env, mscng_sig_class, "type", "Ljava/lang/String;"); diff --git a/src/cz/crcs/ectester/standalone/libs/jni/native.h b/src/cz/crcs/ectester/standalone/libs/jni/native.h index dcdaa1b8..e3bf3d87 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/native.h +++ b/src/cz/crcs/ectester/standalone/libs/jni/native.h @@ -1,857 +1,907 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class cz_crcs_ectester_standalone_libs_TomcryptLib */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_TomcryptLib -#define _Included_cz_crcs_ectester_standalone_libs_TomcryptLib -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_TomcryptLib - * Method: createProvider - * Signature: ()Ljava/security/Provider; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_TomcryptLib_createProvider - (JNIEnv *, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_TomcryptLib - * Method: getCurves - * Signature: ()Ljava/util/Set; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_TomcryptLib_getCurves - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt -#ifdef __cplusplus -extern "C" { -#endif -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID 1421746759512286392i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_MAX_ARRAY_SIZE -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_MAX_ARRAY_SIZE 2147483639L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_KEYS -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_KEYS 0L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_VALUES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_VALUES 1L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_ENTRIES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_ENTRIES 2L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID 4112578634029874840i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID -4298000515446427739i64 -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt - * Method: setup - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024TomCrypt_setup - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt - * Method: keysizeSupported - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_keysizeSupported - (JNIEnv *, jobject, jint); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt - * Method: paramsSupported - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_paramsSupported - (JNIEnv *, jobject, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt - * Method: generate - * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_generate__ILjava_security_SecureRandom_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt - * Method: generate - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 - (JNIEnv *, jobject, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_TomCrypt */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_TomCrypt -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_TomCrypt -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_TomCrypt */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_TomCrypt -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_TomCrypt -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt - * Method: generateSecret - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024TomCrypt_generateSecret - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw - * Method: sign - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024TomCryptRaw_sign - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw - * Method: verify - * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024TomCryptRaw_verify - (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_BotanLib */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_BotanLib -#define _Included_cz_crcs_ectester_standalone_libs_BotanLib -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_BotanLib - * Method: createProvider - * Signature: ()Ljava/security/Provider; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_BotanLib_createProvider - (JNIEnv *, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_BotanLib - * Method: getCurves - * Signature: ()Ljava/util/Set; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_BotanLib_getCurves - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan -#ifdef __cplusplus -extern "C" { -#endif -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID 1421746759512286392i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_MAX_ARRAY_SIZE -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_MAX_ARRAY_SIZE 2147483639L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_KEYS -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_KEYS 0L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_VALUES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_VALUES 1L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_ENTRIES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_ENTRIES 2L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID 4112578634029874840i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID -4298000515446427739i64 -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan - * Method: setup - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Botan_setup - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan - * Method: keysizeSupported - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_keysizeSupported - (JNIEnv *, jobject, jint); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan - * Method: paramsSupported - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_paramsSupported - (JNIEnv *, jobject, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan - * Method: generate - * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_generate__ILjava_security_SecureRandom_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan - * Method: generate - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 - (JNIEnv *, jobject, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Botan */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Botan -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Botan -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Botan */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Botan -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Botan -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan - * Method: generateSecret - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Botan_generateSecret - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan - * Method: sign - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Botan_sign - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan - * Method: verify - * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Botan_verify - (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_CryptoppLib */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_CryptoppLib -#define _Included_cz_crcs_ectester_standalone_libs_CryptoppLib -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_CryptoppLib - * Method: createProvider - * Signature: ()Ljava/security/Provider; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_CryptoppLib_createProvider - (JNIEnv *, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_CryptoppLib - * Method: getCurves - * Signature: ()Ljava/util/Set; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_CryptoppLib_getCurves - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp -#ifdef __cplusplus -extern "C" { -#endif -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID 1421746759512286392i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_MAX_ARRAY_SIZE -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_MAX_ARRAY_SIZE 2147483639L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_KEYS -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_KEYS 0L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_VALUES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_VALUES 1L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_ENTRIES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_ENTRIES 2L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID 4112578634029874840i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID -4298000515446427739i64 -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp - * Method: setup - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Cryptopp_setup - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp - * Method: keysizeSupported - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_keysizeSupported - (JNIEnv *, jobject, jint); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp - * Method: paramsSupported - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_paramsSupported - (JNIEnv *, jobject, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp - * Method: generate - * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_generate__ILjava_security_SecureRandom_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp - * Method: generate - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 - (JNIEnv *, jobject, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Cryptopp */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Cryptopp -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Cryptopp -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Cryptopp */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Cryptopp -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Cryptopp -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp - * Method: generateSecret - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Cryptopp_generateSecret - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp - * Method: sign - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Cryptopp_sign - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp - * Method: verify - * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Cryptopp_verify - (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_OpensslLib */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_OpensslLib -#define _Included_cz_crcs_ectester_standalone_libs_OpensslLib -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_OpensslLib - * Method: createProvider - * Signature: ()Ljava/security/Provider; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_OpensslLib_createProvider - (JNIEnv *, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_OpensslLib - * Method: getCurves - * Signature: ()Ljava/util/Set; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_OpensslLib_getCurves - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl -#ifdef __cplusplus -extern "C" { -#endif -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID 1421746759512286392i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_MAX_ARRAY_SIZE -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_MAX_ARRAY_SIZE 2147483639L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_KEYS -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_KEYS 0L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_VALUES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_VALUES 1L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_ENTRIES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_ENTRIES 2L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID 4112578634029874840i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID -4298000515446427739i64 -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl - * Method: setup - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Openssl_setup - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl - * Method: keysizeSupported - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_keysizeSupported - (JNIEnv *, jobject, jint); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl - * Method: paramsSupported - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_paramsSupported - (JNIEnv *, jobject, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl - * Method: generate - * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_generate__ILjava_security_SecureRandom_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl - * Method: generate - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 - (JNIEnv *, jobject, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Openssl */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Openssl -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Openssl -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Openssl */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Openssl -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Openssl -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl - * Method: generateSecret - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Openssl_generateSecret - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl - * Method: sign - * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Openssl_sign - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl - * Method: verify - * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Openssl_verify - (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_MscngLib */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_MscngLib -#define _Included_cz_crcs_ectester_standalone_libs_MscngLib -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_MscngLib - * Method: createProvider - * Signature: ()Ljava/security/Provider; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_MscngLib_createProvider - (JNIEnv *, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_MscngLib - * Method: getCurves - * Signature: ()Ljava/util/Set; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_MscngLib_getCurves - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng -#ifdef __cplusplus -extern "C" { -#endif -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID 1421746759512286392i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_MAX_ARRAY_SIZE -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_MAX_ARRAY_SIZE 2147483639L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_KEYS -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_KEYS 0L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_VALUES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_VALUES 1L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_ENTRIES -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_ENTRIES 2L -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID 4112578634029874840i64 -#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID -#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID -4298000515446427739i64 -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng - * Method: setup - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Mscng_setup - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng - * Method: keysizeSupported - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_keysizeSupported - (JNIEnv *, jobject, jint); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng - * Method: paramsSupported - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_paramsSupported - (JNIEnv *, jobject, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng - * Method: generate - * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_generate__ILjava_security_SecureRandom_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng - * Method: generate - * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; - */ -JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 - (JNIEnv *, jobject, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Mscng */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Mscng -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Mscng -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Mscng */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Mscng -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Mscng -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng - * Method: generateSecret - * Signature: (Ljava/security/interfaces/ECPublicKey;Ljava/security/interfaces/ECPrivateKey;Ljava/security/spec/AlgorithmParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Mscng_generateSecret - (JNIEnv *, jobject, jobject, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng */ - -#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng -#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng - * Method: sign - * Signature: ([BLjava/security/interfaces/ECPrivateKey;Ljava/security/spec/ECParameterSpec;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Mscng_sign - (JNIEnv *, jobject, jbyteArray, jobject, jobject); - -/* - * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng - * Method: verify - * Signature: ([B[BLjava/security/interfaces/ECPublicKey;Ljava/security/spec/ECParameterSpec;)Z - */ -JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Mscng_verify - (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class cz_crcs_ectester_standalone_libs_TomcryptLib */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_TomcryptLib +#define _Included_cz_crcs_ectester_standalone_libs_TomcryptLib +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_TomcryptLib + * Method: createProvider + * Signature: ()Ljava/security/Provider; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_TomcryptLib_createProvider + (JNIEnv *, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_TomcryptLib + * Method: getCurves + * Signature: ()Ljava/util/Set; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_TomcryptLib_getCurves + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID 1421746759512286392LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_MAX_ARRAY_SIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_MAX_ARRAY_SIZE 2147483639L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_KEYS +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_KEYS 0L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_VALUES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_VALUES 1L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_ENTRIES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_ENTRIES 2L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID 4112578634029874840LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt_serialVersionUID -4298000515446427739LL +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_TomCrypt + * Method: setup + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024TomCrypt_setup + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt_DEFAULT_KEYSIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt_DEFAULT_KEYSIZE 256L +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt + * Method: keysizeSupported + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_keysizeSupported + (JNIEnv *, jobject, jint); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt + * Method: paramsSupported + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_paramsSupported + (JNIEnv *, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt + * Method: generate + * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_generate__ILjava_security_SecureRandom_2 + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_TomCrypt + * Method: generate + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024TomCrypt_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 + (JNIEnv *, jobject, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_TomCrypt */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_TomCrypt +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_TomCrypt +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_TomCrypt */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_TomCrypt +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_TomCrypt +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024TomCrypt_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_TomCrypt + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;Ljava/lang/String;)Ljavax/crypto/SecretKey; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024TomCrypt_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw + * Method: sign + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024TomCryptRaw_sign + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_TomCryptRaw + * Method: verify + * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024TomCryptRaw_verify + (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_BotanLib */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_BotanLib +#define _Included_cz_crcs_ectester_standalone_libs_BotanLib +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_BotanLib + * Method: createProvider + * Signature: ()Ljava/security/Provider; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_BotanLib_createProvider + (JNIEnv *, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_BotanLib + * Method: getCurves + * Signature: ()Ljava/util/Set; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_BotanLib_getCurves + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID 1421746759512286392LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_MAX_ARRAY_SIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_MAX_ARRAY_SIZE 2147483639L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_KEYS +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_KEYS 0L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_VALUES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_VALUES 1L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_ENTRIES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_ENTRIES 2L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID 4112578634029874840LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan_serialVersionUID -4298000515446427739LL +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Botan + * Method: setup + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Botan_setup + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan_DEFAULT_KEYSIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan_DEFAULT_KEYSIZE 256L +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan + * Method: keysizeSupported + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_keysizeSupported + (JNIEnv *, jobject, jint); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan + * Method: paramsSupported + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_paramsSupported + (JNIEnv *, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan + * Method: generate + * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_generate__ILjava_security_SecureRandom_2 + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Botan + * Method: generate + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Botan_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 + (JNIEnv *, jobject, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Botan */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Botan +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Botan +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Botan */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Botan +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Botan +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Botan_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Botan + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;Ljava/lang/String;)Ljavax/crypto/SecretKey; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Botan_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan + * Method: sign + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Botan_sign + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Botan + * Method: verify + * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Botan_verify + (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_CryptoppLib */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_CryptoppLib +#define _Included_cz_crcs_ectester_standalone_libs_CryptoppLib +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_CryptoppLib + * Method: createProvider + * Signature: ()Ljava/security/Provider; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_CryptoppLib_createProvider + (JNIEnv *, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_CryptoppLib + * Method: getCurves + * Signature: ()Ljava/util/Set; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_CryptoppLib_getCurves + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID 1421746759512286392LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_MAX_ARRAY_SIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_MAX_ARRAY_SIZE 2147483639L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_KEYS +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_KEYS 0L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_VALUES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_VALUES 1L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_ENTRIES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_ENTRIES 2L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID 4112578634029874840LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp_serialVersionUID -4298000515446427739LL +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Cryptopp + * Method: setup + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Cryptopp_setup + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp_DEFAULT_KEYSIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp_DEFAULT_KEYSIZE 256L +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp + * Method: keysizeSupported + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_keysizeSupported + (JNIEnv *, jobject, jint); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp + * Method: paramsSupported + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_paramsSupported + (JNIEnv *, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp + * Method: generate + * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_generate__ILjava_security_SecureRandom_2 + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Cryptopp + * Method: generate + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Cryptopp_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 + (JNIEnv *, jobject, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Cryptopp */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Cryptopp +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Cryptopp +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Cryptopp */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Cryptopp +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Cryptopp +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Cryptopp_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Cryptopp + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;Ljava/lang/String;)Ljavax/crypto/SecretKey; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Cryptopp_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp + * Method: sign + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Cryptopp_sign + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Cryptopp + * Method: verify + * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Cryptopp_verify + (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_OpensslLib */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_OpensslLib +#define _Included_cz_crcs_ectester_standalone_libs_OpensslLib +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_OpensslLib + * Method: createProvider + * Signature: ()Ljava/security/Provider; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_OpensslLib_createProvider + (JNIEnv *, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_OpensslLib + * Method: getCurves + * Signature: ()Ljava/util/Set; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_OpensslLib_getCurves + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID 1421746759512286392LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_MAX_ARRAY_SIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_MAX_ARRAY_SIZE 2147483639L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_KEYS +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_KEYS 0L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_VALUES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_VALUES 1L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_ENTRIES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_ENTRIES 2L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID 4112578634029874840LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl_serialVersionUID -4298000515446427739LL +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Openssl + * Method: setup + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Openssl_setup + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl_DEFAULT_KEYSIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl_DEFAULT_KEYSIZE 256L +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl + * Method: keysizeSupported + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_keysizeSupported + (JNIEnv *, jobject, jint); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl + * Method: paramsSupported + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_paramsSupported + (JNIEnv *, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl + * Method: generate + * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_generate__ILjava_security_SecureRandom_2 + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Openssl + * Method: generate + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Openssl_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 + (JNIEnv *, jobject, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Openssl */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Openssl +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Openssl +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Openssl */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Openssl +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Openssl +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Openssl_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Openssl + * Method: generateSecret + * Signature: ([B[BLjava/security/spec/ECParameterSpec;Ljava/lang/String;)Ljavax/crypto/SecretKey; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Openssl_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2 + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl + * Method: sign + * Signature: ([B[BLjava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Openssl_sign + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Openssl + * Method: verify + * Signature: ([B[B[BLjava/security/spec/ECParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Openssl_verify + (JNIEnv *, jobject, jbyteArray, jbyteArray, jbyteArray, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_MscngLib */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_MscngLib +#define _Included_cz_crcs_ectester_standalone_libs_MscngLib +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_MscngLib + * Method: createProvider + * Signature: ()Ljava/security/Provider; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_MscngLib_createProvider + (JNIEnv *, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_MscngLib + * Method: getCurves + * Signature: ()Ljava/util/Set; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_MscngLib_getCurves + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID 1421746759512286392LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_MAX_ARRAY_SIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_MAX_ARRAY_SIZE 2147483639L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_KEYS +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_KEYS 0L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_VALUES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_VALUES 1L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_ENTRIES +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_ENTRIES 2L +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID 4112578634029874840LL +#undef cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID +#define cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng_serialVersionUID -4298000515446427739LL +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeProvider_Mscng + * Method: setup + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeProvider_00024Mscng_setup + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng +#ifdef __cplusplus +extern "C" { +#endif +#undef cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng_DEFAULT_KEYSIZE +#define cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng_DEFAULT_KEYSIZE 256L +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng + * Method: keysizeSupported + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_keysizeSupported + (JNIEnv *, jobject, jint); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng + * Method: paramsSupported + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_paramsSupported + (JNIEnv *, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng + * Method: generate + * Signature: (ILjava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_generate__ILjava_security_SecureRandom_2 + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_Mscng + * Method: generate + * Signature: (Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)Ljava/security/KeyPair; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyPairGeneratorSpi_00024Mscng_generate__Ljava_security_spec_AlgorithmParameterSpec_2Ljava_security_SecureRandom_2 + (JNIEnv *, jobject, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Mscng */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Mscng +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPublicKey_Mscng +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Mscng */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Mscng +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeECPrivateKey_Mscng +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng + * Method: generateSecret + * Signature: (Ljava/security/interfaces/ECPublicKey;Ljava/security/interfaces/ECPrivateKey;Ljava/security/spec/AlgorithmParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Mscng_generateSecret__Ljava_security_interfaces_ECPublicKey_2Ljava_security_interfaces_ECPrivateKey_2Ljava_security_spec_AlgorithmParameterSpec_2 + (JNIEnv *, jobject, jobject, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_Mscng + * Method: generateSecret + * Signature: (Ljava/security/interfaces/ECPublicKey;Ljava/security/interfaces/ECPrivateKey;Ljava/security/spec/AlgorithmParameterSpec;Ljava/lang/String;)Ljavax/crypto/SecretKey; + */ +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Mscng_generateSecret__Ljava_security_interfaces_ECPublicKey_2Ljava_security_interfaces_ECPrivateKey_2Ljava_security_spec_AlgorithmParameterSpec_2Ljava_lang_String_2 + (JNIEnv *, jobject, jobject, jobject, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng */ + +#ifndef _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng +#define _Included_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng + * Method: sign + * Signature: ([BLjava/security/interfaces/ECPrivateKey;Ljava/security/spec/ECParameterSpec;)[B + */ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Mscng_sign + (JNIEnv *, jobject, jbyteArray, jobject, jobject); + +/* + * Class: cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_Mscng + * Method: verify + * Signature: ([B[BLjava/security/interfaces/ECPublicKey;Ljava/security/spec/ECParameterSpec;)Z + */ +JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Mscng_verify + (JNIEnv *, jobject, jbyteArray, jbyteArray, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/cz/crcs/ectester/standalone/libs/jni/openssl.c b/src/cz/crcs/ectester/standalone/libs/jni/openssl.c index 259630cc..255834a1 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/openssl.c +++ b/src/cz/crcs/ectester/standalone/libs/jni/openssl.c @@ -470,7 +470,7 @@ EC_KEY *barray_to_privkey(JNIEnv *env, const EC_GROUP *curve, jbyteArray priv) return result; } -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Openssl_generateSecret(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params) { +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Openssl_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params) { EC_GROUP *curve = create_curve(env, params); if (!curve) { throw_new(env, "java/security/InvalidAlgorithmParameterException", "Curve not found."); @@ -501,6 +501,11 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey return result; } +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024Openssl_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteArray privkey, jobject params, jstring algorithm) { + throw_new(env, "java/lang/UnsupportedOperationException", "Not supported."); + return NULL; +} + JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024Openssl_sign(JNIEnv *env, jobject self, jbyteArray data, jbyteArray privkey, jobject params) { EC_GROUP *curve = create_curve(env, params); if (!curve) { diff --git a/src/cz/crcs/ectester/standalone/libs/jni/tomcrypt.c b/src/cz/crcs/ectester/standalone/libs/jni/tomcrypt.c index d609a489..fdf5663c 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/tomcrypt.c +++ b/src/cz/crcs/ectester/standalone/libs/jni/tomcrypt.c @@ -363,7 +363,7 @@ static jboolean pubkey_from_bytes(JNIEnv *env, jbyteArray pubkey, const ltc_ecc_ return JNI_TRUE; } -JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024TomCrypt_generateSecret(JNIEnv *env, jobject this, jbyteArray pubkey, jbyteArray privkey, jobject params){ +JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024TomCrypt_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2(JNIEnv *env, jobject this, jbyteArray pubkey, jbyteArray privkey, jobject params){ ltc_ecc_set_type *curve = create_curve(env, params); ecc_key pub; @@ -397,6 +397,11 @@ JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKey return output; } +JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeKeyAgreementSpi_00024TomCrypt_generateSecret___3B_3BLjava_security_spec_ECParameterSpec_2Ljava_lang_String_2(JNIEnv *env, jobject this, jbyteArray pubkey, jbyteArray privkey, jobject params, jstring algorithm) { + throw_new(env, "java/lang/UnsupportedOperationException", "Not supported."); + return NULL; +} + JNIEXPORT jbyteArray JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSignatureSpi_00024TomCryptRaw_sign(JNIEnv *env, jobject this, jbyteArray data, jbyteArray privkey, jobject params) { ltc_ecc_set_type *curve = create_curve(env, params); diff --git a/src/cz/crcs/ectester/standalone/output/YAMLTestWriter.java b/src/cz/crcs/ectester/standalone/output/YAMLTestWriter.java index 433624ae..ee8a1998 100644 --- a/src/cz/crcs/ectester/standalone/output/YAMLTestWriter.java +++ b/src/cz/crcs/ectester/standalone/output/YAMLTestWriter.java @@ -15,7 +15,6 @@ import java.security.Key; import java.security.PrivateKey; import java.security.PublicKey; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; diff --git a/util/test.sh b/util/test.sh new file mode 100755 index 00000000..41a16e00 --- /dev/null +++ b/util/test.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# +# ECTesterStandalone testing script, +# tests to see everything is implemented correctly in the testing tool +# +cur=$PWD +cd "$(dirname "${BASH_SOURCE[0]}")"/../dist + +trap int INT +function int() { + cd $cur + exit 1 +} + +function do_test() { + out=$($run "$@") + ret=$? + echo "$out" | tail -n1 + if [ "$ret" -ne "0" ]; then + echo ">>>> ERROR '$@' => $ret" + fi +} + +run="$(which java) -jar ECTesterStandalone.jar" +libs=$($run list-libs | grep -P "^\t-" | cut -d"-" -f 2 | cut -d"(" -f1) +while read -r lib; do + echo "** Testing library: $lib" + support=$($run list-libs "$lib") + kpgs=$(echo "$support" | grep KeyPairGenerators | cut -d":" -f2 | sed 's/,//g') + kas=$(echo "$support" | grep KeyAgreements | cut -d":" -f2 | sed 's/,//g') + sigs=$(echo "$support" | grep Signatures | cut -d":" -f2 | sed 's/,//g') + for kpg in $kpgs; do + echo "*** KPG: $kpg" + do_test generate -t $kpg "$lib" + done + for ka in $kas; do + echo "*** KA: $ka" + do_test ecdh -t $ka "$lib" + done + for sig in $sigs; do + echo "*** SIG: $sig" + do_test ecdsa -t $sig "$lib" + done + echo -en "\n\n" +done <<< "$libs" + +trap INT +cd $cur \ No newline at end of file