diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-30 21:26:02 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-30 21:26:02 +0700 |
commit | 410a99b2871b3ec203affe141bd17dbc1312ed07 (patch) | |
tree | f41e97fdbea388ec33f53ab016fa31546483bf22 /crypto/src/math/ec/custom/sec | |
parent | Fix GetBit range-check (diff) | |
download | BouncyCastle.NET-ed25519-410a99b2871b3ec203affe141bd17dbc1312ed07.tar.xz |
Fix final step of Reduce()
Diffstat (limited to 'crypto/src/math/ec/custom/sec')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP256R1Field.cs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs index cb9874bfd..eab4af956 100644 --- a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs @@ -115,27 +115,26 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec cc >>= 32; int c = (int)cc; - if (c > 0) + if (c < 0) { do { + c += (int)Nat256.Add(z, P, z); + } + while (c < 0); + } + else + { + while (c > 0) + { c += Nat256.Sub(z, P, z); } - while (c != 0); if (z[7] == P7 && Nat256.Gte(z, P)) { Nat256.Sub(z, P, z); } } - else if (c < 0) - { - do - { - c += (int)Nat256.Add(z, P, z); - } - while (c != 0); - } } public static void Square(uint[] x, uint[] z) |