changeset 8598:f7b8e5e5e143

8173622: Backport of 7180907 is incomplete Summary: Add missing fragments from OpenJDK 8 version of 7180907 Reviewed-by: omajid
author weijun
date Mon, 30 Jan 2017 08:21:56 +0000
parents 86ebe8c365f1
children a54eda20411f
files src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java src/share/classes/sun/security/x509/AlgorithmId.java
diffstat 2 files changed, 11 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Mon Jan 30 08:08:52 2017 +0000
+++ b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Mon Jan 30 08:21:56 2017 +0000
@@ -1311,11 +1311,9 @@
            try {
                 String algName =
                         macData.getDigestAlgName().toUpperCase(Locale.ENGLISH);
-                if (algName.equals("SHA")  ||
-                    algName.equals("SHA1") ||
-                    algName.equals("SHA-1")) {
-                    algName = "SHA1";
-                }
+
+                // Change SHA-1 to SHA1
+                algName = algName.replace("-", "");
 
                 // generate MAC (MAC key is created within JCE)
                 Mac m = Mac.getInstance("HmacPBE" + algName);
--- a/src/share/classes/sun/security/x509/AlgorithmId.java	Mon Jan 30 08:08:52 2017 +0000
+++ b/src/share/classes/sun/security/x509/AlgorithmId.java	Mon Jan 30 08:21:56 2017 +0000
@@ -242,10 +242,7 @@
                 AlgorithmId paramsId =
                         AlgorithmId.parse(new DerValue(getEncodedParams()));
                 String paramsName = paramsId.getName();
-                if (paramsName.equals("SHA")) {
-                    paramsName = "SHA1";
-                }
-                algName = paramsName + "withECDSA";
+                algName = makeSigAlg(paramsName, "EC");
             } catch (IOException e) {
                 // ignore
             }
@@ -889,11 +886,11 @@
         nameTable = new HashMap<ObjectIdentifier,String>();
         nameTable.put(MD5_oid, "MD5");
         nameTable.put(MD2_oid, "MD2");
-        nameTable.put(SHA_oid, "SHA");
-        nameTable.put(SHA224_oid, "SHA224");
-        nameTable.put(SHA256_oid, "SHA256");
-        nameTable.put(SHA384_oid, "SHA384");
-        nameTable.put(SHA512_oid, "SHA512");
+        nameTable.put(SHA_oid, "SHA-1");
+        nameTable.put(SHA224_oid, "SHA-224");
+        nameTable.put(SHA256_oid, "SHA-256");
+        nameTable.put(SHA384_oid, "SHA-384");
+        nameTable.put(SHA512_oid, "SHA-512");
         nameTable.put(RSAEncryption_oid, "RSA");
         nameTable.put(RSA_oid, "RSA");
         nameTable.put(DH_oid, "Diffie-Hellman");
@@ -934,11 +931,8 @@
      * name and a encryption algorithm name.
      */
     public static String makeSigAlg(String digAlg, String encAlg) {
-        digAlg = digAlg.replace("-", "").toUpperCase(Locale.ENGLISH);
-        if (digAlg.equalsIgnoreCase("SHA")) digAlg = "SHA1";
-
-        encAlg = encAlg.toUpperCase(Locale.ENGLISH);
-        if (encAlg.equals("EC")) encAlg = "ECDSA";
+        digAlg = digAlg.replace("-", "");
+        if (encAlg.equalsIgnoreCase("EC")) encAlg = "ECDSA";
 
         return digAlg + "with" + encAlg;
     }