8233954: UnsatisfiedLinkError or NoSuchAlgorithmException after removing sunec.dll
authorxuelei
Thu, 21 Nov 2019 18:42:33 -0800
changeset 59214 e7df7c86eda1
parent 59213 229aa067e4cc
child 59215 fcd74557a9cc
8233954: UnsatisfiedLinkError or NoSuchAlgorithmException after removing sunec.dll Reviewed-by: ascarpino
src/java.base/share/classes/sun/security/ssl/NamedGroup.java
src/java.base/share/classes/sun/security/ssl/SignatureScheme.java
--- a/src/java.base/share/classes/sun/security/ssl/NamedGroup.java	Fri Nov 22 09:33:03 2019 +0800
+++ b/src/java.base/share/classes/sun/security/ssl/NamedGroup.java	Thu Nov 21 18:42:33 2019 -0800
@@ -250,8 +250,19 @@
         this.supportedProtocols = supportedProtocols;
         this.keAlgParamSpec = keAlgParamSpec;
 
+        // Check if it is a supported named group.
         AlgorithmParameters algParams = null;
         boolean mediator = (keAlgParamSpec != null);
+
+        // HACK CODE
+        //
+        // An EC provider, for example the SunEC provider, may support
+        // AlgorithmParameters but not KeyPairGenerator or KeyAgreement.
+        if (mediator && (namedGroupSpec == NamedGroupSpec.NAMED_GROUP_ECDHE)) {
+            mediator = JsseJce.isEcAvailable();
+        }
+
+        // Check the specific algorithm parameters.
         if (mediator) {
             try {
                 algParams =
--- a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	Fri Nov 22 09:33:03 2019 +0800
+++ b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	Thu Nov 21 18:42:33 2019 -0800
@@ -274,17 +274,28 @@
                 Arrays.asList(handshakeSupportedProtocols);
 
         boolean mediator = true;
-        if (signAlgParams != null) {
-            mediator = signAlgParams.isAvailable;
-        } else {
-            try {
-                Signature.getInstance(algorithm);
-            } catch (Exception e) {
-                mediator = false;
-                if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
-                    SSLLogger.warning(
-                        "Signature algorithm, " + algorithm +
-                        ", is not supported by the underlying providers");
+        // HACK CODE
+        //
+        // An EC provider, for example the SunEC provider, may support
+        // AlgorithmParameters but not KeyPairGenerator or Signature.
+        if ("EC".equals(keyAlgorithm)) {
+            mediator = JsseJce.isEcAvailable();
+        }
+
+        // Check the specific algorithm and parameters.
+        if (mediator) {
+            if (signAlgParams != null) {
+                mediator = signAlgParams.isAvailable;
+            } else {
+                try {
+                    Signature.getInstance(algorithm);
+                } catch (Exception e) {
+                    mediator = false;
+                    if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+                        SSLLogger.warning(
+                            "Signature algorithm, " + algorithm +
+                            ", is not supported by the underlying providers");
+                    }
                 }
             }
         }