Blame SOURCES/pr3083-rh1346460.patch

045ef6
# HG changeset patch
045ef6
# User andrew
045ef6
# Date 1467652889 -3600
045ef6
#      Mon Jul 04 18:21:29 2016 +0100
045ef6
# Node ID a4541d1d8609cadb08d3e31b40b9184ff32dd6c3
045ef6
# Parent  bc6eab2038c603afb2eb2b4644f3b900c8fd0c46
045ef6
PR3083, RH1346460: Regression in SSL debug output without an ECC provider
045ef6
Summary: Return null rather than throwing an exception when there's no ECC provider.
045ef6
045ef6
diff -r bc6eab2038c6 -r a4541d1d8609 src/share/classes/sun/security/util/Debug.java
045ef6
--- openjdk/jdk/src/share/classes/sun/security/util/Debug.java	Mon Jul 04 17:08:12 2016 +0100
045ef6
+++ openjdk/jdk/src/share/classes/sun/security/util/Debug.java	Mon Jul 04 18:21:29 2016 +0100
045ef6
@@ -73,6 +73,7 @@
045ef6
         System.err.println("certpath      PKIX CertPathBuilder and");
045ef6
         System.err.println("              CertPathValidator debugging");
045ef6
         System.err.println("combiner      SubjectDomainCombiner debugging");
045ef6
+        System.err.println("ecc           Elliptic Curve Cryptography debugging");
045ef6
         System.err.println("gssloginconfig");
045ef6
         System.err.println("              GSS LoginConfigImpl debugging");
045ef6
         System.err.println("configfile    JAAS ConfigFile loading");
045ef6
diff -r bc6eab2038c6 -r a4541d1d8609 src/share/classes/sun/security/util/ECUtil.java
045ef6
--- openjdk/jdk/src/share/classes/sun/security/util/ECUtil.java	Mon Jul 04 17:08:12 2016 +0100
045ef6
+++ openjdk/jdk/src/share/classes/sun/security/util/ECUtil.java	Mon Jul 04 18:21:29 2016 +0100
045ef6
@@ -41,6 +41,9 @@
045ef6
 
045ef6
 public class ECUtil {
045ef6
 
045ef6
+    /* Are we debugging ? */
045ef6
+    private static final Debug debug = Debug.getInstance("ecc");
045ef6
+
045ef6
     // Used by SunPKCS11 and SunJSSE.
045ef6
     public static ECPoint decodePoint(byte[] data, EllipticCurve curve)
045ef6
             throws IOException {
045ef6
@@ -90,6 +93,10 @@
045ef6
     }
045ef6
 
045ef6
     private static AlgorithmParameters getECParameters(Provider p) {
045ef6
+        return getECParameters(p, false);
045ef6
+    }
045ef6
+
045ef6
+    private static AlgorithmParameters getECParameters(Provider p, boolean throwException) {
045ef6
         try {
045ef6
             if (p != null) {
045ef6
                 return AlgorithmParameters.getInstance("EC", p);
045ef6
@@ -97,13 +104,21 @@
045ef6
 
045ef6
             return AlgorithmParameters.getInstance("EC");
045ef6
         } catch (NoSuchAlgorithmException nsae) {
045ef6
-            throw new RuntimeException(nsae);
045ef6
+            if (throwException) {
045ef6
+                throw new RuntimeException(nsae);
045ef6
+            } else {
045ef6
+                // ECC provider is optional so just return null
045ef6
+                if (debug != null) {
045ef6
+                    debug.println("Provider unavailable: " + nsae);
045ef6
+                }
045ef6
+                return null;
045ef6
+            }
045ef6
         }
045ef6
     }
045ef6
 
045ef6
     public static byte[] encodeECParameterSpec(Provider p,
045ef6
                                                ECParameterSpec spec) {
045ef6
-        AlgorithmParameters parameters = getECParameters(p);
045ef6
+        AlgorithmParameters parameters = getECParameters(p, true);
045ef6
 
045ef6
         try {
045ef6
             parameters.init(spec);
045ef6
@@ -122,11 +137,16 @@
045ef6
     public static ECParameterSpec getECParameterSpec(Provider p,
045ef6
                                                      ECParameterSpec spec) {
045ef6
         AlgorithmParameters parameters = getECParameters(p);
045ef6
+        if (parameters == null)
045ef6
+            return null;
045ef6
 
045ef6
         try {
045ef6
             parameters.init(spec);
045ef6
             return parameters.getParameterSpec(ECParameterSpec.class);
045ef6
         } catch (InvalidParameterSpecException ipse) {
045ef6
+            if (debug != null) {
045ef6
+                debug.println("Invalid parameter specification: " + ipse);
045ef6
+            }
045ef6
             return null;
045ef6
         }
045ef6
     }
045ef6
@@ -135,34 +155,49 @@
045ef6
                                                      byte[] params)
045ef6
             throws IOException {
045ef6
         AlgorithmParameters parameters = getECParameters(p);
045ef6
+        if (parameters == null)
045ef6
+            return null;
045ef6
 
045ef6
         parameters.init(params);
045ef6
 
045ef6
         try {
045ef6
             return parameters.getParameterSpec(ECParameterSpec.class);
045ef6
         } catch (InvalidParameterSpecException ipse) {
045ef6
+            if (debug != null) {
045ef6
+                debug.println("Invalid parameter specification: " + ipse);
045ef6
+            }
045ef6
             return null;
045ef6
         }
045ef6
     }
045ef6
 
045ef6
     public static ECParameterSpec getECParameterSpec(Provider p, String name) {
045ef6
         AlgorithmParameters parameters = getECParameters(p);
045ef6
+        if (parameters == null)
045ef6
+            return null;
045ef6
 
045ef6
         try {
045ef6
             parameters.init(new ECGenParameterSpec(name));
045ef6
             return parameters.getParameterSpec(ECParameterSpec.class);
045ef6
         } catch (InvalidParameterSpecException ipse) {
045ef6
+            if (debug != null) {
045ef6
+                debug.println("Invalid parameter specification: " + ipse);
045ef6
+            }
045ef6
             return null;
045ef6
         }
045ef6
     }
045ef6
 
045ef6
     public static ECParameterSpec getECParameterSpec(Provider p, int keySize) {
045ef6
         AlgorithmParameters parameters = getECParameters(p);
045ef6
+        if (parameters == null)
045ef6
+            return null;
045ef6
 
045ef6
         try {
045ef6
             parameters.init(new ECKeySizeParameterSpec(keySize));
045ef6
             return parameters.getParameterSpec(ECParameterSpec.class);
045ef6
         } catch (InvalidParameterSpecException ipse) {
045ef6
+            if (debug != null) {
045ef6
+                debug.println("Invalid parameter specification: " + ipse);
045ef6
+            }
045ef6
             return null;
045ef6
         }
045ef6
 
045ef6
@@ -171,11 +206,16 @@
045ef6
     public static String getCurveName(Provider p, ECParameterSpec spec) {
045ef6
         ECGenParameterSpec nameSpec;
045ef6
         AlgorithmParameters parameters = getECParameters(p);
045ef6
+        if (parameters == null)
045ef6
+            return null;
045ef6
 
045ef6
         try {
045ef6
             parameters.init(spec);
045ef6
             nameSpec = parameters.getParameterSpec(ECGenParameterSpec.class);
045ef6
         } catch (InvalidParameterSpecException ipse) {
045ef6
+            if (debug != null) {
045ef6
+                debug.println("Invalid parameter specification: " + ipse);
045ef6
+            }
045ef6
             return null;
045ef6
         }
045ef6