diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-01 20:29:01 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-01 20:29:01 +0700 |
commit | 0bcacb1cc7a059679117f9a6ca5a7b54ec0640ee (patch) | |
tree | 12c3ba5d46cdd8b2164a4177c0fcc3cd1e5c9b86 | |
parent | Refactor ToString() (diff) | |
download | BouncyCastle.NET-ed25519-0bcacb1cc7a059679117f9a6ca5a7b54ec0640ee.tar.xz |
Don't create a SecureRandom unnecessarily
-rw-r--r-- | crypto/src/crypto/engines/RSABlindedEngine.cs | 24 |
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; + } } } |