summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2017-09-16 09:25:49 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2017-09-16 09:25:49 +0700
commiteb261258c070decc949f07829ab7c942818167ed (patch)
tree26cd90694e7e3bcd68765131821c7c99daa4f4a8
parentAdd expiry test case to PgpKeyRingTest (diff)
downloadBouncyCastle.NET-ed25519-eb261258c070decc949f07829ab7c942818167ed.tar.xz
Use Arrays.CopyOfRange
-rw-r--r--crypto/src/crypto/parameters/ParametersWithIV.cs41
1 files changed, 19 insertions, 22 deletions
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; }
         }