8167371: KeyStoreSpi.engineSetEntry should throw an Exception if password protection alg is specified

Reviewed-by: xuelei, mullan
This commit is contained in:
Vinnie Ryan 2016-10-13 12:37:42 +01:00
parent 410b8c8f8f
commit 02ca9985fc
2 changed files with 50 additions and 2 deletions

View file

@ -479,6 +479,10 @@ public abstract class KeyStoreSpi {
} else if (engineIsKeyEntry(alias)) {
KeyStore.PasswordProtection pp =
(KeyStore.PasswordProtection)protParam;
if (pp.getProtectionAlgorithm() != null) {
throw new KeyStoreException(
"unsupported password protection algorithm");
}
char[] password = pp.getPassword();
Key key = engineGetKey(alias, password);
@ -524,6 +528,10 @@ public abstract class KeyStoreSpi {
KeyStore.PasswordProtection pProtect = null;
if (protParam != null) {
pProtect = (KeyStore.PasswordProtection)protParam;
if (pProtect.getProtectionAlgorithm() != null) {
throw new KeyStoreException(
"unsupported password protection algorithm");
}
}
// set entry