8145344: Add SHA1 and SHA-224 to preferred provider list for solaris-sparc
authorascarpino
Tue, 02 Feb 2016 11:27:18 -0800
changeset 35643 ada9a798efee
parent 35642 e45a64dce0f6
child 35697 7fa18fc6e339
8145344: Add SHA1 and SHA-224 to preferred provider list for solaris-sparc Reviewed-by: vinnie, jnimeh
jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java
jdk/src/java.base/share/conf/security/java.security
jdk/test/sun/security/jca/PreferredProviderTest.java
--- a/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java	Tue Feb 02 17:20:53 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java	Tue Feb 02 11:27:18 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -653,6 +653,7 @@
         String type = null;
         String algorithm;
         String provider;
+        String alternateName = null;
 
         PreferredEntry(String t, String p) {
             int i = t.indexOf('.');
@@ -664,6 +665,11 @@
             }
 
             provider = p;
+            if (algorithm.compareToIgnoreCase("SHA1") == 0) {
+                alternateName = "SHA-1";
+            } else if (algorithm.compareToIgnoreCase("SHA-1") == 0) {
+                alternateName = "SHA1";
+            }
         }
 
         boolean match(String t, String a) {
@@ -685,6 +691,15 @@
                 return true;
             }
 
+            if (alternateName != null &&
+                    a.compareToIgnoreCase(alternateName) == 0) {
+                if (debug != null) {
+                    debug.println("Config entry found (alternateName):  " +
+                            toString());
+                }
+                return true;
+            }
+
             // No match
             return false;
         }
--- a/jdk/src/java.base/share/conf/security/java.security	Tue Feb 02 17:20:53 2016 +0000
+++ b/jdk/src/java.base/share/conf/security/java.security	Tue Feb 02 11:27:18 2016 -0800
@@ -109,7 +109,8 @@
 #   jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \
 #         MessageDigest.SHA-256:SUN
 #ifdef solaris-sparc
-jdk.security.provider.preferred=AES:SunJCE, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
+jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, SHA-224:SUN, \
+      SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
 #endif
 #ifdef solaris-x86
 jdk.security.provider.preferred=AES:SunJCE, RSA:SunRsaSign
--- a/jdk/test/sun/security/jca/PreferredProviderTest.java	Tue Feb 02 17:20:53 2016 +0000
+++ b/jdk/test/sun/security/jca/PreferredProviderTest.java	Tue Feb 02 11:27:18 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8076359 8133151
+ * @bug 8076359 8133151 8145344
  * @summary Test the value for new jdk.security.provider.preferred security property
  * @requires os.name == "SunOS"
  */
@@ -40,8 +40,9 @@
 public class PreferredProviderTest {
 
     private static final List<DataTuple> SPARC_DATA = Arrays.asList(
-            new DataTuple("SHA-256", "SUN"), new DataTuple("SHA-384", "SUN"),
-            new DataTuple("SHA-512", "SUN"));
+            new DataTuple("SHA1", "SUN"), new DataTuple("SHA-1", "SUN"),
+            new DataTuple("SHA-224", "SUN"), new DataTuple("SHA-256", "SUN"),
+            new DataTuple("SHA-384", "SUN"), new DataTuple("SHA-512", "SUN"));
     private static final List<DataTuple> X86_DATA = Arrays
             .asList(new DataTuple("RSA", "SunRsaSign"));
 
@@ -52,7 +53,7 @@
         String actualProvider = null;
         if (type.equals("sparcv9")) {
             if (!preferredProvider.equals(
-                    "AES:SunJCE, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN")) {
+                    "AES:SunJCE, SHA1:SUN, SHA-224:SUN, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN")) {
                 throw new RuntimeException(
                         "Test Failed: wrong jdk.security.provider.preferred "
                                 + "value on solaris-sparcv9");