diff --git a/tst/com/amazon/corretto/crypto/provider/test/EvpKeyFactoryTest.java b/tst/com/amazon/corretto/crypto/provider/test/EvpKeyFactoryTest.java index 278e76fc..e96d1891 100644 --- a/tst/com/amazon/corretto/crypto/provider/test/EvpKeyFactoryTest.java +++ b/tst/com/amazon/corretto/crypto/provider/test/EvpKeyFactoryTest.java @@ -86,12 +86,7 @@ public static void setupParameters() throws Exception { } for (String algorithm : ALGORITHMS) { - KeyPairGenerator kpg; - if (algorithm.equals("EdDSA")) { - kpg = KeyPairGenerator.getInstance("Ed25519"); - } else { - kpg = KeyPairGenerator.getInstance(algorithm); - } + KeyPairGenerator kpg = KeyPairGenerator.getInstance(algorithm); List keys = new ArrayList<>(); if (algorithm.equals("EC")) { // Different curves can excercise different areas of ASN.1/DER and so should all be tested. diff --git a/tst/com/amazon/corretto/crypto/provider/test/KeyReuseThreadStormTest.java b/tst/com/amazon/corretto/crypto/provider/test/KeyReuseThreadStormTest.java index f39375bb..3de1cae3 100644 --- a/tst/com/amazon/corretto/crypto/provider/test/KeyReuseThreadStormTest.java +++ b/tst/com/amazon/corretto/crypto/provider/test/KeyReuseThreadStormTest.java @@ -37,12 +37,14 @@ public class KeyReuseThreadStormTest { private static final KeyPairGenerator RSA_KEY_GEN; private static final KeyPairGenerator EC_KEY_GEN; + private static final KeyPairGenerator ED_KEY_GEN; private static final KeyPair PAIR_RSA_1024_OR_DEFAULT; private static final KeyPair PAIR_RSA_2048; private static final KeyPair PAIR_RSA_4096; private static final KeyPair PAIR_EC_P256; private static final KeyPair PAIR_EC_P384; private static final KeyPair PAIR_EC_P521; + private static final KeyPair PAIR_ED25519; static { try { @@ -62,6 +64,8 @@ public class KeyReuseThreadStormTest { PAIR_EC_P384 = EC_KEY_GEN.generateKeyPair(); EC_KEY_GEN.initialize(new ECGenParameterSpec("NIST P-521")); PAIR_EC_P521 = EC_KEY_GEN.generateKeyPair(); + ED_KEY_GEN = KeyPairGenerator.getInstance("Ed25519", NATIVE_PROVIDER); + PAIR_ED25519 = ED_KEY_GEN.generateKeyPair(); } catch (final GeneralSecurityException ex) { throw new AssertionError(ex); } @@ -203,6 +207,30 @@ public void ecThreadStorm() throws Throwable { executeThreads(threads); } + @Test + public void edThreadStorm() throws Throwable { + final byte[] rngSeed = TestUtil.getRandomBytes(20); + System.out.println("RNG Seed: " + Arrays.toString(rngSeed)); + final SecureRandom rng = SecureRandom.getInstance("SHA1PRNG"); + rng.setSeed(rngSeed); + final int iterations = 500; + final int threadCount = 48; + + final List threads = new ArrayList<>(); + for (int x = 0; x < threadCount; x++) { + final List keys = new ArrayList(); + while (keys.size() < 2) { + if (rng.nextBoolean()) { + keys.add(PAIR_ED25519); + } + } + final TestThread t; + t = new SignatureTestThread("EddsaThread-" + x, rng, iterations, "Ed25519", keys); + threads.add(t); + } + executeThreads(threads); + } + private abstract static class TestThread extends Thread { public volatile Throwable result = null; protected final SecureRandom rnd_;