Skip to content

Commit f33ab6e

Browse files
author
royb
committed
enabled domain separation to mlkem keygen
disabled old KAT test, added acvp sample vector
1 parent 7f2e5ca commit f33ab6e

File tree

3 files changed

+352
-141
lines changed

3 files changed

+352
-141
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/crystals/kyber/KyberEngine.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ public byte[][] generateKemKeyPairInternal(byte[] d, byte[] z)
209209

210210
symmetric.hash_h(hashedPublicKey, indCpaKeyPair[0], 0);
211211

212-
213212
byte[] outputPublicKey = new byte[KyberIndCpaPublicKeyBytes];
214213
System.arraycopy(indCpaKeyPair[0], 0, outputPublicKey, 0, KyberIndCpaPublicKeyBytes);
215214
return new byte[][]{ Arrays.copyOfRange(outputPublicKey, 0, outputPublicKey.length - 32), Arrays.copyOfRange(outputPublicKey, outputPublicKey.length - 32, outputPublicKey.length), s, hashedPublicKey, z };

core/src/main/java/org/bouncycastle/pqc/crypto/crystals/kyber/KyberIndCpa.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ byte[][] generateKeyPair(byte[] d)
5555
// (p, sigma) <- G(d || k)
5656

5757
byte[] buf = new byte[64];
58-
//TODO: specs specifies K to be concatenated to with d but acvp tests says otherwise
59-
symmetric.hash_g(buf, d);
60-
// byte[] k = new byte[1];
61-
// k[0] = (byte)kyberK;
62-
// symmetric.hash_g(buf, Arrays.concatenate(d, k));
58+
byte[] k = new byte[1];
59+
k[0] = (byte)kyberK;
60+
symmetric.hash_g(buf, Arrays.concatenate(d, k));
6361

6462
byte[] publicSeed = new byte[32]; // p in docs
6563
byte[] noiseSeed = new byte[32]; // sigma in docs

0 commit comments

Comments
 (0)