From 8614e492c5ca2733d581b37f9d0e7d6714bb0a29 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 11 Sep 2020 11:07:11 +0700 Subject: Further Divsteps30 improvement --- crypto/src/math/raw/Mod.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'crypto') diff --git a/crypto/src/math/raw/Mod.cs b/crypto/src/math/raw/Mod.cs index 1a1524c11..a1eeaa9b7 100644 --- a/crypto/src/math/raw/Mod.cs +++ b/crypto/src/math/raw/Mod.cs @@ -278,21 +278,19 @@ namespace Org.BouncyCastle.Math.Raw Debug.Assert((u * f0 + v * g0) == f << i); Debug.Assert((q * f0 + r * g0) == g << i); - int p = -(g & 1); - int s = eta >> 31; + int c1 = eta >> 31; + int c2 = -(g & 1); - int c1 = p & s; - int c2 = p & ~s; + int x = (f ^ c1) - c1; + int y = (u ^ c1) - c1; + int z = (v ^ c1) - c1; - eta = (eta ^ c1) - (c1 + 1); - - g += f & c2; - q += u & c2; - r += v & c2; + g += x & c2; + q += y & c2; + r += z & c2; - g -= f & c1; - q -= u & c1; - r -= v & c1; + c1 &= c2; + eta = (eta ^ c1) - (c1 + 1); f += g & c1; u += q & c1; -- cgit 1.4.1