aboutsummaryrefslogtreecommitdiff
path: root/standalone/src
diff options
context:
space:
mode:
authorJ08nY2024-06-19 11:19:42 +0200
committerJ08nY2024-06-19 11:19:42 +0200
commit5fee2ecff3c6eee47ca0138bc23603f4c7741c30 (patch)
treed619c2b35c331dff13e236c68179609d8848b288 /standalone/src
parentb7d077792a282b27875218ef808de067e4953150 (diff)
downloadECTester-5fee2ecff3c6eee47ca0138bc23603f4c7741c30.tar.gz
ECTester-5fee2ecff3c6eee47ca0138bc23603f4c7741c30.tar.zst
ECTester-5fee2ecff3c6eee47ca0138bc23603f4c7741c30.zip
Diffstat (limited to 'standalone/src')
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCofactorSuite.java6
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCompositeSuite.java40
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneDegenerateSuite.java8
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneEdgeCasesSuite.java4
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneInvalidSuite.java8
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandalonePerformanceSuite.java12
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTestVectorSuite.java2
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTwistSuite.java8
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneWrongSuite.java36
9 files changed, 62 insertions, 62 deletions
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCofactorSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCofactorSuite.java
index 52b0fbf..bb9a509 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCofactorSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCofactorSuite.java
@@ -76,10 +76,10 @@ public class StandaloneCofactorSuite extends StandaloneTestSuite {
ECParameterSpec spec = curve.toSpec();
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp == null) {
+ if (kp == null) {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() + ". " + "KeyAgreement tests will be skipped.", generate);
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Cofactor test of " + curve.getId() + ".", generateFail));
continue;
@@ -101,7 +101,7 @@ public class StandaloneCofactorSuite extends StandaloneTestSuite {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform " + kaIdent.getName() + " with public points on non-generator subgroup.", specificKaTests.toArray(new Test[0])));
}
}
- if(allKaTests.isEmpty()) {
+ if (allKaTests.isEmpty()) {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified key agreement types is supported by the library."));
}
Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0]));
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCompositeSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCompositeSuite.java
index c59d864..839bb40 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCompositeSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneCompositeSuite.java
@@ -85,10 +85,10 @@ public class StandaloneCompositeSuite extends StandaloneTestSuite {
//Generate KeyPair
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp == null) {
+ if (kp == null) {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() + ". " + "KeyAgreement tests will be skipped.", generate);
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Composite test of " + curve.getId() + ".", generateFail));
continue;
@@ -104,14 +104,14 @@ public class StandaloneCompositeSuite extends StandaloneTestSuite {
for (EC_Key.Public pub : curveKeys.getValue()) {
ECPublicKey ecpub = ECUtil.toPublicKey(pub);
KeyAgreement ka = kaIdent.getInstance(cfg.selected.getProvider());
- KeyAgreementTestable testable = new KeyAgreementTestable(ka, ecpriv ,ecpub);
+ KeyAgreementTestable testable = new KeyAgreementTestable(ka, ecpriv, ecpub);
Test keyAgreement = KeyAgreementTest.expectError(testable, Result.ExpectedValue.FAILURE);
specificKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Composite test of " + curve.getId() + ", with generated private key, " + pub.getDesc(), keyAgreement));
}
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform " + kaIdent.getName() + " with various public points.", specificKaTests.toArray(new Test[0])));
}
}
- if(allKaTests.isEmpty()) {
+ if (allKaTests.isEmpty()) {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified key agreement types is supported by the library."));
}
Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0]));
@@ -153,7 +153,7 @@ public class StandaloneCompositeSuite extends StandaloneTestSuite {
}
private void testGroup(List<EC_Curve> curves, KeyPairGenerator kpg, String testName, Result.ExpectedValue dhValue) throws Exception {
- for (EC_Curve curve : curves) {
+ for (EC_Curve curve : curves) {
String description;
if (testName == null) {
description = curve.getDesc() + " test of " + curve.getId() + ".";
@@ -162,19 +162,19 @@ public class StandaloneCompositeSuite extends StandaloneTestSuite {
}
//generate KeyPair
- KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, curve.toSpec());
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
- runTest(generate);
- KeyPair kp = kgt.getKeyPair();
- if(kp == null) {
- Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() +
- ". " + " Other tests will be skipped.", generate);
- doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, description, generateFail));
- continue;
- }
- Test generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generate);
- ECPrivateKey ecpriv = (ECPrivateKey) kp.getPrivate();
- ECPublicKey ecpub = (ECPublicKey) kp.getPublic();
+ KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, curve.toSpec());
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ runTest(generate);
+ KeyPair kp = kgt.getKeyPair();
+ if (kp == null) {
+ Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() +
+ ". " + " Other tests will be skipped.", generate);
+ doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, description, generateFail));
+ continue;
+ }
+ Test generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generate);
+ ECPrivateKey ecpriv = (ECPrivateKey) kp.getPrivate();
+ ECPublicKey ecpub = (ECPublicKey) kp.getPublic();
//perform KeyAgreement tests
List<Test> kaTests = new LinkedList<>();
@@ -185,7 +185,7 @@ public class StandaloneCompositeSuite extends StandaloneTestSuite {
kaTests.add(KeyAgreementTest.expectError(testable, dhValue));
}
}
- if(kaTests.isEmpty()) {
+ if (kaTests.isEmpty()) {
kaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified KeyAgreement types is supported by the library."));
}
@@ -198,7 +198,7 @@ public class StandaloneCompositeSuite extends StandaloneTestSuite {
sigTests.add(SignatureTest.expectError(testable, dhValue));
}
}
- if(sigTests.isEmpty()) {
+ if (sigTests.isEmpty()) {
sigTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified Signature types is supported by the library."));
}
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneDegenerateSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneDegenerateSuite.java
index 9ab8a39..45000df 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneDegenerateSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneDegenerateSuite.java
@@ -77,17 +77,17 @@ public class StandaloneDegenerateSuite extends StandaloneTestSuite {
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
Test generateSuccess;
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp != null) {
+ if (kp != null) {
generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generate);
} else { //If KeyPair generation fails, try generating it on a default curve instead. Use this key only if it has the same domain parameters as our public key.
KeyGeneratorTestable kgtOnDefaultCurve = new KeyGeneratorTestable(kpg, curve.getBits());
Test generateOnDefaultCurve = KeyGeneratorTest.expectError(kgtOnDefaultCurve, Result.ExpectedValue.ANY);
runTest(generateOnDefaultCurve);
kp = kgtOnDefaultCurve.getKeyPair();
- if(kp != null && ECUtil.equalKeyPairParameters((ECPrivateKey) kp.getPrivate(), ECUtil.toPublicKey(keys.get(0)))) {
+ if (kp != null && ECUtil.equalKeyPairParameters((ECPrivateKey) kp.getPrivate(), ECUtil.toPublicKey(keys.get(0)))) {
generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generateOnDefaultCurve);
} else {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() + ". " + "KeyAgreement tests will be skipped.", generate);
@@ -111,7 +111,7 @@ public class StandaloneDegenerateSuite extends StandaloneTestSuite {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform " + kaIdent.getName() + " with degenerate public points..", specificKaTests.toArray(new Test[0])));
}
}
- if(allKaTests.isEmpty()) {
+ if (allKaTests.isEmpty()) {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified key agreement types is supported by the library."));
}
Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0]));
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneEdgeCasesSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneEdgeCasesSuite.java
index 1900bea..7c46f02 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneEdgeCasesSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneEdgeCasesSuite.java
@@ -264,10 +264,10 @@ public class StandaloneEdgeCasesSuite extends StandaloneTestSuite {
//generate KeyPair
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp == null) {
+ if (kp == null) {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on "
+ secp160r1.getBits() + "b secp160r1." + " Other tests will be skipped.", generate);
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Test private key values near zero, near p and near/larger than the order on" + secp160r1.getId() + ".", generateFail));
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneInvalidSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneInvalidSuite.java
index ace8945..391fc34 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneInvalidSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneInvalidSuite.java
@@ -76,17 +76,17 @@ public class StandaloneInvalidSuite extends StandaloneTestSuite {
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
Test generateSuccess;
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp != null) {
+ if (kp != null) {
generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generate);
} else { //If KeyPair generation fails, try generating it on a default curve instead. Use this key only if it has the same domain parameters as our public key.
KeyGeneratorTestable kgtOnDefaultCurve = new KeyGeneratorTestable(kpg, curve.getBits());
Test generateOnDefaultCurve = KeyGeneratorTest.expectError(kgtOnDefaultCurve, Result.ExpectedValue.ANY);
runTest(generateOnDefaultCurve);
kp = kgtOnDefaultCurve.getKeyPair();
- if(kp != null && ECUtil.equalKeyPairParameters((ECPrivateKey) kp.getPrivate(), ECUtil.toPublicKey(keys.get(0)))) {
+ if (kp != null && ECUtil.equalKeyPairParameters((ECPrivateKey) kp.getPrivate(), ECUtil.toPublicKey(keys.get(0)))) {
generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generateOnDefaultCurve);
} else {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() + ". " + "KeyAgreement tests will be skipped.", generate);
@@ -110,7 +110,7 @@ public class StandaloneInvalidSuite extends StandaloneTestSuite {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform " + kaIdent.getName() + " with invalid public points.", specificKaTests.toArray(new Test[0])));
}
}
- if(allKaTests.isEmpty()) {
+ if (allKaTests.isEmpty()) {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified key agreement types is supported by the library."));
}
Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0]));
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandalonePerformanceSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandalonePerformanceSuite.java
index e3b6d2e..a1b4d75 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandalonePerformanceSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandalonePerformanceSuite.java
@@ -73,7 +73,7 @@ public class StandalonePerformanceSuite extends StandaloneTestSuite {
KeyGeneratorTestable kgtOther = null;
ECParameterSpec spec = null;
List<Test> kpgTests = new LinkedList<>();
- for(KeyPairGeneratorIdent kpgIdent : kpgIdents) {
+ for (KeyPairGeneratorIdent kpgIdent : kpgIdents) {
KeyPairGenerator kpg = kpgIdent.getInstance(cfg.selected.getProvider());
if (cli.hasOption("test.bits")) {
int bits = Integer.parseInt(cli.getOptionValue("test.bits"));
@@ -111,7 +111,7 @@ public class StandalonePerformanceSuite extends StandaloneTestSuite {
kaTests.add(PerformanceTest.repeat(testable, cfg.selected, kaIdent.getName(), count));
}
}
- if(kaTests.isEmpty()) {
+ if (kaTests.isEmpty()) {
kaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified KeyAgreement types is supported by the library."));
}
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "KeyAgreement performance tests", kaTests.toArray(new Test[0])));
@@ -121,17 +121,17 @@ public class StandalonePerformanceSuite extends StandaloneTestSuite {
for (SignatureIdent sigIdent : cfg.selected.getSigs()) {
if (sigAlgo == null || sigIdent.containsAny(sigTypes)) {
Signature sig = sigIdent.getInstance(cfg.selected.getProvider());
- sigTests.add(PerformanceTest.repeat(new SignatureTestable(sig, kgtOne, null), cfg.selected, sigIdent.getName(),count));
- if(kgtOne.getKeyPair() != null) {
+ sigTests.add(PerformanceTest.repeat(new SignatureTestable(sig, kgtOne, null), cfg.selected, sigIdent.getName(), count));
+ if (kgtOne.getKeyPair() != null) {
ECPrivateKey signKey = (ECPrivateKey) kgtOne.getKeyPair().getPrivate();
sigTestsNoVerification.add(PerformanceTest.repeat(new SignatureTestable(sig, signKey, null, null), cfg.selected, sigIdent.getName(), count));
}
}
}
- if(sigTestsNoVerification.isEmpty() & !sigTests.isEmpty()) {
+ if (sigTestsNoVerification.isEmpty() & !sigTests.isEmpty()) {
sigTestsNoVerification.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Signature tests with no verification require a successfully generated private key."));
}
- if(sigTests.isEmpty()) {
+ if (sigTests.isEmpty()) {
sigTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified Signature types is supported by the library."));
sigTestsNoVerification.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified Signature types is supported by the library."));
}
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTestVectorSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTestVectorSuite.java
index 1e1889c..111d354 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTestVectorSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTestVectorSuite.java
@@ -31,7 +31,7 @@ public class StandaloneTestVectorSuite extends StandaloneTestSuite {
protected void runTests() throws Exception {
Map<String, EC_KAResult> results = EC_Store.getInstance().getObjects(EC_KAResult.class, "test");
for (EC_KAResult result : results.values()) {
- if(!"DH_PLAIN".equals(result.getKA())) {
+ if (!"DH_PLAIN".equals(result.getKA())) {
continue;
}
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTwistSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTwistSuite.java
index f182952..84228e7 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTwistSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneTwistSuite.java
@@ -76,17 +76,17 @@ public class StandaloneTwistSuite extends StandaloneTestSuite {
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
Test generateSuccess;
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp != null) {
+ if (kp != null) {
generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generate);
} else { //If KeyPair generation fails, try generating it on a default curve instead. Use this key only if it has the same domain parameters as our public key.
KeyGeneratorTestable kgtOnDefaultCurve = new KeyGeneratorTestable(kpg, curve.getBits());
Test generateOnDefaultCurve = KeyGeneratorTest.expectError(kgtOnDefaultCurve, Result.ExpectedValue.ANY);
runTest(generateOnDefaultCurve);
kp = kgtOnDefaultCurve.getKeyPair();
- if(kp != null && ECUtil.equalKeyPairParameters((ECPrivateKey) kp.getPrivate(), ECUtil.toPublicKey(keys.get(0)))) {
+ if (kp != null && ECUtil.equalKeyPairParameters((ECPrivateKey) kp.getPrivate(), ECUtil.toPublicKey(keys.get(0)))) {
generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generateOnDefaultCurve);
} else {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() + ". " + "KeyAgreement tests will be skipped.", generate);
@@ -110,7 +110,7 @@ public class StandaloneTwistSuite extends StandaloneTestSuite {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform " + kaIdent.getName() + " with public points on twist.", specificKaTests.toArray(new Test[0])));
}
}
- if(allKaTests.isEmpty()) {
+ if (allKaTests.isEmpty()) {
allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified key agreement types is supported by the library."));
}
Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0]));
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneWrongSuite.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneWrongSuite.java
index a457a33..1aae9d5 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneWrongSuite.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/suites/StandaloneWrongSuite.java
@@ -103,7 +103,7 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
/* Just do the default run on the wrong curves.
* These should generally fail, the curves aren't curves.
*/
- if(!skip) {
+ if (!skip) {
Map<String, EC_Curve> wrongCurves = EC_Store.getInstance().getObjects(EC_Curve.class, "wrong");
for (Map.Entry<String, EC_Curve> e : wrongCurves.entrySet()) {
@@ -151,11 +151,11 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
short bits = curve.getBits();
final byte[] originalp = curve.getParam(EC_Consts.PARAMETER_FP)[0];
- curve.setParam(EC_Consts.PARAMETER_FP, new byte[][]{ ByteUtil.hexToBytes("0")});
- Test prime0 = ecdhTest(toCustomSpec(curve),"ECDH with p = 0.");
+ curve.setParam(EC_Consts.PARAMETER_FP, new byte[][]{ByteUtil.hexToBytes("0")});
+ Test prime0 = ecdhTest(toCustomSpec(curve), "ECDH with p = 0.");
- curve.setParam(EC_Consts.PARAMETER_FP, new byte[][]{ ByteUtil.hexToBytes("1")});
- Test prime1 = ecdhTest(toCustomSpec(curve),"ECDH with p = 1.");
+ curve.setParam(EC_Consts.PARAMETER_FP, new byte[][]{ByteUtil.hexToBytes("1")});
+ Test prime1 = ecdhTest(toCustomSpec(curve), "ECDH with p = 1.");
short keyHalf = (short) (bits / 2);
BigInteger prime = new BigInteger(keyHalf, 50, r);
@@ -173,23 +173,23 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
Test composite = ecdhTest(toCustomSpec(curve), "ECDH with p = q * s.");
- Test wrongPrime = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with corrupted prime parameter.", prime0 , prime1, primePower, composite );
+ Test wrongPrime = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with corrupted prime parameter.", prime0, prime1, primePower, composite);
- curve.setParam(EC_Consts.PARAMETER_FP, new byte[][] {originalp});
+ curve.setParam(EC_Consts.PARAMETER_FP, new byte[][]{originalp});
final byte[][] originalG = curve.getParam(EC_Consts.PARAMETER_G);
byte[] Gx = new BigInteger(curve.getBits(), r).toByteArray();
byte[] Gy = new BigInteger(curve.getBits(), r).toByteArray();
- curve.setParam(EC_Consts.PARAMETER_G, new byte[][] {Gx, Gy});
+ curve.setParam(EC_Consts.PARAMETER_G, new byte[][]{Gx, Gy});
Test fullRandomG = ecdhTest(toCustomSpec(curve), "ECDH with G = random data.");
final BigInteger originalBigp = new BigInteger(1, originalp);
byte[] smallerGx = new BigInteger(curve.getBits(), r).mod(originalBigp).toByteArray();
byte[] smallerGy = new BigInteger(curve.getBits(), r).mod(originalBigp).toByteArray();
- curve.setParam(EC_Consts.PARAMETER_G, new byte[][] {smallerGx, smallerGy});
+ curve.setParam(EC_Consts.PARAMETER_G, new byte[][]{smallerGx, smallerGy});
Test randomG = ecdhTest(toCustomSpec(curve), "ECDH with G = random data mod p.");
- curve.setParam(EC_Consts.PARAMETER_G, new byte[][] {ByteUtil.hexToBytes("0"), ByteUtil.hexToBytes("0")});
+ curve.setParam(EC_Consts.PARAMETER_G, new byte[][]{ByteUtil.hexToBytes("0"), ByteUtil.hexToBytes("0")});
Test zeroG = ecdhTest(toCustomSpec(curve), "ECDH with G = infinity.");
Test wrongG = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with corrupted G parameter.", fullRandomG, randomG, zeroG);
@@ -199,7 +199,7 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
final BigInteger originalBigR = new BigInteger(1, originalR);
List<Test> allRTests = new LinkedList<>();
- if(!skip) {
+ if (!skip) {
byte[] RZero = new byte[]{(byte) 0};
curve.setParam(EC_Consts.PARAMETER_R, new byte[][]{RZero});
allRTests.add(ecdhTest(toCustomSpec(curve), "ECDH with R = 0."));
@@ -215,7 +215,7 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
prevPrimeR = BigInteger.probablePrime(originalBigR.bitLength() - 1, r);
} while (prevPrimeR.compareTo(originalBigR) >= 0);
byte[] prevRBytes = ECUtil.toByteArray(prevPrimeR, bits);
- curve.setParam(EC_Consts.PARAMETER_R, new byte[][] {prevRBytes});
+ curve.setParam(EC_Consts.PARAMETER_R, new byte[][]{prevRBytes});
allRTests.add(ecdhTest(toCustomSpec(curve), "ECDH with R = some prime (but [r]G != infinity) smaller than original R."));
BigInteger nextPrimeR = originalBigR.nextProbablePrime();
@@ -225,15 +225,15 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
byte[] nonprimeRBytes = nextRBytes.clone();
nonprimeRBytes[nonprimeRBytes.length - 1] ^= 1;
- curve.setParam(EC_Consts.PARAMETER_R, new byte[][] {nonprimeRBytes} );
+ curve.setParam(EC_Consts.PARAMETER_R, new byte[][]{nonprimeRBytes});
allRTests.add(ecdhTest(toCustomSpec(curve), "ECDH with R = some composite (but [r]G != infinity)."));
Test wrongR = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with corrupted R parameter.", allRTests.toArray(new Test[0]));
- curve.setParam(EC_Consts.PARAMETER_R, new byte[][] {originalR});
+ curve.setParam(EC_Consts.PARAMETER_R, new byte[][]{originalR});
byte[] kRaw = new byte[]{(byte) 0xff};
- curve.setParam(EC_Consts.PARAMETER_K, new byte[][] {kRaw});
+ curve.setParam(EC_Consts.PARAMETER_K, new byte[][]{kRaw});
Test bigK = ecdhTest(toCustomSpec(curve), "ECDH with big K.");
byte[] kZero = new byte[]{(byte) 0};
@@ -241,7 +241,7 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
Test zeroK = ecdhTest(toCustomSpec(curve), "ECDH with K = 0.");
Test wrongK = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests with corrupted K parameter.", bigK, zeroK);
- doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests of " + bits + "b " + "FP", wrongPrime, wrongG, wrongR , wrongK));
+ doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests of " + bits + "b " + "FP", wrongPrime, wrongG, wrongR, wrongK));
}
@@ -284,10 +284,10 @@ public class StandaloneWrongSuite extends StandaloneTestSuite {
private Test ecdhTest(ECParameterSpec spec, String desc) throws NoSuchAlgorithmException {
//generate KeyPair
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, spec);
- Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.FAILURE);
+ Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.FAILURE);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
- if(kp == null) {
+ if (kp == null) {
return CompoundTest.all(Result.ExpectedValue.SUCCESS, desc, generate);
}
ECPublicKey pub = (ECPublicKey) kp.getPublic();