summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-03-03 14:53:32 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-03-03 14:53:32 +0700
commit208038d681e1ee46d33079e9221e10fe4a6aa25c (patch)
tree9ea820b68d29437204b044b8939afe6e4fd79046 /crypto/src/math/ec/custom/sec/SecP224R1Field.cs
parentAdd/rename MulAddTo variations (diff)
downloadBouncyCastle.NET-ed25519-208038d681e1ee46d33079e9221e10fe4a6aa25c.tar.xz
Refactor reduction methods and change scope of PExt fields
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP224R1Field.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP224R1Field.cs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
index da01cb742..bd6656b27 100644
--- a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs
@@ -7,9 +7,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
     {
         // 2^224 - 2^96 + 1
         internal static readonly uint[] P = new uint[] { 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
-        private const uint P6 = 0xFFFFFFFF;
-        private static readonly uint[] PExt = new uint[]{ 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF,
+        internal static readonly uint[] PExt = new uint[]{ 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF,
             0xFFFFFFFF, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
+        private const uint P6 = 0xFFFFFFFF;
         private const uint PExt13 = 0xFFFFFFFF;
 
         public static void Add(uint[] x, uint[] y, uint[] z)
@@ -115,7 +115,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             cc >>= 32;
 
             int c = (int)cc;
-            if (c > 0)
+            if (c >= 0)
             {
                 Reduce32((uint)c, z);
             }
@@ -130,8 +130,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public static void Reduce32(uint x, uint[] z)
         {
-            int c = Nat224.SubWord(x, z, 0) + (int)Nat224.AddWord(x, z, 3);
-            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
+            if ((x != 0 && (Nat224.SubWord(x, z, 0) + Nat224.AddWord(x, z, 3) != 0))
+                || (z[6] == P6 && Nat224.Gte(z, P)))
             {
                 Nat224.Sub(z, P, z);
             }