From 0bcacb1cc7a059679117f9a6ca5a7b54ec0640ee Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 1 Aug 2019 20:29:01 +0700 Subject: Don't create a SecureRandom unnecessarily --- crypto/src/crypto/engines/RSABlindedEngine.cs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'crypto/src') 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; + } } } -- cgit 1.5.1