3 files changed, 15 insertions, 9 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
index 712d6a46d..3f9f79fc3 100644
--- a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
@@ -97,8 +97,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
const long n = 1;
+ t0 -= n;
+
long cc = 0;
- cc += (long)xx[0] - t0 + n;
+ cc += (long)xx[0] - t0;
z[0] = (uint)cc;
cc >>= 32;
cc += (long)xx[1] - t1;
@@ -107,7 +109,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
cc += (long)xx[2] - t2;
z[2] = (uint)cc;
cc >>= 32;
- cc += (long)xx[3] + t0 - xx10 - n;
+ cc += (long)xx[3] + t0 - xx10;
z[3] = (uint)cc;
cc >>= 32;
cc += (long)xx[4] + t1 - xx11;
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
index cc2fe4866..aeb6f52fc 100644
--- a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
@@ -98,8 +98,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
const long n = 6;
+ t0 -= n;
+
long cc = 0;
- cc += (long)xx[0] + t0 - t3 - t5 - n;
+ cc += (long)xx[0] + t0 - t3 - t5;
z[0] = (uint)cc;
cc >>= 32;
cc += (long)xx[1] + t1 - t4 - t6;
@@ -108,7 +110,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
cc += (long)xx[2] + t2 - t5 - xx15;
z[2] = (uint)cc;
cc >>= 32;
- cc += (long)xx[3] + (t3 << 1) + xx13 - xx15 - t0 + n;
+ cc += (long)xx[3] + (t3 << 1) + xx13 - xx15 - t0;
z[3] = (uint)cc;
cc >>= 32;
cc += (long)xx[4] + (t4 << 1) + xx14 - t1;
@@ -117,7 +119,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
cc += (long)xx[5] + (t5 << 1) + xx15 - t2;
z[5] = (uint)cc;
cc >>= 32;
- cc += (long)xx[6] + (t6 << 1) + t5 - t0 + n;
+ cc += (long)xx[6] + (t6 << 1) + t5 - t0;
z[6] = (uint)cc;
cc >>= 32;
cc += (long)xx[7] + (xx15 << 1) + xx15 + xx08 - t2 - t4 - n;
diff --git a/crypto/src/math/ec/custom/sec/SecP384R1Field.cs b/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
index dc531f4de..a12529d2c 100644
--- a/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
@@ -97,20 +97,22 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
const long n = 1;
+ xx12 -= n;
+
long cc = 0;
- cc += (long)xx[0] + xx12 + xx20 + xx21 - xx23 - n;
+ cc += (long)xx[0] + xx12 + xx20 + xx21 - xx23;
z[0] = (uint)cc;
cc >>= 32;
- cc += (long)xx[1] + xx13 + xx22 + xx23 - xx12 - xx20 + n;
+ cc += (long)xx[1] + xx13 + xx22 + xx23 - xx12 - xx20;
z[1] = (uint)cc;
cc >>= 32;
cc += (long)xx[2] + xx14 + xx23 - xx13 - xx21;
z[2] = (uint)cc;
cc >>= 32;
- cc += (long)xx[3] + xx12 + xx15 + xx20 + xx21 - xx14 - xx22 - xx23 - n;
+ cc += (long)xx[3] + xx12 + xx15 + xx20 + xx21 - xx14 - xx22 - xx23;
z[3] = (uint)cc;
cc >>= 32;
- cc += (long)xx[4] + xx12 + xx13 + xx16 + xx20 + ((xx21 - xx23) << 1) + xx22 - xx15 - n;
+ cc += (long)xx[4] + xx12 + xx13 + xx16 + xx20 + ((xx21 - xx23) << 1) + xx22 - xx15;
z[4] = (uint)cc;
cc >>= 32;
cc += (long)xx[5] + xx13 + xx14 + xx17 + xx21 + (xx22 << 1) + xx23 - xx16;
|