diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-27 12:08:37 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-27 12:08:37 +0700 |
commit | b5402e83610e8eed4e54ca3b098c077518a090ef (patch) | |
tree | 4e43f0d8a9f476606d13dd540a01d74422206b7f | |
parent | Simplify Twice() (diff) | |
download | BouncyCastle.NET-ed25519-b5402e83610e8eed4e54ca3b098c077518a090ef.tar.xz |
Optimize final adjustments in Reduce()
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP224R1Field.cs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs index f2b9eda64..da01cb742 100644 --- a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs @@ -115,24 +115,15 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec cc >>= 32; int c = (int)cc; - if (c < 0) + if (c > 0) { - do - { - c += (int)Nat224.Add(z, P, z); - } - while (c < 0); + Reduce32((uint)c, z); } else { - while (c > 0) + while (c < 0) { - c += Nat224.Sub(z, P, z); - } - - if (z[6] == P6 && Nat224.Gte(z, P)) - { - Nat224.Sub(z, P, z); + c += (int)Nat224.Add(z, P, z); } } } |