diff --git a/crypto/src/crypto/engines/RSABlindedEngine.cs b/crypto/src/crypto/engines/RSABlindedEngine.cs
index cdc0a7844..d207f617c 100644
--- a/crypto/src/crypto/engines/RSABlindedEngine.cs
+++ b/crypto/src/crypto/engines/RSABlindedEngine.cs
@@ -104,10 +104,7 @@ namespace Org.BouncyCastle.Crypto.Engines
* @return the result of the RSA process.
* @exception DataLengthException the input block is too large.
*/
- public virtual byte[] ProcessBlock(
- byte[] inBuf,
- int inOff,
- int inLen)
+ public virtual byte[] ProcessBlock(byte[] inBuf, int inOff, int inLen)
{
if (key == null)
throw new InvalidOperationException("RSA engine not initialised");
@@ -115,30 +112,22 @@ namespace Org.BouncyCastle.Crypto.Engines
BigInteger input = core.ConvertInput(inBuf, inOff, inLen);
BigInteger result;
- if (key is RsaPrivateCrtKeyParameters)
+ if (key is RsaPrivateCrtKeyParameters crt)
{
- RsaPrivateCrtKeyParameters k = (RsaPrivateCrtKeyParameters)key;
- BigInteger e = k.PublicExponent;
- if (e != null) // can't do blinding without a public exponent
- {
- BigInteger m = k.Modulus;
- BigInteger r = BigIntegers.CreateRandomInRange(
- BigInteger.One, m.Subtract(BigInteger.One), random);
+ BigInteger e = crt.PublicExponent;
+ BigInteger m = crt.Modulus;
+ BigInteger r = BigIntegers.CreateRandomInRange(
+ BigInteger.One, m.Subtract(BigInteger.One), random);
- BigInteger blindedInput = r.ModPow(e, m).Multiply(input).Mod(m);
- BigInteger blindedResult = core.ProcessBlock(blindedInput);
+ BigInteger blindedInput = r.ModPow(e, m).Multiply(input).Mod(m);
+ BigInteger blindedResult = core.ProcessBlock(blindedInput);
- BigInteger rInv = BigIntegers.ModOddInverse(m, r);
- result = blindedResult.Multiply(rInv).Mod(m);
+ BigInteger rInv = BigIntegers.ModOddInverse(m, r);
+ result = blindedResult.Multiply(rInv).Mod(m);
- // defence against Arjen Lenstra’s CRT attack
- if (!input.Equals(result.ModPow(e, m)))
- throw new InvalidOperationException("RSA engine faulty decryption/signing detected");
- }
- else
- {
- result = core.ProcessBlock(input);
- }
+ // defence against Arjen Lenstra’s CRT attack
+ if (!input.Equals(result.ModPow(e, m)))
+ throw new InvalidOperationException("RSA engine faulty decryption/signing detected");
}
else
{
|