diff -r 0265a70ea2a5 -r c9a3e3cac9c7 src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java --- a/src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java Thu Aug 23 10:52:27 2018 +0200 +++ b/src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java Thu Aug 23 11:37:14 2018 +0100 @@ -104,6 +104,7 @@ Arrays.fill(D, (byte)type); concat(salt, I, 0, s); concat(passwd, I, s, p); + Arrays.fill(passwd, (byte) 0x00); byte[] Ai; byte[] B = new byte[v]; @@ -268,87 +269,92 @@ salt = pbeKey.getSalt(); // maybe null if unspecified iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified } else if (key instanceof SecretKey) { - byte[] passwdBytes = key.getEncoded(); - if ((passwdBytes == null) || - !(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) { + byte[] passwdBytes; + if (!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3)) || + (passwdBytes = key.getEncoded()) == null) { throw new InvalidKeyException("Missing password"); } passwdChars = new char[passwdBytes.length]; for (int i=0; i