diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-30 18:25:13 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-30 18:25:13 +0400 |
commit | 385a6b665ddd0c5f8c2674b04e6b6b7dba8779ef (patch) | |
tree | 36ce0f32dc004b2257d177ad661a865867c1e7c4 /core/src/main/java/org/bouncycastle/math | |
parent | 87b117dc2695e723ea3f2e9b1d79f81d14214612 (diff) |
Fix final step of reduce()
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math')
-rw-r--r-- | core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Field.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Field.java b/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Field.java index 94bbef69..eecba2f2 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Field.java +++ b/core/src/main/java/org/bouncycastle/math/ec/custom/sec/SecP256R1Field.java @@ -116,27 +116,26 @@ public class SecP256R1Field cc >>= 32; int c = (int)cc; - if (c > 0) + if (c < 0) { do { + c += 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 += Nat256.add(z, P, z); - } - while (c != 0); - } } public static void square(int[] x, int[] z) |