summary refs log tree commit diff
path: root/crypto/src/bcpg/RsaSecretBcpgKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/bcpg/RsaSecretBcpgKey.cs')
-rw-r--r--crypto/src/bcpg/RsaSecretBcpgKey.cs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/src/bcpg/RsaSecretBcpgKey.cs b/crypto/src/bcpg/RsaSecretBcpgKey.cs
index 5c04d9f85..783f083ce 100644
--- a/crypto/src/bcpg/RsaSecretBcpgKey.cs
+++ b/crypto/src/bcpg/RsaSecretBcpgKey.cs
@@ -1,6 +1,7 @@
 using System;
 
 using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Bcpg
 {
@@ -21,7 +22,7 @@ namespace Org.BouncyCastle.Bcpg
 
 			this.expP = d.Value.Remainder(p.Value.Subtract(BigInteger.One));
 			this.expQ = d.Value.Remainder(q.Value.Subtract(BigInteger.One));
-			this.crt = q.Value.ModInverse(p.Value);
+			this.crt = BigIntegers.ModOddInverse(p.Value, q.Value);
 		}
 
 		public RsaSecretBcpgKey(
@@ -44,11 +45,11 @@ namespace Org.BouncyCastle.Bcpg
 			this.d = new MPInteger(d);
 			this.p = new MPInteger(p);
 			this.q = new MPInteger(q);
-			this.u = new MPInteger(p.ModInverse(q));
+			this.u = new MPInteger(BigIntegers.ModOddInverse(q, p));
 
 			this.expP = d.Remainder(p.Subtract(BigInteger.One));
 			this.expQ = d.Remainder(q.Subtract(BigInteger.One));
-			this.crt = q.ModInverse(p);
+			this.crt = BigIntegers.ModOddInverse(p, q);
 		}
 
 		public BigInteger Modulus