Skip to content

Commit b949a8f

Browse files
committed
Refactoring in legacy McEliece
1 parent 54661c8 commit b949a8f

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

core/src/main/java/org/bouncycastle/pqc/legacy/crypto/mceliece/McElieceFujisakiCipher.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public class McElieceFujisakiCipher
3030
*/
3131
public static final String OID = "1.3.6.1.4.1.8301.3.1.3.4.2.1";
3232

33-
private static final String DEFAULT_PRNG_NAME = "SHA1PRNG";
34-
3533
private Digest messDigest;
3634

3735
private SecureRandom sr;

core/src/main/java/org/bouncycastle/pqc/legacy/crypto/mceliece/McElieceKobaraImaiCipher.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.bouncycastle.pqc.legacy.math.linearalgebra.ByteUtils;
1414
import org.bouncycastle.pqc.legacy.math.linearalgebra.GF2Vector;
1515
import org.bouncycastle.pqc.legacy.math.linearalgebra.IntegerFunctions;
16+
import org.bouncycastle.util.Arrays;
17+
import org.bouncycastle.util.Strings;
1618

1719
/**
1820
* This class implements the Kobara/Imai conversion of the McEliecePKCS. This is
@@ -23,20 +25,20 @@
2325
public class McElieceKobaraImaiCipher
2426
implements MessageEncryptor
2527
{
28+
public static byte[] getPublicConstant()
29+
{
30+
return Arrays.clone(PUBLIC_CONSTANT);
31+
}
2632

2733
/**
2834
* The OID of the algorithm.
2935
*/
3036
public static final String OID = "1.3.6.1.4.1.8301.3.1.3.4.2.3";
3137

32-
private static final String DEFAULT_PRNG_NAME = "SHA1PRNG";
33-
3438
/**
3539
* A predetermined public constant.
3640
*/
37-
public static final byte[] PUBLIC_CONSTANT = "a predetermined public constant"
38-
.getBytes();
39-
41+
private static final byte[] PUBLIC_CONSTANT = Strings.toByteArray("a predetermined public constant");
4042

4143
private Digest messDigest;
4244

core/src/test/java/org/bouncycastle/pqc/legacy/crypto/test/McElieceKobaraImaiCipherTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,7 @@ public void performTest()
129129

130130
// XXX write in McElieceFujisakiDigestCipher?
131131

132-
boolean verified = true;
133-
for (int i = 0; i < hash.length; i++)
134-
{
135-
verified = verified && hash[i] == constructedmessage[i];
136-
}
137-
138-
if (!verified)
132+
if (!Arrays.areEqual(hash, constructedmessage))
139133
{
140134
fail("en/decryption fails");
141135
}

0 commit comments

Comments
 (0)