summary refs log tree commit diff
path: root/crypto/src/math
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-02-27 12:08:37 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-02-27 12:08:37 +0700
commitb5402e83610e8eed4e54ca3b098c077518a090ef (patch)
tree4e43f0d8a9f476606d13dd540a01d74422206b7f /crypto/src/math
parentSimplify Twice() (diff)
downloadBouncyCastle.NET-ed25519-b5402e83610e8eed4e54ca3b098c077518a090ef.tar.xz
Optimize final adjustments in Reduce()
Diffstat (limited to 'crypto/src/math')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP224R1Field.cs17
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);
                 }
             }
         }