mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8266293: Key protection using PBEWithMD5AndDES fails with "java.security.InvalidAlgorithmParameterException: Salt must be 8 bytes long"
Reviewed-by: valeriep
This commit is contained in:
parent
a90b33a955
commit
04f7112647
2 changed files with 18 additions and 3 deletions
|
@ -804,11 +804,17 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
|||
*/
|
||||
private AlgorithmParameters getPBEAlgorithmParameters(
|
||||
String algorithm, int iterationCount) throws IOException {
|
||||
AlgorithmParameters algParams = null;
|
||||
AlgorithmParameters algParams;
|
||||
|
||||
byte[] salt = getSalt();
|
||||
if (KnownOIDs.findMatch(algorithm) == KnownOIDs.PBEWithMD5AndDES) {
|
||||
// PBES1 scheme such as PBEWithMD5AndDES requires a 8-byte salt
|
||||
salt = Arrays.copyOf(salt, 8);
|
||||
}
|
||||
|
||||
// create PBE parameters from salt and iteration count
|
||||
PBEParameterSpec paramSpec =
|
||||
new PBEParameterSpec(getSalt(), iterationCount);
|
||||
new PBEParameterSpec(salt, iterationCount);
|
||||
try {
|
||||
algParams = AlgorithmParameters.getInstance(algorithm);
|
||||
algParams.init(paramSpec);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue