summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-21 17:01:00 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-21 17:01:00 +0700
commitcb74795bf4e107cf2689e85250a5b939671d30e1 (patch)
tree933b196b8efb40f2781b16807a0f71fe3d6c1e3d
parentMerge branch 'feature/threefish-skein-memoable-sm3' of git://github.com/timw/... (diff)
downloadBouncyCastle.NET-ed25519-cb74795bf4e107cf2689e85250a5b939671d30e1.tar.xz
Fix up merge
-rw-r--r--crypto/src/crypto/digests/SkeinEngine.cs3
-rw-r--r--crypto/src/util/Arrays.cs38
2 files changed, 29 insertions, 12 deletions
diff --git a/crypto/src/crypto/digests/SkeinEngine.cs b/crypto/src/crypto/digests/SkeinEngine.cs
index 49ec51304..43381e7cf 100644
--- a/crypto/src/crypto/digests/SkeinEngine.cs
+++ b/crypto/src/crypto/digests/SkeinEngine.cs
@@ -800,4 +800,5 @@ namespace Org.BouncyCastle.Crypto.Digests
 		}
 
 	}
-}
\ No newline at end of file
+}
+
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index d90bbdd90..59c91bdd1 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -219,21 +219,26 @@ namespace Org.BouncyCastle.Utilities
             return data == null ? null : (byte[]) data.Clone();
         }
 
-        public static int[] Clone(
-            int[] data)
+        public static byte[] Clone(
+            byte[] data, 
+            byte[] existing)
         {
-            return data == null ? null : (int[]) data.Clone();
+            if (data == null)
+            {
+                return null;
+            }
+            if ((existing == null) || (existing.Length != data.Length))
+            {
+                return Clone(data);
+            }
+            Array.Copy(data, 0, existing, 0, existing.Length);
+            return existing;
         }
 
-        public static void Fill(
-            byte[]	buf,
-            byte	b)
+        public static int[] Clone(
+            int[] data)
         {
-            int i = buf.Length;
-            while (i > 0)
-            {
-                buf[--i] = b;
-            }
+            return data == null ? null : (int[]) data.Clone();
         }
 
         [CLSCompliantAttribute(false)]
@@ -260,6 +265,17 @@ namespace Org.BouncyCastle.Utilities
             return existing;
         }
 
+        public static void Fill(
+            byte[]	buf,
+            byte	b)
+        {
+            int i = buf.Length;
+            while (i > 0)
+            {
+                buf[--i] = b;
+            }
+        }
+
         public static byte[] Copy(byte[] data, int off, int len)
         {
             byte[] result = new byte[len];