summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-08-01 20:29:01 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-08-01 20:29:01 +0700
commit0bcacb1cc7a059679117f9a6ca5a7b54ec0640ee (patch)
tree12c3ba5d46cdd8b2164a4177c0fcc3cd1e5c9b86 /crypto/src
parentRefactor ToString() (diff)
downloadBouncyCastle.NET-ed25519-0bcacb1cc7a059679117f9a6ca5a7b54ec0640ee.tar.xz
Don't create a SecureRandom unnecessarily
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/crypto/engines/RSABlindedEngine.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/crypto/src/crypto/engines/RSABlindedEngine.cs b/crypto/src/crypto/engines/RSABlindedEngine.cs

index 7b928c5fb..98108f9b4 100644 --- a/crypto/src/crypto/engines/RSABlindedEngine.cs +++ b/crypto/src/crypto/engines/RSABlindedEngine.cs
@@ -49,13 +49,29 @@ namespace Org.BouncyCastle.Crypto.Engines { ParametersWithRandom rParam = (ParametersWithRandom)param; - key = (RsaKeyParameters)rParam.Parameters; - random = rParam.Random; + this.key = (RsaKeyParameters)rParam.Parameters; + + if (key is RsaPrivateCrtKeyParameters) + { + this.random = rParam.Random; + } + else + { + this.random = null; + } } else { - key = (RsaKeyParameters)param; - random = new SecureRandom(); + this.key = (RsaKeyParameters)param; + + if (key is RsaPrivateCrtKeyParameters) + { + this.random = new SecureRandom(); + } + else + { + this.random = null; + } } }