added ability to set digest in line with changes to OpenSSL 1.1.0
/**
* Generator for PBE derived keys and ivs as usd by OpenSSL.
* <p>
- * The scheme is a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
- * iteration count of 1.
+ * Originally this scheme was a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
+ * iteration count of 1. The default digest was changed to SHA-256 with OpenSSL 1.1.0. This
+ * implementation still defaults to MD5, but the digest can now be set.
* <p>
*/
public class OpenSSLPBEParametersGenerator
extends PBEParametersGenerator
{
- private Digest digest = DigestFactory.createMD5();
+ private final Digest digest;
/**
- * Construct a OpenSSL Parameters generator.
+ * Construct a OpenSSL Parameters generator - digest the original MD5.
*/
public OpenSSLPBEParametersGenerator()
{
+ this(DigestFactory.createMD5());
+ }
+
+ /**
+ * Construct a OpenSSL Parameters generator - digest as specified.
+ *
+ * @param digest the digest to use as the PRF.
+ */
+ public OpenSSLPBEParametersGenerator(Digest digest)
+ {
+ this.digest = digest;
}
/**
