summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/Nat224.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/math/ec/custom/sec/Nat224.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/Nat224.cs145
1 files changed, 3 insertions, 142 deletions
diff --git a/crypto/src/math/ec/custom/sec/Nat224.cs b/crypto/src/math/ec/custom/sec/Nat224.cs
index 7027f1162..f8021b19a 100644
--- a/crypto/src/math/ec/custom/sec/Nat224.cs
+++ b/crypto/src/math/ec/custom/sec/Nat224.cs
@@ -117,32 +117,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return (uint)c;
         }
 
-        // TODO Re-write to allow full range for x?
-        public static uint AddDWord(ulong x, uint[] z, int zOff)
-        {
-            Debug.Assert(zOff <= 5);
-            ulong c = x;
-            c += (ulong)z[zOff + 0];
-            z[zOff + 0] = (uint)c;
-            c >>= 32;
-            c += (ulong)z[zOff + 1];
-            z[zOff + 1] = (uint)c;
-            c >>= 32;
-            return c == 0 ? 0 : Inc(z, zOff + 2);
-        }
-
-        public static uint AddExt(uint[] xx, uint[] yy, uint[] zz)
-        {
-            ulong c = 0;
-            for (int i = 0; i < 14; ++i)
-            {
-                c += (ulong)xx[i] + yy[i];
-                zz[i] = (uint)c;
-                c >>= 32;
-            }
-            return (uint)c;
-        }
-
         public static uint AddTo(uint[] x, uint[] z)
         {
             ulong c = 0;
@@ -231,24 +205,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return (uint)c;
         }
 
-        public static uint AddWord(uint x, uint[] z, int zOff)
-        {
-            Debug.Assert(zOff <= 6);
-            ulong c = (ulong)x + z[zOff + 0];
-            z[zOff + 0] = (uint)c;
-            c >>= 32;
-            return c == 0 ? 0 : Inc(z, zOff + 1);
-        }
-
-        public static uint AddWordExt(uint x, uint[] zz, int zzOff)
-        {
-            Debug.Assert(zzOff <= 13);
-            ulong c = (ulong)x + zz[zzOff + 0];
-            zz[zzOff + 0] = (uint)c;
-            c >>= 32;
-            return c == 0 ? 0 : IncExt(zz, zzOff + 1);
-        }
-
         public static void Copy(uint[] x, uint[] z)
         {
             z[0] = x[0];
@@ -270,32 +226,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return new uint[14];
         }
 
-        public static int Dec(uint[] z, int zOff)
-        {
-            Debug.Assert(zOff <= 7);
-            for (int i = zOff; i < 7; ++i)
-            {
-                if (--z[i] != uint.MaxValue)
-                {
-                    return 0;
-                }
-            }
-            return -1;
-        }
-
-        public static int DecExt(uint[] zz, int zzOff)
-        {
-            Debug.Assert(zzOff <= 14);
-            for (int i = zzOff; i < 14; ++i)
-            {
-                if (--zz[i] != uint.MaxValue)
-                {
-                    return 0;
-                }
-            }
-            return -1;
-        }
-
         public static bool Diff(uint[] x, int xOff, uint[] y, int yOff, uint[] z, int zOff)
         {
             bool pos = Gte(x, xOff, y, yOff);
@@ -389,32 +319,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return true;
         }
 
-        public static uint Inc(uint[] z, int zOff)
-        {
-            Debug.Assert(zOff <= 7);
-            for (int i = zOff; i < 7; ++i)
-            {
-                if (++z[i] != uint.MinValue)
-                {
-                    return 0;
-                }
-            }
-            return 1;
-        }
-
-        public static uint IncExt(uint[] zz, int zzOff)
-        {
-            Debug.Assert(zzOff <= 14);
-            for (int i = zzOff; i < 14; ++i)
-            {
-                if (++zz[i] != uint.MinValue)
-                {
-                    return 0;
-                }
-            }
-            return 1;
-        }
-
         public static bool IsOne(uint[] x)
         {
             if (x[0] != 1)
@@ -806,7 +710,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             c += z[zOff + 3];
             z[zOff + 3] = (uint)c;
             c >>= 32;
-            return c == 0 ? 0 : Inc(z, zOff + 4);
+            return c == 0 ? 0 : Nat.IncAt(7, z, zOff, 4);
         }
 
         public static uint Mul33WordAdd(uint x, uint y, uint[] z, int zOff)
@@ -823,7 +727,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             c += z[zOff + 2];
             z[zOff + 2] = (uint)c;
             c >>= 32;
-            return c == 0 ? 0 : Inc(z, zOff + 3);
+            return c == 0 ? 0 : Nat.IncAt(7, z, zOff, 3);
         }
 
         public static uint MulWordDwordAdd(uint x, ulong y, uint[] z, int zOff)
@@ -839,7 +743,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             c += z[zOff + 2];
             z[zOff + 2] = (uint)c;
             c >>= 32;
-            return c == 0 ? 0 : Inc(z, zOff + 3);
+            return c == 0 ? 0 : Nat.IncAt(7, z, zOff, 3);
         }
 
         public static uint MulWord(uint x, uint[] y, uint[] z, int zOff)
@@ -1167,31 +1071,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return (int)c;
         }
 
-        // TODO Re-write to allow full range for x?
-        public static int SubDWord(ulong x, uint[] z)
-        {
-            long c = -(long)x;
-            c += (long)z[0];
-            z[0] = (uint)c;
-            c >>= 32;
-            c += (long)z[1];
-            z[1] = (uint)c;
-            c >>= 32;
-            return c == 0 ? 0 : Dec(z, 2);
-        }
-
-        public static int SubExt(uint[] xx, uint[] yy, uint[] zz)
-        {
-            long c = 0;
-            for (int i = 0; i < 14; ++i)
-            {
-                c += (long)xx[i] - yy[i];
-                zz[i] = (uint)c;
-                c >>= 32;
-            }
-            return (int)c;
-        }
-
         public static int SubFrom(uint[] x, uint[] z)
         {
             long c = 0;
@@ -1246,24 +1125,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return (int)c;
         }
 
-        public static int SubWord(uint x, uint[] z, int zOff)
-        {
-            Debug.Assert(zOff <= 6);
-            long c = (long)z[zOff + 0] - x;
-            z[zOff + 0] = (uint)c;
-            c >>= 32;
-            return c == 0 ? 0 : Dec(z, zOff + 1);
-        }
-
-        public static int SubWordExt(uint x, uint[] zz, int zzOff)
-        {
-            Debug.Assert(zzOff <= 13);
-            long c = (long)zz[zzOff + 0] - x;
-            zz[zzOff + 0] = (uint)c;
-            c >>= 32;
-            return c == 0 ? 0 : DecExt(zz, zzOff + 1);
-        }
-
         public static BigInteger ToBigInteger(uint[] x)
         {
             byte[] bs = new byte[28];