added support for SCRYPT with key encryption algorithms that don't have parameters (eg. AESKWP).
@@ -209,10 +209,22 @@ else if (algorithm.equals(PKCSObjectIdentifiers.id_PBES2))
cipher.init(Cipher.ENCRYPT_MODE, simplifyPbeKey(key), random);
- PBES2Parameters algParams = new PBES2Parameters(
+ AlgorithmParameters algP = cipher.getParameters();
+
+ PBES2Parameters algParams;
+
+ if (algP != null)
+ {
+ algParams = new PBES2Parameters(
new KeyDerivationFunc(MiscObjectIdentifiers.id_scrypt, params),
new EncryptionScheme(keyEncAlgorithm, ASN1Primitive.fromByteArray(cipher.getParameters().getEncoded())));
-
+ }
+ else
+ {
+ algParams = new PBES2Parameters(
+ new KeyDerivationFunc(MiscObjectIdentifiers.id_scrypt, params),
+ new EncryptionScheme(keyEncAlgorithm));
+ }
encryptionAlg = new AlgorithmIdentifier(algorithm, algParams);
}
else
