Skip to content

Commit 17576ed

Browse files
committed
removed unneeded byte[] copyOfRange
1 parent 3685f9d commit 17576ed

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/mlkem/Poly.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,14 @@ public byte[] toBytes()
237237
return r;
238238
}
239239

240-
public void fromBytes(byte[] inpBytes)
240+
public void fromBytes(byte[] inpBytes, int inOff)
241241
{
242242
for (int i = 0; i < MLKEMEngine.KyberN / 2; ++i)
243243
{
244-
int a0 = inpBytes[3 * i + 0] & 0xFF;
245-
int a1 = inpBytes[3 * i + 1] & 0xFF;
246-
int a2 = inpBytes[3 * i + 2] & 0xFF;
244+
int index = inOff + (3 * i);
245+
int a0 = inpBytes[index + 0] & 0xFF;
246+
int a1 = inpBytes[index + 1] & 0xFF;
247+
int a2 = inpBytes[index + 2] & 0xFF;
247248
coeffs[2 * i + 0] = (short)(((a0 >> 0) | (a1 << 8)) & 0xFFF);
248249
coeffs[2 * i + 1] = (short)(((a1 >> 4) | (a2 << 4)) & 0xFFF);
249250
}

core/src/main/java/org/bouncycastle/pqc/crypto/mlkem/PolyVec.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.bouncycastle.pqc.crypto.mlkem;
22

3-
import org.bouncycastle.util.Arrays;
4-
53
class PolyVec
64
{
75
Poly[] vec;
@@ -242,7 +240,7 @@ public void fromBytes(byte[] inputBytes)
242240
{
243241
for (int i = 0; i < kyberK; i++)
244242
{
245-
this.getVectorIndex(i).fromBytes(Arrays.copyOfRange(inputBytes, i * MLKEMEngine.KyberPolyBytes, (i + 1) * MLKEMEngine.KyberPolyBytes));
243+
this.getVectorIndex(i).fromBytes(inputBytes, i * MLKEMEngine.KyberPolyBytes);
246244
}
247245
}
248246

0 commit comments

Comments
 (0)