diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-03-03 14:51:57 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-03-03 14:51:57 +0700 |
commit | d64a63800bdbb629722b58c98a9c1868728621ab (patch) | |
tree | 9563f7c8fb9ccdf01841c29fe4a523123644fd68 /crypto/src/math/ec/custom/sec/Nat256.cs | |
parent | Allow for (very rare) cases where the Sqrt() algorithm needs to retry (diff) | |
download | BouncyCastle.NET-ed25519-d64a63800bdbb629722b58c98a9c1868728621ab.tar.xz |
Add/rename MulAddTo variations
Diffstat (limited to 'crypto/src/math/ec/custom/sec/Nat256.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/Nat256.cs | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/crypto/src/math/ec/custom/sec/Nat256.cs b/crypto/src/math/ec/custom/sec/Nat256.cs index 98b4b83cd..beb9ab5ed 100644 --- a/crypto/src/math/ec/custom/sec/Nat256.cs +++ b/crypto/src/math/ec/custom/sec/Nat256.cs @@ -591,7 +591,53 @@ 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 y_7 = y[7]; + + ulong zc = 0; + for (int i = 0; i < 8; ++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 += x_i * y_7 + zz[i + 7]; + zz[i + 7] = (uint)c; + c >>= 32; + c += zc + zz[i + 8]; + zz[i + 8] = (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]; |