diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-26 23:14:22 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-26 23:14:22 +0700 |
commit | 7a1a1a5a24aed17bff66159e6bbc709faef2281a (patch) | |
tree | a509f574af447ae8031b2b1206ba95748da2570d /crypto/src/math/ec/Nat.cs | |
parent | Optimization for custom curve reduction when only a few bits need reducing; u... (diff) | |
download | BouncyCastle.NET-ed25519-7a1a1a5a24aed17bff66159e6bbc709faef2281a.tar.xz |
Add extra arg to AddWord() and add variant of Copy()
Diffstat (limited to 'crypto/src/math/ec/Nat.cs')
-rw-r--r-- | crypto/src/math/ec/Nat.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/src/math/ec/Nat.cs b/crypto/src/math/ec/Nat.cs index a5a496fad..9d2290ba7 100644 --- a/crypto/src/math/ec/Nat.cs +++ b/crypto/src/math/ec/Nat.cs @@ -69,10 +69,11 @@ namespace Org.BouncyCastle.Math.EC return (uint)c; } - public static uint AddWord(int len, uint x, uint[] z) + public static uint AddWord(int len, uint x, uint[] z, int zOff) { - ulong c = (ulong)x + z[0]; - z[0] = (uint)c; + Debug.Assert(zOff < len); + ulong c = (ulong)x + z[zOff + 0]; + z[zOff + 0] = (uint)c; c >>= 32; return c == 0 ? 0 : Inc(len, z, 1); } @@ -80,13 +81,18 @@ namespace Org.BouncyCastle.Math.EC public static uint AddWordExt(int len, uint x, uint[] zz, int zzOff) { int extLen = len << 1; - Debug.Assert(zzOff <= (extLen - 1)); + Debug.Assert(zzOff < extLen); ulong c = (ulong)x + zz[zzOff]; zz[zzOff] = (uint)c; c >>= 32; return c == 0 ? 0 : Inc(extLen, zz, zzOff + 1); } + public static void Copy(int len, uint[] x, uint[] z) + { + Array.Copy(x, 0, z, 0, len); + } + public static uint[] Copy(int len, uint[] x) { uint[] z = new uint[len]; |