1 files changed, 9 insertions, 10 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
index cb9874bfd..eab4af956 100644
--- a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
@@ -115,27 +115,26 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
cc >>= 32;
int c = (int)cc;
- if (c > 0)
+ if (c < 0)
{
do
{
+ c += (int)Nat256.Add(z, P, z);
+ }
+ while (c < 0);
+ }
+ else
+ {
+ while (c > 0)
+ {
c += Nat256.Sub(z, P, z);
}
- while (c != 0);
if (z[7] == P7 && Nat256.Gte(z, P))
{
Nat256.Sub(z, P, z);
}
}
- else if (c < 0)
- {
- do
- {
- c += (int)Nat256.Add(z, P, z);
- }
- while (c != 0);
- }
}
public static void Square(uint[] x, uint[] z)
|