Don't get a SecureRandom unnecessarily
@@ -40,13 +40,29 @@ public void init(
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
- key = (RSAKeyParameters)rParam.getParameters();
- random = rParam.getRandom();
+ this.key = (RSAKeyParameters)rParam.getParameters();
+
+ if (key instanceof RSAPrivateCrtKeyParameters)
+ {
+ this.random = rParam.getRandom();
+ }
+ else
+ {
+ this.random = null;
+ }
}
else
{
- key = (RSAKeyParameters)param;
- random = CryptoServicesRegistrar.getSecureRandom();
+ this.key = (RSAKeyParameters)param;
+
+ if (key instanceof RSAPrivateCrtKeyParameters)
+ {
+ this.random = CryptoServicesRegistrar.getSecureRandom();
+ }
+ else
+ {
+ this.random = null;
+ }
}
}
