From b5402e83610e8eed4e54ca3b098c077518a090ef Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 27 Feb 2014 12:08:37 +0700 Subject: Optimize final adjustments in Reduce() --- crypto/src/math/ec/custom/sec/SecP224R1Field.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'crypto/src/math/ec') diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs index f2b9eda64..da01cb742 100644 --- a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs @@ -115,24 +115,15 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec cc >>= 32; int c = (int)cc; - if (c < 0) + if (c > 0) { - do - { - c += (int)Nat224.Add(z, P, z); - } - while (c < 0); + Reduce32((uint)c, z); } else { - while (c > 0) + while (c < 0) { - c += Nat224.Sub(z, P, z); - } - - if (z[6] == P6 && Nat224.Gte(z, P)) - { - Nat224.Sub(z, P, z); + c += (int)Nat224.Add(z, P, z); } } } -- cgit 1.4.1