summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/Nat224.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-03-03 14:51:57 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-03-03 14:51:57 +0700
commitd64a63800bdbb629722b58c98a9c1868728621ab (patch)
tree9563f7c8fb9ccdf01841c29fe4a523123644fd68 /crypto/src/math/ec/custom/sec/Nat224.cs
parentAllow for (very rare) cases where the Sqrt() algorithm needs to retry (diff)
downloadBouncyCastle.NET-ed25519-d64a63800bdbb629722b58c98a9c1868728621ab.tar.xz
Add/rename MulAddTo variations
Diffstat (limited to 'crypto/src/math/ec/custom/sec/Nat224.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/Nat224.cs44
1 files changed, 43 insertions, 1 deletions
diff --git a/crypto/src/math/ec/custom/sec/Nat224.cs b/crypto/src/math/ec/custom/sec/Nat224.cs
index 357ce5c69..abc55b3e7 100644
--- a/crypto/src/math/ec/custom/sec/Nat224.cs
+++ b/crypto/src/math/ec/custom/sec/Nat224.cs
@@ -557,7 +557,49 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             }
         }
 
-        public static uint MulAdd(uint[] x, int xOff, uint[] y, int yOff, uint[] zz, int zzOff)
+        public static uint MulAddTo(uint[] x, uint[] y, uint[] zz)
+        {
+            ulong y_0 = y[0];
+            ulong y_1 = y[1];
+            ulong y_2 = y[2];
+            ulong y_3 = y[3];
+            ulong y_4 = y[4];
+            ulong y_5 = y[5];
+            ulong y_6 = y[6];
+
+            ulong zc = 0;
+            for (int i = 0; i < 7; ++i)
+            {
+                ulong c = 0, x_i = x[i];
+                c += x_i * y_0 + zz[i + 0];
+                zz[i + 0] = (uint)c;
+                c >>= 32;
+                c += x_i * y_1 + zz[i + 1];
+                zz[i + 1] = (uint)c;
+                c >>= 32;
+                c += x_i * y_2 + zz[i + 2];
+                zz[i + 2] = (uint)c;
+                c >>= 32;
+                c += x_i * y_3 + zz[i + 3];
+                zz[i + 3] = (uint)c;
+                c >>= 32;
+                c += x_i * y_4 + zz[i + 4];
+                zz[i + 4] = (uint)c;
+                c >>= 32;
+                c += x_i * y_5 + zz[i + 5];
+                zz[i + 5] = (uint)c;
+                c >>= 32;
+                c += x_i * y_6 + zz[i + 6];
+                zz[i + 6] = (uint)c;
+                c >>= 32;
+                c += zc + zz[i + 7];
+                zz[i + 7] = (uint)c;
+                zc = c >> 32;
+            }
+            return (uint)zc;
+        }
+
+        public static uint MulAddTo(uint[] x, int xOff, uint[] y, int yOff, uint[] zz, int zzOff)
         {
             ulong y_0 = y[yOff + 0];
             ulong y_1 = y[yOff + 1];