summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-03-05 11:53:21 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-03-05 11:53:21 +0700
commit7e777150e04e7e74dbf28f8e0a922bd2a5f8d94a (patch)
treea9ce36cb2d6a01be55b4876492bab81c8ca75463 /crypto/src/math/ec/custom/sec/SecP256R1Field.cs
parentFix infinite loop issue when there is no sqrt (diff)
downloadBouncyCastle.NET-ed25519-7e777150e04e7e74dbf28f8e0a922bd2a5f8d94a.tar.xz
Use Nat methods instead of specific Nat*.*Ext methods
Reduction improvements in curve25519 and secp256r1
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP256R1Field.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256R1Field.cs3
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
index de383046d..cd4702f16 100644
--- a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs
@@ -14,6 +14,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         private static readonly uint[] _2P = new uint[]{ 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000001, 0x00000000, 0x00000000,
             0x00000002, 0xFFFFFFFE, 0x00000001 };
         private const uint P7 = 0xFFFFFFFF;
+        private const uint PExt15 = 0xFFFFFFFE;
 
         public static void Add(uint[] x, uint[] y, uint[] z)
         {
@@ -27,7 +28,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         public static void AddExt(uint[] xx, uint[] yy, uint[] zz)
         {
             uint c = Nat.Add(16, xx, yy, zz);
-            if (c != 0 || Nat256.GteExt(zz, PExt))
+            if (c != 0 || (zz[15] >= PExt15 && Nat.Gte(16, zz, PExt)))
             {
                 Nat.SubFrom(16, PExt, zz);
             }