8164494: SunPKCS11 requires a non-empty PBE password
authorvinnie
Fri, 19 Aug 2016 22:15:32 +0100
changeset 40452 423fab158db3
parent 40451 17dd00080a7c
child 40453 0d68f70ab984
8164494: SunPKCS11 requires a non-empty PBE password Reviewed-by: valeriep
jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Fri Aug 19 13:38:12 2016 -0700
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Fri Aug 19 22:15:32 2016 +0100
@@ -108,6 +108,11 @@
         }
         try {
             this.prf = Mac.getInstance(prfAlgo);
+            // SunPKCS11 requires a non-empty PBE password
+            if (passwdBytes.length == 0 &&
+                this.prf.getProvider().getName().startsWith("SunPKCS11")) {
+                this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
+            }
         } catch (NoSuchAlgorithmException nsae) {
             // not gonna happen; re-throw just in case
             InvalidKeySpecException ike = new InvalidKeySpecException();