diff options
-rw-r--r-- | support/src/test/java/libcore/java/security/StandardNames.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/support/src/test/java/libcore/java/security/StandardNames.java b/support/src/test/java/libcore/java/security/StandardNames.java index 688d4572195..df1a135a34d 100644 --- a/support/src/test/java/libcore/java/security/StandardNames.java +++ b/support/src/test/java/libcore/java/security/StandardNames.java @@ -19,6 +19,7 @@ package libcore.java.security; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.security.Provider; import java.security.Security; import java.security.spec.DSAPrivateKeySpec; import java.security.spec.DSAPublicKeySpec; @@ -98,6 +99,15 @@ public final class StandardNames { assertTrue("Duplicate " + type + " " + algorithm, algorithms.add(algorithm.toUpperCase(Locale.ROOT))); } + // Only add to PROVIDER_ALGORITHMS if actually present + private static void provideOptional(String type, String algorithm) { + for (Provider p : Security.getProviders()) { + if (p.getService(type, algorithm) != null) { + provide(type, algorithm); + return; + } + } + } private static void unprovide(String type, String algorithm) { Set<String> algorithms = PROVIDER_ALGORITHMS.get(type); assertNotNull(algorithms); @@ -420,7 +430,7 @@ public final class StandardNames { provide("Signature", "SHA256withRSA/PSS"); provide("Signature", "SHA384withRSA/PSS"); provide("Signature", "SHA512withRSA/PSS"); - provide("Signature", "ED25519"); + provideOptional("Signature", "ED25519"); // different names: ARCFOUR vs ARC4 unprovide("Cipher", "ARCFOUR"); |