From 5db90811abc9f90c461c611613aad65b8cc36ac4 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 27 Feb 2014 11:16:09 +0700 Subject: Simplify Twice() --- crypto/src/math/ec/custom/sec/SecP521R1Field.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'crypto/src/math/ec') diff --git a/crypto/src/math/ec/custom/sec/SecP521R1Field.cs b/crypto/src/math/ec/custom/sec/SecP521R1Field.cs index f57804778..7b2c7bada 100644 --- a/crypto/src/math/ec/custom/sec/SecP521R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP521R1Field.cs @@ -130,13 +130,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec public static void Twice(uint[] x, uint[] z) { - uint c = Nat.ShiftUpBit(16, x, 0, z) | (x[16] << 1); - if (c > P16 || (c == P16 && Nat.Eq(16, z, P))) - { - c += Nat.Inc(16, z, 0); - c &= P16; - } - z[16] = c; + uint x16 = x[16]; + uint c = Nat.ShiftUpBit(16, x, x16 << 23, z) | (x16 << 1); + z[16] = c & P16; } protected static void ImplMultiply(uint[] x, uint[] y, uint[] zz) -- cgit 1.4.1