changeset 15440:29e024ed0ea6

8164494: SunPKCS11 requires a non-empty PBE password Reviewed-by: valeriep
author vinnie
date Fri, 19 Aug 2016 22:15:32 +0100
parents b40ed911893b
children 098b5fdffd5a
files src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Fri Aug 19 13:38:12 2016 -0700
+++ b/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();