diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-01 19:10:28 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-01 19:10:28 +0700 |
commit | 8405b5610adc2405c7cb1d2b25150388728adba6 (patch) | |
tree | dc311fdc9782ed7bace841ad74141f17a1b57217 /crypto/src/math/ec/ECFieldElement.cs | |
parent | Add support for delayed modular reduction (diff) | |
download | BouncyCastle.NET-ed25519-8405b5610adc2405c7cb1d2b25150388728adba6.tar.xz |
Add custom curve for secp521r1 (P-521)
Diffstat (limited to 'crypto/src/math/ec/ECFieldElement.cs')
-rw-r--r-- | crypto/src/math/ec/ECFieldElement.cs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/src/math/ec/ECFieldElement.cs b/crypto/src/math/ec/ECFieldElement.cs index 13ae32e5d..7a4c9da97 100644 --- a/crypto/src/math/ec/ECFieldElement.cs +++ b/crypto/src/math/ec/ECFieldElement.cs @@ -390,11 +390,10 @@ namespace Org.BouncyCastle.Math.EC protected virtual BigInteger ModInverse(BigInteger x) { - // Our BigInteger.ModInverse performance is quite poor, so use the new Nat/Mod classes here - //return x.ModInverse(q); - int len = (FieldSize + 31) >> 5; - uint[] p = Nat.FromBigInteger(len, q); - uint[] n = Nat.FromBigInteger(len, x); + int bits = FieldSize; + int len = (bits + 31) >> 5; + uint[] p = Nat.FromBigInteger(bits, q); + uint[] n = Nat.FromBigInteger(bits, x); uint[] z = Nat.Create(len); Mod.Invert(p, n, z); return Nat.ToBigInteger(len, z); |