summary refs log tree commit diff
path: root/crypto/src/math
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-07-29 22:15:23 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-07-29 22:15:23 +0700
commit3fc5f0e61be2f9f6169d88b143e8c196d5e63b5e (patch)
tree47c418aa136b57c261f462d211544b8230727567 /crypto/src/math
parentfixed typo (diff)
downloadBouncyCastle.NET-ed25519-3fc5f0e61be2f9f6169d88b143e8c196d5e63b5e.tar.xz
Fix field reduction for custom secp128r1 curve
- see https://github.com/bcgit/bc-java/issues/566
Diffstat (limited to 'crypto/src/math')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP128R1Field.cs5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP128R1Field.cs b/crypto/src/math/ec/custom/sec/SecP128R1Field.cs
index d1ac009b3..cf91c7e5d 100644
--- a/crypto/src/math/ec/custom/sec/SecP128R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP128R1Field.cs
@@ -134,6 +134,11 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
                 x = (uint)c;
             }
+
+            if (z[3] >= P3 && Nat128.Gte(z, P))
+            {
+                AddPInvTo(z);
+            }
         }
 
         public static void Square(uint[] x, uint[] z)