From 745143a518d71a026e142007b6a4bc831e2ae13b Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 2 Feb 2016 18:09:16 +0700 Subject: Additional temp values in reduction --- crypto/src/math/ec/custom/sec/SecP256R1Field.cs | 7 ++++--- crypto/src/math/ec/custom/sec/SecP384R1Field.cs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'crypto/src/math/ec') diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs index 11594b2ba..5b3de6d36 100644 --- a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs @@ -110,9 +110,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec long t4 = xx12 + xx13; long t5 = xx13 + xx14; long t6 = xx14 + xx15; + long t7 = t5 - t0; long cc = 0; - cc += (long)xx[0] + t0 - t3 - t5; + cc += (long)xx[0] - t3 - t7; z[0] = (uint)cc; cc >>= 32; cc += (long)xx[1] + t1 - t4 - t6; @@ -121,7 +122,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec cc += (long)xx[2] + t2 - t5; z[2] = (uint)cc; cc >>= 32; - cc += (long)xx[3] + (t3 << 1) + xx13 - xx15 - t0; + cc += (long)xx[3] + (t3 << 1) + t7 - t6; z[3] = (uint)cc; cc >>= 32; cc += (long)xx[4] + (t4 << 1) + xx14 - t1; @@ -130,7 +131,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec cc += (long)xx[5] + (t5 << 1) - t2; z[5] = (uint)cc; cc >>= 32; - cc += (long)xx[6] + (t6 << 1) + t5 - t0; + cc += (long)xx[6] + (t6 << 1) + t7; z[6] = (uint)cc; cc >>= 32; cc += (long)xx[7] + (xx15 << 1) + xx08 - t2 - t4; diff --git a/crypto/src/math/ec/custom/sec/SecP384R1Field.cs b/crypto/src/math/ec/custom/sec/SecP384R1Field.cs index 7820775ee..0780df3f0 100644 --- a/crypto/src/math/ec/custom/sec/SecP384R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP384R1Field.cs @@ -105,9 +105,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec long t4 = xx17 + xx21; long t5 = xx21 - xx23; long t6 = xx22 - xx23; + long t7 = t0 + t5; long cc = 0; - cc += (long)xx[0] + t0 + t5; + cc += (long)xx[0] + t7; z[0] = (uint)cc; cc >>= 32; cc += (long)xx[1] + xx23 - t0 + t1; @@ -116,10 +117,10 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec cc += (long)xx[2] - xx21 - t1 + t2; z[2] = (uint)cc; cc >>= 32; - cc += (long)xx[3] + t0 - t2 + t3 + t5; + cc += (long)xx[3] - t2 + t3 + t7; z[3] = (uint)cc; cc >>= 32; - cc += (long)xx[4] + xx16 + xx21 + t0 + t1 - t3 + t5; + cc += (long)xx[4] + xx16 + xx21 + t1 - t3 + t7; z[4] = (uint)cc; cc >>= 32; cc += (long)xx[5] - xx16 + t1 + t2 + t4; -- cgit 1.4.1