From fa5ba0e0e0a3168fdbed27b9c21eada9bb9f1587 Mon Sep 17 00:00:00 2001 From: J08nY Date: Sat, 30 Mar 2024 11:12:17 +0100 Subject: Add more suites to tests. --- .../java/cz/crcs/ectester/standalone/AppTests.java | 75 ++++++++++++++++++---- 1 file changed, 62 insertions(+), 13 deletions(-) (limited to 'standalone/src/test/java') diff --git a/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java b/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java index c869233..e3ae573 100644 --- a/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java +++ b/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java @@ -1,12 +1,14 @@ package cz.crcs.ectester.standalone; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; +import org.junit.jupiter.params.provider.MethodSource; import org.junitpioneer.jupiter.StdIo; import org.junitpioneer.jupiter.StdOut; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assumptions.assumeFalse; @@ -53,9 +55,13 @@ public class AppTests { assertTrue(s.contains("NONEwithECDSA")); } + static Stream libs() { + return Stream.of("BoringSSL", "Botan", "BouncyCastle", "Crypto++", "IPPCP", "LibreSSL", "libgcrypt", "mbedTLS", "Nettle", "OpenSSL", "SunEC", "tomcrypt", "wolfCrypt"); + } + @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void defaultSuite(String libName, StdOut out) { // TODO: "Nettle" is very broken here for a weird reason. @@ -74,7 +80,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void testVectorSuite(String libName, StdOut out) { String[] args = new String[]{"test", "test-vectors", libName}; @@ -89,14 +95,14 @@ public class AppTests { } @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") public void performanceSuite(String libName) { // TODO: "Nettle" is very broken here for a weird reason. assumeFalse(libName.equals("Nettle")); - String[] args = new String[]{"test", "performance", "-o", "/dev/null", libName}; + String[] args = new String[]{"test", "performance", libName}; if (libName.equals("Botan") || libName.equals("Crypto++")) { - args = new String[]{"test", "--kpg-type", "ECDH", "performance", "-o", "/dev/null", libName}; + args = new String[]{"test", "--kpg-type", "ECDH", "performance", libName}; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); @@ -108,9 +114,51 @@ public class AppTests { } } + @ParameterizedTest + @MethodSource("libs") + public void signatureSuite(String libName) { + String[] args = new String[]{"test", "signature", libName}; + switch (libName) { + case "Nettle": + case "libgcrypt": + case "BoringSSL": + case "OpenSSL": + case "tomcrypt": + case "LibreSSL": + case "IPPCP": + case "mbedTLS": + args = new String[]{"test", "-st", "NONEwithECDSA", "signature", libName}; + break; + } + ECTesterStandalone.main(args); + } + + @ParameterizedTest + @MethodSource("libs") + public void miscSuite(String libName) { + String[] args = new String[]{"test", "miscellaneous", libName}; + if (libName.equals("Botan") || libName.equals("Crypto++")) { + args = new String[]{"test", "--kpg-type", "ECDH", "miscellaneous", libName}; + } + ECTesterStandalone.main(args); + } + + @ParameterizedTest + @MethodSource("libs") + public void invalidSuite(String libName) { + // TODO: "Nettle" is very broken here for a weird reason. + assumeFalse(libName.equals("Nettle")); + + String[] args = new String[]{"test", "invalid", libName}; + if (libName.equals("Botan") || libName.equals("Crypto++")) { + args = new String[]{"test", "--kpg-type", "ECDH", "invalid", libName}; + } + ECTesterStandalone.main(args); + } + @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void generate(String libName, StdOut out) { String[] args = new String[]{"generate", "-n", "10", "-nc", "secg/secp256r1", libName}; @@ -133,7 +181,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void ecdh(String libName, StdOut out) { String[] args = new String[]{"ecdh", "-n", "10", "-nc", "secg/secp256r1", libName}; @@ -152,7 +200,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void ecdsa(String libName, StdOut out) { String[] args = new String[]{"ecdsa", "-n", "10", "-nc", "secg/secp256r1", libName}; @@ -164,10 +212,11 @@ public class AppTests { case "BoringSSL": args = new String[]{"ecdsa", "-n", "10", "-cn", "prime256v1", "-t", "NONEwithECDSA", libName}; break; - case "OpenSSL 3": - case "libtomcrypt": + case "OpenSSL": + case "tomcrypt": case "LibreSSL": - case "2021": + case "IPPCP": + case "mbedTLS": args = new String[]{"ecdsa", "-n", "10", "-nc", "secg/secp256r1", "-t", "NONEwithECDSA", libName}; break; case "wolfCrypt": @@ -179,7 +228,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void export(String libName, StdOut out) { // TODO: wolfCrypt is weirdly broken here. -- cgit v1.2.3-70-g09d2