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