From d557191b745060ec36ec544f4e7a99b4903785de Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 13 Oct 2022 16:14:09 +0700 Subject: Remove unnecessary copies --- crypto/src/pqc/crypto/crystals/dilithium/Symmetric.cs | 4 +--- crypto/src/pqc/crypto/crystals/kyber/Symmetric.cs | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'crypto') 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); } -- cgit 1.4.1