From eb261258c070decc949f07829ab7c942818167ed Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 16 Sep 2017 09:25:49 +0700 Subject: Use Arrays.CopyOfRange --- crypto/src/crypto/parameters/ParametersWithIV.cs | 41 +++++++++++------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'crypto') diff --git a/crypto/src/crypto/parameters/ParametersWithIV.cs b/crypto/src/crypto/parameters/ParametersWithIV.cs index 11a8b77a0..4b2eb930f 100644 --- a/crypto/src/crypto/parameters/ParametersWithIV.cs +++ b/crypto/src/crypto/parameters/ParametersWithIV.cs @@ -1,41 +1,38 @@ using System; +using Org.BouncyCastle.Utilities; + namespace Org.BouncyCastle.Crypto.Parameters { public class ParametersWithIV - : ICipherParameters + : ICipherParameters { - private readonly ICipherParameters parameters; - private readonly byte[] iv; + private readonly ICipherParameters parameters; + private readonly byte[] iv; - public ParametersWithIV( - ICipherParameters parameters, - byte[] iv) - : this(parameters, iv, 0, iv.Length) - { - } + public ParametersWithIV(ICipherParameters parameters, + byte[] iv) + : this(parameters, iv, 0, iv.Length) + { + } - public ParametersWithIV( - ICipherParameters parameters, - byte[] iv, - int ivOff, - int ivLen) + public ParametersWithIV(ICipherParameters parameters, + byte[] iv, int ivOff, int ivLen) { // NOTE: 'parameters' may be null to imply key re-use - if (iv == null) - throw new ArgumentNullException("iv"); + if (iv == null) + throw new ArgumentNullException("iv"); - this.parameters = parameters; - this.iv = new byte[ivLen]; - Array.Copy(iv, ivOff, this.iv, 0, ivLen); + this.parameters = parameters; + this.iv = Arrays.CopyOfRange(iv, ivOff, ivOff + ivLen); } - public byte[] GetIV() + public byte[] GetIV() { - return (byte[]) iv.Clone(); + return (byte[])iv.Clone(); } - public ICipherParameters Parameters + public ICipherParameters Parameters { get { return parameters; } } -- cgit 1.4.1