summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/Arrays.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index 3c083034e..7d211e5dc 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -206,12 +206,52 @@ namespace Org.BouncyCastle.Utilities
 			return data == null ? null : (byte[]) data.Clone();
 		}
 
+		public static byte[] Clone(
+			byte[] data, 
+			byte[] existing)
+		{
+			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 int[] Clone(
 			int[] data)
 		{
 			return data == null ? null : (int[]) data.Clone();
 		}
 
+		[CLSCompliantAttribute(false)]
+		public static ulong[] Clone(
+			ulong[] data)
+		{
+			return data == null ? null : (ulong[]) data.Clone();
+		}
+
+		[CLSCompliantAttribute(false)]
+		public static ulong[] Clone(
+			ulong[] data, 
+			ulong[] existing)
+		{
+			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)