From 201d86c4ab73d81605402d2b0cae15106f9e372d Mon Sep 17 00:00:00 2001 From: Tim Whittington Date: Fri, 11 Oct 2013 20:27:51 +1300 Subject: Port SkeinDigest and SkeinMac from bc-java. Skein digest and Mac in 256/512/1024 bit state sizes (and arbitrary byte level output size), with unit tests. --- crypto/src/util/Arrays.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'crypto/src/util') 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) -- cgit 1.4.1