summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-13 16:14:09 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-13 16:14:09 +0700
commitd557191b745060ec36ec544f4e7a99b4903785de (patch)
tree61dd6c2f847dfab5cc95a9cd18175ec686601e25
parentRefactoring in Frodo (performance) (diff)
downloadBouncyCastle.NET-ed25519-d557191b745060ec36ec544f4e7a99b4903785de.tar.xz
Remove unnecessary copies
-rw-r--r--crypto/src/pqc/crypto/crystals/dilithium/Symmetric.cs4
-rw-r--r--crypto/src/pqc/crypto/crystals/kyber/Symmetric.cs5
2 files changed, 3 insertions, 6 deletions
diff --git a/crypto/src/pqc/crypto/crystals/dilithium/Symmetric.cs b/crypto/src/pqc/crypto/crystals/dilithium/Symmetric.cs
index b3836ef87..6cea667c6 100644
--- a/crypto/src/pqc/crypto/crystals/dilithium/Symmetric.cs
+++ b/crypto/src/pqc/crypto/crystals/dilithium/Symmetric.cs
@@ -1,9 +1,7 @@
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Crypto.Engines;
 using Org.BouncyCastle.Crypto.Modes;
 using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium
 {
@@ -53,7 +51,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium
                 expnonce[0] = (byte)nonce;
                 expnonce[1] = (byte)(nonce >> 8);
                 
-                ParametersWithIV kp = new ParametersWithIV(new KeyParameter(Arrays.CopyOfRange(key, 0, 32)), expnonce);
+                ParametersWithIV kp = new ParametersWithIV(new KeyParameter(key, 0, 32), expnonce);
                 cipher.Init(true, kp);
             }
 
diff --git a/crypto/src/pqc/crypto/crystals/kyber/Symmetric.cs b/crypto/src/pqc/crypto/crystals/kyber/Symmetric.cs
index bea8cae54..9aad815da 100644
--- a/crypto/src/pqc/crypto/crystals/kyber/Symmetric.cs
+++ b/crypto/src/pqc/crypto/crystals/kyber/Symmetric.cs
@@ -4,7 +4,6 @@ using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Crypto.Modes;
 using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Kyber
 {
@@ -135,7 +134,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Kyber
                 expnonce[0] = x;
                 expnonce[1] = y;
 
-                ParametersWithIV kp = new ParametersWithIV(new KeyParameter(Arrays.CopyOfRange(key, 0, 32)), expnonce);
+                ParametersWithIV kp = new ParametersWithIV(new KeyParameter(key, 0, 32), expnonce);
                 cipher.Init(true, kp);
             }
 
@@ -149,7 +148,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Kyber
                 byte[] expnonce = new byte[12];
                 expnonce[0] = nonce;
 
-                ParametersWithIV kp = new ParametersWithIV(new KeyParameter(Arrays.CopyOfRange(key, 0, 32)), expnonce);
+                ParametersWithIV kp = new ParametersWithIV(new KeyParameter(key, 0, 32), expnonce);
                 cipher.Init(true, kp);
                 Aes128(output, 0, output.Length);
             }