diff --git a/src/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java b/src/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java index e85b8816a28c86e7572ab9ba7aed1a3171946378..9c76839f385b2b31c4be3b1cdf831b9c6219ee03 100644 --- a/src/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java +++ b/src/share/classes/com/sun/crypto/provider/HmacPKCS12PBESHA1.java @@ -73,62 +73,69 @@ public final class HmacPKCS12PBESHA1 extends HmacCore { 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