diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-26 15:03:37 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-26 15:03:37 +0700 |
commit | e88ccf8b5f72b744fa91e7f50aa120a17b341df3 (patch) | |
tree | aabb57cfcede362d7c22dfe73fc109f855bc4002 | |
parent | Add diagnostics (diff) | |
download | BouncyCastle.NET-ed25519-e88ccf8b5f72b744fa91e7f50aa120a17b341df3.tar.xz |
Add methods working with uint[]
-rw-r--r-- | crypto/src/util/Arrays.cs | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs index 8f8cebedc..3632587de 100644 --- a/crypto/src/util/Arrays.cs +++ b/crypto/src/util/Arrays.cs @@ -95,6 +95,18 @@ namespace Org.BouncyCastle.Utilities return HaveSameContents(a, b); } + [CLSCompliantAttribute(false)] + public static bool AreEqual(uint[] a, uint[] b) + { + if (a == b) + return true; + + if (a == null || b == null) + return false; + + return HaveSameContents(a, b); + } + private static bool HaveSameContents( bool[] a, bool[] b) @@ -159,6 +171,20 @@ namespace Org.BouncyCastle.Utilities return true; } + private static bool HaveSameContents(uint[] a, uint[] b) + { + int i = a.Length; + if (i != b.Length) + return false; + while (i != 0) + { + --i; + if (a[i] != b[i]) + return false; + } + return true; + } + public static string ToString( object[] a) { @@ -197,9 +223,7 @@ namespace Org.BouncyCastle.Utilities public static int GetHashCode(int[] data) { if (data == null) - { return 0; - } int i = data.Length; int hc = i + 1; @@ -213,6 +237,24 @@ namespace Org.BouncyCastle.Utilities return hc; } + [CLSCompliantAttribute(false)] + public static int GetHashCode(uint[] data) + { + if (data == null) + return 0; + + int i = data.Length; + int hc = i + 1; + + while (--i >= 0) + { + hc *= 257; + hc ^= (int)data[i]; + } + + return hc; + } + public static byte[] Clone( byte[] data) { |