Skip to content

Commit 0ad3e3a

Browse files
committed
github #262 added settable digest to OpenSSL PBE generator
1 parent 8737142 commit 0ad3e3a

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

crypto/src/crypto/generators/OpenSSLPBEParametersGenerator.cs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,39 @@
66

77
namespace Org.BouncyCastle.Crypto.Generators
88
{
9-
/**
10-
* Generator for PBE derived keys and ivs as usd by OpenSSL.
11-
* <p>
12-
* The scheme is a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
13-
* iteration count of 1.
14-
* </p>
15-
*/
9+
///
10+
/// <description>
11+
///
12+
/// Generator for PBE derived keys and ivs as usd by OpenSSL.
13+
/// <p>
14+
/// Originally this scheme was a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
15+
/// iteration count of 1. The default digest was changed to SHA-256 with OpenSSL 1.1.0. This
16+
/// implementation still defaults to MD5, but the digest can now be set.
17+
/// </description>
18+
///
1619
public class OpenSslPbeParametersGenerator
1720
: PbeParametersGenerator
1821
{
19-
private readonly IDigest digest = new MD5Digest();
22+
private readonly IDigest digest;
23+
24+
///
25+
/// <description>
26+
/// Construct a OpenSSL Parameters generator - digest the original MD5.
27+
/// </description>
28+
///
29+
public OpenSslPbeParametersGenerator() : this(new MD5Digest())
30+
{
31+
}
2032

21-
/**
22-
* Construct a OpenSSL Parameters generator.
23-
*/
24-
public OpenSslPbeParametersGenerator()
33+
///
34+
/// <description>
35+
/// Construct a OpenSSL Parameters generator - digest as specified.
36+
/// </description>
37+
/// <param name="digest">the digest to use as the PRF.</param>
38+
///
39+
public OpenSslPbeParametersGenerator(IDigest digest)
2540
{
41+
this.digest = digest;
2642
}
2743

2844
public override void Init(

0 commit comments

Comments
 (0)