changeset 49134:9cbb97715f53

8199018: Test crypto provider not registering Reviewed-by: wetmore
author coffeys
date Tue, 06 Mar 2018 10:31:14 +0000
parents a5b237cfccef
children 6d825d74f4d6
files test/jdk/sun/security/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java test/jdk/sun/security/ssl/HandshakeHash/MyProvider.java
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/sun/security/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java	Tue Mar 06 00:59:49 2018 +0100
+++ b/test/jdk/sun/security/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java	Tue Mar 06 10:31:14 2018 +0000
@@ -42,6 +42,7 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.security.MessageDigest;
 import java.security.Security;
 import javax.net.ssl.SSLSocket;
 
@@ -49,6 +50,7 @@
 
     private static String[] protocol;
     private static String[] ciphersuite;
+    private static String[] mds = { "SHA", "MD5", "SHA-256" };
 
     /*
      * ==================
@@ -57,6 +59,14 @@
     public static void main(String[] args) throws Exception {
         // Add in a non-cloneable MD5/SHA1/SHA-256 implementation
         Security.insertProviderAt(new MyProvider(), 1);
+        // make sure our provider is functioning
+        for (String s : mds) {
+            MessageDigest md = MessageDigest.getInstance(s);
+            String p = md.getProvider().getName();
+            if (!p.equals("MyProvider")) {
+                throw new RuntimeException("Unexpected provider: " + p);
+            }
+        }
 
         if (args.length != 2) {
             throw new Exception(
--- a/test/jdk/sun/security/ssl/HandshakeHash/MyProvider.java	Tue Mar 06 00:59:49 2018 +0100
+++ b/test/jdk/sun/security/ssl/HandshakeHash/MyProvider.java	Tue Mar 06 10:31:14 2018 +0000
@@ -28,8 +28,8 @@
     public MyProvider() {
         super("MyProvider", "1.0",
                 "Test Provider: SHA1/MD5/SHA256 exhaustion testing");
-        put("MessageDigest.SHA", "DigestBase.SHADigest");
-        put("MessageDigest.MD5", "DigestBase.MD5Digest");
-        put("MessageDigest.SHA-256", "DigestBase.SHA256Digest");
+        put("MessageDigest.SHA", "DigestBase$SHA");
+        put("MessageDigest.MD5", "DigestBase$MD5");
+        put("MessageDigest.SHA-256", "DigestBase$SHA256");
     }
 }