Skip to content

Commit 16ba11a

Browse files
author
gefeili
committed
Fix the bug in ReedSolomon
1 parent 45c8e3f commit 16ba11a

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/hqc/ReedSolomon.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ private static void computeZx(int[] output, int[] sigma, int deg, int[] syndrome
191191
for (int i = 2; i <= delta; i++)
192192
{
193193
int mask = i - deg < 1 ? 0xffff : 0;
194-
output[i] = mask & sigma[i - 1];
195-
194+
output[i] ^= (mask) & syndromes[i - 1];
196195
for (int j = 1; j < i; j++)
197196
{
198197
output[i] ^= (mask) & GFCalculator.mult(sigma[j], syndromes[i - j - 1]);

prov/src/test/java/org/bouncycastle/pqc/jcajce/provider/test/HQCTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,10 @@ public void testGenerateAES256()
164164
assertTrue(Arrays.areEqual(secEnc1.getEncoded(), secEnc2.getEncoded()));
165165
}
166166

167-
public static void main(String[] args)
167+
public void testReedSolomon()
168168
throws Exception
169169
{
170-
HQCTest test = new HQCTest();
171-
172-
test.setUp();
173-
174-
byte[] seed = Hex.decode("416a32ada1c7a569c34d5334273a781c340aac25eb7614271aa6930d0358fb30fd87e111336a29e165dc60d9643a3e9b");
170+
byte[] seed = Hex.decode("416a32ada1c7a569c34d5334273a781c340aac25eb7614271aa6930d0358fb30fd87e111336a29e165dc60d9643a3e9b");//b
175171
byte[] kemSeed = Hex.decode("13f36c0636ff93af6d702f7774097c185bf67cddc9b09f9b584d736c4faf40e073b0499efa0c926e9a44fec1e45ee4cf");
176172
//HQCKeyPairGenerator kpg = new HQCKeyPairGenerator();
177173
//kpg.init(new HQCKeyGenerationParameters();
@@ -206,11 +202,6 @@ public static void main(String[] args)
206202
Key k = w2.unwrap(data, "AES", Cipher.SECRET_KEY);
207203

208204
assertTrue(Arrays.areEqual(keyBytes, k.getEncoded()));
209-
// for (int i = 0; i < 10000; ++i)
210-
// {
211-
// test.testBasicKEMARIA();
212-
// }
213-
System.out.println("OK");
214205
}
215206

216207
}

0 commit comments

Comments
 (0)