summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-26 15:03:37 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-26 15:03:37 +0700
commite88ccf8b5f72b744fa91e7f50aa120a17b341df3 (patch)
treeaabb57cfcede362d7c22dfe73fc109f855bc4002 /crypto/src
parentAdd diagnostics (diff)
downloadBouncyCastle.NET-ed25519-e88ccf8b5f72b744fa91e7f50aa120a17b341df3.tar.xz
Add methods working with uint[]
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/util/Arrays.cs46
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)
         {