diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-21 17:01:00 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-21 17:01:00 +0700 |
commit | cb74795bf4e107cf2689e85250a5b939671d30e1 (patch) | |
tree | 933b196b8efb40f2781b16807a0f71fe3d6c1e3d /crypto/src/util/Arrays.cs | |
parent | Merge branch 'feature/threefish-skein-memoable-sm3' of git://github.com/timw/... (diff) | |
download | BouncyCastle.NET-ed25519-cb74795bf4e107cf2689e85250a5b939671d30e1.tar.xz |
Fix up merge
Diffstat (limited to 'crypto/src/util/Arrays.cs')
-rw-r--r-- | crypto/src/util/Arrays.cs | 38 |
1 files changed, 27 insertions, 11 deletions
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]; |