From e0b74ac5076f2b2ff2430110530014bd114584e7 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 3 Jun 2017 17:54:33 +0700 Subject: Fix reductions for custom secp128r1 field --- crypto/src/math/ec/custom/sec/SecP128R1Field.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crypto/src/math/ec') 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); } -- cgit 1.4.1