From 40ec0fea381a6538f5498b9fb75706ef9fa79f59 Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 16 Oct 2018 00:57:24 +0200 Subject: Add support for BoringSSL. --- docs/LIBS.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/LIBS.md b/docs/LIBS.md index 00dcaaf..ad7aaf0 100644 --- a/docs/LIBS.md +++ b/docs/LIBS.md @@ -7,7 +7,6 @@ Popular libraries with at least some ECC support: - [mbedTLS](https://tls.mbed.org/) - [Nettle](http://www.lysator.liu.se/~nisse/nettle/) - [OpenSSL (FIPS mode)](https://www.openssl.org/docs/fipsnotes.html) - - [BoringSSL](https://boringssl.googlesource.com/boringssl) - [Microsoft .NET crypto](https://docs.microsoft.com/en-us/dotnet/standard/security/cryptography-model) # Supported libraries @@ -61,6 +60,17 @@ Popular libraries with at least some ECC support: - Also uses multiplication with precomputation by wNAF splitting(ec_mult.c) - For binary field curves: - Uses Jacobian coordinates, and Lopez-Dahab ladder, also uses wNAF-based interleaving multi-exponentiation method(ec2_smpl.c) + - [BoringSSL](https://boringssl.googlesource.com/boringssl) + - C + - Supports prime field curves only: + - Use Jacobian coordinates, and Montgomery ladder, also uses optimized arithmetic on NIST P-224, P-256. + - Bundled as a git submodule in `ext/boringssl`. To build and use run: +```bash +cd ext/boringssl +mkdir build && cd build +cmake -DBUILD_SHARED_LIBS=1 -GNinja .. +ninja +``` - [Botan](https://botan.randombit.net/) - C++ - Uses blinded(randomized) Montgomery ladder. -- cgit v1.3.1 From c3474ab145fc1975b68949f3abd40ea4ee6dd73c Mon Sep 17 00:00:00 2001 From: J08nY Date: Sun, 21 Oct 2018 13:52:11 +0200 Subject: Add libgcrypt to docs. --- README.md | 17 +++++++++-------- docs/LIBS.md | 31 ++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 19 deletions(-) (limited to 'docs') diff --git a/README.md b/README.md index 370f144..4112595 100644 --- a/README.md +++ b/README.md @@ -222,14 +222,15 @@ If you are interested in testing support for other JavaCard algorithms, please v ## Standalone library testing Currently supported libraries include: - - BouncyCastle - - SunEC - - OpenSSL - - BoringSSL - - Crypto++ - - libtomcrypt - - botan - - Microsoft CNG + - [BouncyCastle](https://bouncycastle.org/java.html) + - [Sun EC](https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunEC) + - [OpenSSL](https://www.openssl.org/) + - [BoringSSL](https://boringssl.googlesource.com/boringssl) + - [Crypto++](https://cryptopp.com/) + - [libtomcrypt](http://www.libtom.net/LibTomCrypt/) + - [libgcrypt](https://www.gnupg.org/related_software/libgcrypt/) + - [Botan](https://botan.randombit.net/) + - [Microsoft CNG](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376210(v=vs.85).aspx) For more information on ECC libraries see [LIBS](docs/LIBS.md). diff --git a/docs/LIBS.md b/docs/LIBS.md index ad7aaf0..faab84d 100644 --- a/docs/LIBS.md +++ b/docs/LIBS.md @@ -3,14 +3,16 @@ 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/) + - [LibreSSL](https://www.libressl.org/) - [Nettle](http://www.lysator.liu.se/~nisse/nettle/) - [OpenSSL (FIPS mode)](https://www.openssl.org/docs/fipsnotes.html) - [Microsoft .NET crypto](https://docs.microsoft.com/en-us/dotnet/standard/security/cryptography-model) # Supported libraries +Libraries that ECTester can test. + - [BouncyCastle](https://bouncycastle.org/java.html) - Java - Works with the short Weierstrass curve model. @@ -71,6 +73,23 @@ mkdir build && cd build cmake -DBUILD_SHARED_LIBS=1 -GNinja .. ninja ``` + - [Crypto++](https://cryptopp.com/) + - C++ + - For prime field curves: + - Uses projective coordinates and sliding window scalar multiplication algorithm. + - For binary field curves: + - Uses affine coordinates and sliding window scalar multiplication algorithm. + - [libtomcrypt](http://www.libtom.net/LibTomCrypt/) + - C + - Uses Jacobian coordinates. + - Sliding window scalar multiplication algorithm. + - [libgcrypt](https://www.gnupg.org/related_software/libgcrypt/) + - C + - Only supports prime field curves. + - Uses short Weierstrass, Montgomery and Twisted Edwards models. + - Uses left-to-right double-and-add always scalar multiplication and Jacobian coordinates in short Weierstrass form. + - Uses Montgomery ladder and X-only in Montgomery form. + - Uses left-to-right double-and-add always scalar multiplication in Twisted Edwards form. - [Botan](https://botan.randombit.net/) - C++ - Uses blinded(randomized) Montgomery ladder. @@ -78,16 +97,6 @@ ninja - - - ECTester supports v2.4.0 and up. - - [libtomcrypt](http://www.libtom.net/LibTomCrypt/) - - C - - Uses Jacobian coordinates. - - Sliding window scalar multiplication algorithm. - - [Crypto++](https://cryptopp.com/) - - C++ - - For prime field curves: - - Uses projective coordinates and sliding window scalar multiplication algorithm. - - For binary field curves: - - Uses affine coordinates and sliding window scalar multiplication algorithm. - [Microsoft CNG](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376210(v=vs.85).aspx) - C API. - Closed source. -- cgit v1.3.1 From 1243b4acace365b0231aca22470517ae42c4ed1d Mon Sep 17 00:00:00 2001 From: J08nY Date: Sat, 3 Nov 2018 00:02:02 +0100 Subject: Add compression tests for quadratic non-residue in modular square root. --- docs/TESTS.md | 6 ++++ src/cz/crcs/ectester/common/ec/EC_SigResult.java | 2 +- src/cz/crcs/ectester/common/util/ECUtil.java | 8 +++++ src/cz/crcs/ectester/data/EC_Store.java | 18 ++++------ src/cz/crcs/ectester/data/other/keys.xml | 38 +++++++++++++++++++++- .../ectester/reader/test/CardCompositeSuite.java | 18 +++++----- .../ectester/reader/test/CardCompressionSuite.java | 30 +++++++++++++++++ .../ectester/reader/test/CardEdgeCasesSuite.java | 8 ++--- .../ectester/reader/test/CardSignatureSuite.java | 6 ++-- 9 files changed, 104 insertions(+), 30 deletions(-) (limited to 'docs') diff --git a/docs/TESTS.md b/docs/TESTS.md index c639722..25f61a8 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -40,6 +40,12 @@ Tests using known test vectors provided by NIST/SECG/Brainpool: 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). + - Compressed form, valid + - Hybrid form, valid + - Hybrid form, invalid `y` + - Point at infinity + - Compressed form, invalid, `x^3 + ax + b` results in quadratic non-residue in modular square root computation. + ## Miscellaneous Some miscellaneous tests, tries ECDH and ECDSA over supersingular curves, anomalous curves and Barreto-Naehrig curves with small embedding degree and CM discriminant. diff --git a/src/cz/crcs/ectester/common/ec/EC_SigResult.java b/src/cz/crcs/ectester/common/ec/EC_SigResult.java index f1ab0f5..d97ced1 100644 --- a/src/cz/crcs/ectester/common/ec/EC_SigResult.java +++ b/src/cz/crcs/ectester/common/ec/EC_SigResult.java @@ -69,7 +69,7 @@ public class EC_SigResult extends EC_Data { @Override public String toString() { - return "<" + getId() + "> " + sig + " result over " + curve + ", " + signKey + " + " + verifyKey + (data == null ? "" : " of data \"" + data + "\"") + (desc == null ? "" : ": " + desc) + System.lineSeparator() + super.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/util/ECUtil.java b/src/cz/crcs/ectester/common/util/ECUtil.java index 6c3ad58..1706ca0 100644 --- a/src/cz/crcs/ectester/common/util/ECUtil.java +++ b/src/cz/crcs/ectester/common/util/ECUtil.java @@ -31,6 +31,14 @@ public class ECUtil { return raw; } + public static byte[] toX962Compressed(byte[][] point) { + if (point.length != 2) { + return null; + } + byte ybit = (byte) (point[1][point[1].length - 1] % 2); + return ByteUtil.concatenate(new byte[]{(byte) (0x02 | ybit)}, point[0]); + } + public static byte[] toX962Compressed(ECPoint point, int bits) { if (point.equals(ECPoint.POINT_INFINITY)) { return new byte[]{0}; diff --git a/src/cz/crcs/ectester/data/EC_Store.java b/src/cz/crcs/ectester/data/EC_Store.java index f1d4260..d104fa4 100644 --- a/src/cz/crcs/ectester/data/EC_Store.java +++ b/src/cz/crcs/ectester/data/EC_Store.java @@ -350,7 +350,7 @@ public class EC_Store { return getObject(objClass, query.substring(0, split), query.substring(split + 1)); } - private static List>> mapKeyToCurve(Collection data, Function getter) { + private static Map> mapKeyToCurve(Collection data, Function getter) { Map> curves = new TreeMap<>(); for (T item : data) { EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, getter.apply(item)); @@ -361,21 +361,18 @@ public class EC_Store { for (List keyList : curves.values()) { Collections.sort(keyList); } - List>> curveList = new LinkedList<>(); - curveList.addAll(curves.entrySet()); - Comparator>> c = Comparator.comparing(Map.Entry::getKey); - return curveList; + return curves; } - public static List>> mapKeyToCurve(Collection keys) { + public static Map> mapKeyToCurve(Collection keys) { return mapKeyToCurve(keys, EC_Key::getCurve); } - public static List>> mapResultToCurve(Collection results) { + public static Map> mapResultToCurve(Collection results) { return mapKeyToCurve(results, EC_KAResult::getCurve); } - public static List>> mapToPrefix(Collection data) { + public static Map> mapToPrefix(Collection data) { Map> groups = new TreeMap<>(); for (T item : data) { String prefix = item.getId().split("/")[0]; @@ -386,10 +383,7 @@ public class EC_Store { for (List itemList : groups.values()) { Collections.sort(itemList); } - List>> result = new LinkedList<>(); - result.addAll(groups.entrySet()); - result.sort(Comparator.comparing(Map.Entry::getKey)); - return result; + return groups; } public static EC_Store getInstance() { diff --git a/src/cz/crcs/ectester/data/other/keys.xml b/src/cz/crcs/ectester/data/other/keys.xml index d06de81..e17b45b 100644 --- a/src/cz/crcs/ectester/data/other/keys.xml +++ b/src/cz/crcs/ectester/data/other/keys.xml @@ -11,4 +11,40 @@ 0x296D416994A4801B9A48E8C67C98E0C05DE1C0E85D4DC676F32FEACDC4998F0E,0xA91F9BE06C1D50EEB0295A35CA0F130F17EA647147626318E28AEC97F0653749 secg/secp256r1 - \ No newline at end of file + + + compression/128/non-residue + 0xb6707fa8afeddf79b9579e8dda4eaf51,0x000000000000000000000000000000 + secg/secp128r1 + + + compression/160/non-residue + 0xb1cb90992ff28689c6f160dcfb51b9525492e3d9,0x0000000000000000000000000000000000000000 + secg/secp160r1 + + + compression/192/non-residue + 0x8910baef94195e069c142b129e97507bfc2e19b53b707441,0x000000000000000000000000000000000000000000000000 + secg/secp192r1 + + + compression/224/non-residue + 0xafd44b41555e8bea506518b35405d4f5be78355d6342e7f5287bd748,0x00000000000000000000000000000000000000000000000000000000 + secg/secp224r1 + + + compression/256/non-residue + 0xeb7a88c476ede6ecae7909aa19631d9918762e851c38a3ea00fe50b7b2e2e656,0x0000000000000000000000000000000000000000000000000000000000000000 + secg/secp256r1 + + + compression/384/non-residue + 0x45d50b222c11c0f20946133382a988caf2d4f64e669340ba60a5ab3151a6bf3883e7e77a6d358fd07db411bc8ad0f375,0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + secg/secp384r1 + + + compression/521/non-residue + 0x1d7b127de8415bbf498c26f7a17c9e39dcd866b68359bc8e139f401f8ee8489419fb6166850c98cce7e1fdc620902961656d72f9b42703f06ccb9fe6e218e7e3fe3,0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + secg/secp521r1 + + diff --git a/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java b/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java index 336b371..4bf9290 100644 --- a/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardCompositeSuite.java @@ -37,8 +37,8 @@ public class CardCompositeSuite extends CardTestSuite { * is revealed. */ Map keys = EC_Store.getInstance().getObjects(EC_Key.class, "composite"); - List>> mappedKeys = EC_Store.mapKeyToCurve(keys.values()); - for (Map.Entry> curveKeys : mappedKeys) { + Map> mappedKeys = EC_Store.mapKeyToCurve(keys.values()); + for (Map.Entry> curveKeys : mappedKeys.entrySet()) { EC_Curve curve = curveKeys.getKey(); List tests = new LinkedList<>(); Test allocate = runTest(CommandTest.expect(new Command.Allocate(this.card, ECTesterApplet.KEYPAIR_LOCAL, curve.getBits(), curve.getField()), ExpectedValue.SUCCESS)); @@ -59,35 +59,35 @@ public class CardCompositeSuite extends CardTestSuite { Map results = EC_Store.getInstance().getObjects(EC_Curve.class, "composite"); - List>> groupList = EC_Store.mapToPrefix(results.values()); + Map> groups = EC_Store.mapToPrefix(results.values()); /* Test the whole curves with both keypairs generated on card(no small-order public points provided). */ - List wholeCurves = groupList.stream().filter((e) -> e.getKey().equals("whole")).findFirst().get().getValue(); + List wholeCurves = groups.entrySet().stream().filter((e) -> e.getKey().equals("whole")).findFirst().get().getValue(); testGroup(wholeCurves, "Composite generator order", ExpectedValue.FAILURE, "Card rejected to do ECDH with composite order generator.", "Card did not reject to do ECDH with composite order generator."); /* Also test having a G of small order, so small R. */ - List smallRCurves = groupList.stream().filter((e) -> e.getKey().equals("small")).findFirst().get().getValue(); + List smallRCurves = groups.entrySet().stream().filter((e) -> e.getKey().equals("small")).findFirst().get().getValue(); testGroup(smallRCurves, "Small generator order", ExpectedValue.FAILURE, "Card correctly rejected to do ECDH over a small order generator.", "Card incorrectly does ECDH over a small order generator."); /* Test increasingly larger prime R, to determine where/if card behavior changes. */ - List varyingCurves = groupList.stream().filter((e) -> e.getKey().equals("varying")).findFirst().get().getValue(); + List varyingCurves = groups.entrySet().stream().filter((e) -> e.getKey().equals("varying")).findFirst().get().getValue(); testGroup(varyingCurves, null, ExpectedValue.ANY, "", ""); /* Also test having a G of large but composite order, R = p * q, */ - List pqCurves = groupList.stream().filter((e) -> e.getKey().equals("pq")).findFirst().get().getValue(); + List pqCurves = groups.entrySet().stream().filter((e) -> e.getKey().equals("pq")).findFirst().get().getValue(); testGroup(pqCurves, null, ExpectedValue.ANY, "", ""); /* Also test having G or large order being a Carmichael pseudoprime, R = p * q * r, */ - List ppCurves = groupList.stream().filter((e) -> e.getKey().equals("pp")).findFirst().get().getValue(); + List ppCurves = groups.entrySet().stream().filter((e) -> e.getKey().equals("pp")).findFirst().get().getValue(); testGroup(ppCurves, "Generator order = Carmichael pseudoprime", ExpectedValue.ANY, "", ""); /* Also test rg0 curves. */ - List rg0Curves = groupList.stream().filter((e) -> e.getKey().equals("rg0")).findFirst().get().getValue(); + List rg0Curves = groups.entrySet().stream().filter((e) -> e.getKey().equals("rg0")).findFirst().get().getValue(); testGroup(rg0Curves, null, ExpectedValue.ANY, "", ""); } diff --git a/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java b/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java index ae25bf1..7338415 100644 --- a/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardCompressionSuite.java @@ -2,6 +2,8 @@ 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.output.TestWriter; import cz.crcs.ectester.common.test.CompoundTest; import cz.crcs.ectester.common.test.Result; @@ -9,6 +11,7 @@ import cz.crcs.ectester.common.test.Test; import cz.crcs.ectester.common.util.ByteUtil; import cz.crcs.ectester.common.util.CardUtil; import cz.crcs.ectester.common.util.ECUtil; +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; @@ -18,6 +21,7 @@ import javacard.security.KeyPair; import java.security.spec.ECPoint; import java.util.LinkedList; import java.util.List; +import java.util.Map; /** * @author Jan Jancar johny@neuromancer.sk @@ -51,6 +55,10 @@ public class CardCompressionSuite extends CardTestSuite { if (cfg.binaryField) { runCompression(KeyPair.ALG_EC_F2M); } + + // Now, do ECDH over SECG curves and give the implementation a compressed key that is not a quadratic residue in + // decompression. + runNonResidue(); } private void runCompression(byte field) throws Exception { @@ -119,4 +127,26 @@ public class CardCompressionSuite extends CardTestSuite { doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Compression test of " + spec + ".", compressionTests.toArray(new Test[0]))); } } + + private void runNonResidue() { + Map otherKeys = EC_Store.getInstance().getObjects(EC_Key.Public.class, "other"); + List compressionKeys = EC_Store.mapToPrefix(otherKeys.values()).get("compression"); + + for (EC_Key.Public key : compressionKeys) { + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, key.getCurve()); + List tests = new LinkedList<>(); + Test allocate = runTest(CommandTest.expect(new Command.Allocate(this.card, ECTesterApplet.KEYPAIR_LOCAL, curve.getBits(), curve.getField()), Result.ExpectedValue.SUCCESS)); + if (!allocate.ok()) { + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "No support for " + curve.getBits() + "b " + CardUtil.getKeyTypeString(curve.getField()) + ".", allocate)); + continue; + } + tests.add(allocate); + tests.add(CommandTest.expect(new Command.Set(this.card, ECTesterApplet.KEYPAIR_LOCAL, EC_Consts.CURVE_external, curve.getParams(), curve.flatten()), Result.ExpectedValue.ANY)); + tests.add(CommandTest.expect(new Command.Generate(this.card, ECTesterApplet.KEYPAIR_LOCAL), Result.ExpectedValue.ANY)); + byte[] pointData = ECUtil.toX962Compressed(key.getParam(EC_Consts.PARAMETER_W)); + byte[] pointDataEncoded = ByteUtil.prependLength(pointData); + tests.add(CommandTest.expect(new Command.ECDH_direct(this.card, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.TRANSFORMATION_NONE, EC_Consts.KeyAgreement_ALG_EC_SVDP_DH, pointDataEncoded), Result.ExpectedValue.FAILURE)); + doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Non-residue test of " + curve.getId() + ".", tests.toArray(new Test[0]))); + } + } } diff --git a/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java b/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java index b68b2ec..c0fde69 100644 --- a/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardEdgeCasesSuite.java @@ -39,8 +39,8 @@ public class CardEdgeCasesSuite extends CardTestSuite { @Override protected void runTests() throws Exception { Map results = EC_Store.getInstance().getObjects(EC_KAResult.class, "wycheproof"); - List>> groupList = EC_Store.mapToPrefix(results.values()); - for (Map.Entry> e : groupList) { + Map> groups = EC_Store.mapToPrefix(results.values()); + for (Map.Entry> e : groups.entrySet()) { String description = null; switch (e.getKey()) { case "addsub": @@ -55,8 +55,8 @@ public class CardEdgeCasesSuite extends CardTestSuite { } List groupTests = new LinkedList<>(); - List>> curveList = EC_Store.mapResultToCurve(e.getValue()); - for (Map.Entry> c : curveList) { + Map> curveList = EC_Store.mapResultToCurve(e.getValue()); + for (Map.Entry> c : curveList.entrySet()) { EC_Curve curve = c.getKey(); List curveTests = new LinkedList<>(); diff --git a/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java b/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java index 59def74..20546c8 100644 --- a/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java +++ b/src/cz/crcs/ectester/reader/test/CardSignatureSuite.java @@ -28,16 +28,16 @@ public class CardSignatureSuite extends CardTestSuite { @Override protected void runTests() throws Exception { Map results = EC_Store.getInstance().getObjects(EC_SigResult.class, "wrong"); - List>> groupList = EC_Store.mapToPrefix(results.values()); + Map> groups = EC_Store.mapToPrefix(results.values()); - List nok = groupList.stream().filter((e) -> e.getKey().equals("nok")).findFirst().get().getValue(); + List nok = groups.entrySet().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(); + List ok = groups.entrySet().stream().filter((e) -> e.getKey().equals("ok")).findFirst().get().getValue(); for (EC_SigResult sig : ok) { ecdsaTest(sig, Result.ExpectedValue.SUCCESS, null); } -- cgit v1.3.1 From f59aaf972a83330206e8b0d2e1819f45da38f74e Mon Sep 17 00:00:00 2001 From: J08nY Date: Sun, 11 Nov 2018 17:51:53 +0100 Subject: Add WolfCrypt provider to testing. --- README.md | 1 + docs/LIBS.md | 2 ++ lib/wolfcrypt-jni.jar | Bin 0 -> 83453 bytes nbproject/standalone/manifest.mf | 2 +- nbproject/standalone/project.properties | 1 + .../crcs/ectester/standalone/ECTesterStandalone.java | 13 ++++++++++++- .../crcs/ectester/standalone/libs/WolfCryptLib.java | 18 ++++++++++++++++++ 7 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 lib/wolfcrypt-jni.jar create mode 100644 src/cz/crcs/ectester/standalone/libs/WolfCryptLib.java (limited to 'docs') diff --git a/README.md b/README.md index d70ae9b..d23922d 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,7 @@ Currently supported libraries include: - [Sun EC](https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunEC) - [OpenSSL](https://www.openssl.org/) - [BoringSSL](https://boringssl.googlesource.com/boringssl) + - [wolfSSL](https://www.wolfssl.com/) - [Crypto++](https://cryptopp.com/) - [libtomcrypt](http://www.libtom.net/LibTomCrypt/) - [libgcrypt](https://www.gnupg.org/related_software/libgcrypt/) diff --git a/docs/LIBS.md b/docs/LIBS.md index faab84d..d41f98a 100644 --- a/docs/LIBS.md +++ b/docs/LIBS.md @@ -55,6 +55,8 @@ Libraries that ECTester can test. - Uses Lopez-Dahab (Montgomery) ladder, XZ coordinates (ec2_mont.c): Fast multiplication on elliptic curves over GF(2^m) without precomputation (Algorithm 2P) - Contains an implementation of IEEE P1363 algorithm A.10.3 using affine coordinates (ec2_aff.c) - Has some custom arithmetic for some of the NIST primes. + - [WolfCrypt](https://www.wolfssl.com) + - C + Java - [OpenSSL](https://www.openssl.org/) - C - For prime field curves: diff --git a/lib/wolfcrypt-jni.jar b/lib/wolfcrypt-jni.jar new file mode 100644 index 0000000..890ae14 Binary files /dev/null and b/lib/wolfcrypt-jni.jar differ diff --git a/nbproject/standalone/manifest.mf b/nbproject/standalone/manifest.mf index 5e8f5d9..ad7aacb 100644 --- a/nbproject/standalone/manifest.mf +++ b/nbproject/standalone/manifest.mf @@ -1,4 +1,4 @@ Manifest-Version: 1.0 -Class-Path: lib/bcprov-jdk15on-1.58.jar lib/jcardsim-3.0.4-SNAPSHOT.jar lib/commons-cli-1.4.jar lib/snakeyaml-1.19.jar +Class-Path: lib/bcprov-jdk15on-1.58.jar lib/wolfcrypt-jni.jar lib/jcardsim-3.0.4-SNAPSHOT.jar lib/commons-cli-1.4.jar lib/snakeyaml-1.19.jar Main-Class: cz.crcs.ectester.standalone.ECTesterStandalone diff --git a/nbproject/standalone/project.properties b/nbproject/standalone/project.properties index 6b6d440..29ad3cc 100644 --- a/nbproject/standalone/project.properties +++ b/nbproject/standalone/project.properties @@ -34,6 +34,7 @@ includes=**/common/**,**/standalone/**,**/data/**,**/applet/* jar.compress=true javac.classpath=\ lib/bcprov-jdk15on-1.58.jar:\ + lib/wolfcrypt-jni.jar:\ lib/jcardsim-3.0.4-SNAPSHOT.jar:\ lib/commons-cli-1.4.jar:\ lib/snakeyaml-1.19.jar diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java index 7480215..b6f5478 100644 --- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java +++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java @@ -49,6 +49,7 @@ import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.reflect.Field; import java.nio.file.Files; import java.security.*; import java.security.interfaces.ECPrivateKey; @@ -66,7 +67,17 @@ import java.util.stream.Collectors; * @version v0.3.0 */ public class ECTesterStandalone { - private ProviderECLibrary[] libs = new ProviderECLibrary[]{new SunECLib(), new BouncyCastleLib(), new TomcryptLib(), new BotanLib(), new CryptoppLib(), new OpensslLib(), new BoringsslLib(), new GcryptLib(), new MscngLib()}; + private ProviderECLibrary[] libs = new ProviderECLibrary[]{ + new SunECLib(), + new BouncyCastleLib(), + new TomcryptLib(), + new BotanLib(), + new CryptoppLib(), + new OpensslLib(), + new BoringsslLib(), + new GcryptLib(), + new MscngLib(), + new WolfCryptLib()}; private Config cfg; private Options opts = new Options(); diff --git a/src/cz/crcs/ectester/standalone/libs/WolfCryptLib.java b/src/cz/crcs/ectester/standalone/libs/WolfCryptLib.java new file mode 100644 index 0000000..b58eb91 --- /dev/null +++ b/src/cz/crcs/ectester/standalone/libs/WolfCryptLib.java @@ -0,0 +1,18 @@ +package cz.crcs.ectester.standalone.libs; + +import com.wolfssl.provider.jce.WolfCryptProvider; + +import java.util.HashSet; +import java.util.Set; + +public class WolfCryptLib extends ProviderECLibrary { + + public WolfCryptLib() { + super(new WolfCryptProvider()); + } + + @Override + public Set getCurves() { + return new HashSet<>(); + } +} -- cgit v1.3.1