summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2017-06-03 17:54:33 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2017-06-03 17:54:33 +0700
commite0b74ac5076f2b2ff2430110530014bd114584e7 (patch)
tree7c651d4014ad91c6c1a1c369da987e3b038b51ed
parentImprove error handling/messages (diff)
downloadBouncyCastle.NET-ed25519-e0b74ac5076f2b2ff2430110530014bd114584e7.tar.xz
Fix reductions for custom secp128r1 field
-rw-r--r--crypto/src/math/ec/custom/sec/SecP128R1Field.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP128R1Field.cs b/crypto/src/math/ec/custom/sec/SecP128R1Field.cs
index ff6fb6b65..d1ac009b3 100644
--- a/crypto/src/math/ec/custom/sec/SecP128R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP128R1Field.cs
@@ -19,7 +19,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static void Add(uint[] x, uint[] y, uint[] z)
         {
             uint c = Nat128.Add(x, y, z);
-            if (c != 0 || (z[3] == P3 && Nat128.Gte(z, P)))
+            if (c != 0 || (z[3] >= P3 && Nat128.Gte(z, P)))
             {
                 AddPInvTo(z);
             }
@@ -28,7 +28,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static void AddExt(uint[] xx, uint[] yy, uint[] zz)
         {
             uint c = Nat256.Add(xx, yy, zz);
-            if (c != 0 || (zz[7] == PExt7 && Nat256.Gte(zz, PExt)))
+            if (c != 0 || (zz[7] >= PExt7 && Nat256.Gte(zz, PExt)))
             {
                 Nat.AddTo(PExtInv.Length, PExtInv, zz);
             }
@@ -37,7 +37,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static void AddOne(uint[] x, uint[] z)
         {
             uint c = Nat.Inc(4, x, z);
-            if (c != 0 || (z[3] == P3 && Nat128.Gte(z, P)))
+            if (c != 0 || (z[3] >= P3 && Nat128.Gte(z, P)))
             {
                 AddPInvTo(z);
             }
@@ -46,7 +46,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static uint[] FromBigInteger(BigInteger x)
         {
             uint[] z = Nat128.FromBigInteger(x);
-            if (z[3] == P3 && Nat128.Gte(z, P))
+            if (z[3] >= P3 && Nat128.Gte(z, P))
             {
                 Nat128.SubFrom(P, z);
             }
@@ -76,7 +76,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static void MultiplyAddToExt(uint[] x, uint[] y, uint[] zz)
         {
             uint c = Nat128.MulAddTo(x, y, zz);
-            if (c != 0 || (zz[7] == PExt7 && Nat256.Gte(zz, PExt)))
+            if (c != 0 || (zz[7] >= PExt7 && Nat256.Gte(zz, PExt)))
             {
                 Nat.AddTo(PExtInv.Length, PExtInv, zz);
             }
@@ -179,7 +179,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static void Twice(uint[] x, uint[] z)
         {
             uint c = Nat.ShiftUpBit(4, x, 0, z);
-            if (c != 0 || (z[3] == P3 && Nat128.Gte(z, P)))
+            if (c != 0 || (z[3] >= P3 && Nat128.Gte(z, P)))
             {
                 AddPInvTo(z);
             }