diff --git a/crypto/src/security/ParameterUtilities.cs b/crypto/src/security/ParameterUtilities.cs
index 792067bba..dc6992833 100644
--- a/crypto/src/security/ParameterUtilities.cs
+++ b/crypto/src/security/ParameterUtilities.cs
@@ -299,6 +299,15 @@ namespace Org.BouncyCastle.Security
throw new SecurityUtilityException("Algorithm " + algorithm + " not recognised.");
}
+ public static ICipherParameters WithRandom(ICipherParameters cp, SecureRandom random)
+ {
+ if (random != null)
+ {
+ cp = new ParametersWithRandom(cp, random);
+ }
+ return cp;
+ }
+
private static Asn1OctetString CreateIVOctetString(
SecureRandom random,
int ivLength)
diff --git a/crypto/src/security/SignerUtilities.cs b/crypto/src/security/SignerUtilities.cs
index a9045ae6e..6107bf878 100644
--- a/crypto/src/security/SignerUtilities.cs
+++ b/crypto/src/security/SignerUtilities.cs
@@ -602,5 +602,17 @@ namespace Org.BouncyCastle.Security
{
return (string) algorithms[oid.Id];
}
+
+ public static ISigner InitSigner(DerObjectIdentifier algorithmOid, bool forSigning, AsymmetricKeyParameter privateKey, SecureRandom random)
+ {
+ return InitSigner(algorithmOid.Id, forSigning, privateKey, random);
+ }
+
+ public static ISigner InitSigner(string algorithm, bool forSigning, AsymmetricKeyParameter privateKey, SecureRandom random)
+ {
+ ISigner signer = SignerUtilities.GetSigner(algorithm);
+ signer.Init(forSigning, ParameterUtilities.WithRandom(privateKey, random));
+ return signer;
+ }
}
}
|