diff options
author | Tim Whittington <bc@whittington.net.nz> | 2013-10-11 20:27:51 +1300 |
---|---|---|
committer | Tim Whittington <bc@whittington.net.nz> | 2013-10-20 21:29:17 +1300 |
commit | 201d86c4ab73d81605402d2b0cae15106f9e372d (patch) | |
tree | b6fb1854c0c46a06201df6117abf5fc16256e1f1 /crypto/src/util/Arrays.cs | |
parent | Port of Threefish implementation from bc-java. (diff) | |
download | BouncyCastle.NET-ed25519-201d86c4ab73d81605402d2b0cae15106f9e372d.tar.xz |
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.
Diffstat (limited to 'crypto/src/util/Arrays.cs')
-rw-r--r-- | crypto/src/util/Arrays.cs | 40 |
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) |