Skip to content

Commit 2561759

Browse files
committed
corrected CompositeUtil table used by key builders, added test for same.
1 parent 7ba916e commit 2561759

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

prov/src/main/java/org/bouncycastle/jcajce/CompositeUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ class CompositeUtil
1515
{
1616
algorithmOids.put("MLDSA44-RSA2048-PSS-SHA256", IANAObjectIdentifiers.id_MLDSA44_RSA2048_PSS_SHA256);
1717
algorithmOids.put("MLDSA44-RSA2048-PKCS15-SHA256", IANAObjectIdentifiers.id_MLDSA44_RSA2048_PKCS15_SHA256);
18-
algorithmOids.put("MLDSA44-Ed25519-SHA512", IANAObjectIdentifiers.id_MLDSA44_Ed25519_SHA512);
18+
algorithmOids.put("MLDSA44-ED25519-SHA512", IANAObjectIdentifiers.id_MLDSA44_Ed25519_SHA512);
1919
algorithmOids.put("MLDSA44-ECDSA-P256-SHA256", IANAObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256);
2020
algorithmOids.put("MLDSA65-RSA3072-PSS-SHA512", IANAObjectIdentifiers.id_MLDSA65_RSA3072_PSS_SHA512);
2121
algorithmOids.put("MLDSA65-RSA3072-PKCS15-SHA512", IANAObjectIdentifiers.id_MLDSA65_RSA3072_PKCS15_SHA512);
2222
algorithmOids.put("MLDSA65-RSA4096-PSS-SHA512", IANAObjectIdentifiers.id_MLDSA65_RSA4096_PSS_SHA512);
2323
algorithmOids.put("MLDSA65-RSA4096-PKCS15-SHA512", IANAObjectIdentifiers.id_MLDSA65_RSA4096_PKCS15_SHA512);
2424
algorithmOids.put("MLDSA65-ECDSA-P256-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_P256_SHA512);
2525
algorithmOids.put("MLDSA65-ECDSA-P384-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_P384_SHA512);
26-
algorithmOids.put("MLDSA65-ECDSA-brainpoolP256r1-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_brainpoolP256r1_SHA512);
27-
algorithmOids.put("MLDSA65-Ed25519-SHA512", IANAObjectIdentifiers.id_MLDSA65_Ed25519_SHA512);
26+
algorithmOids.put("MLDSA65-ECDSA-BRAINPOOLP256R1-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_brainpoolP256r1_SHA512);
27+
algorithmOids.put("MLDSA65-ED25519-SHA512", IANAObjectIdentifiers.id_MLDSA65_Ed25519_SHA512);
2828
algorithmOids.put("MLDSA87-ECDSA-P384-SHA512", IANAObjectIdentifiers.id_MLDSA87_ECDSA_P384_SHA512);
29-
algorithmOids.put("MLDSA87-ECDSA-brainpoolP384r1-SHA512", IANAObjectIdentifiers.id_MLDSA87_ECDSA_brainpoolP384r1_SHA512);
30-
algorithmOids.put("MLDSA87-Ed448-SHAKE256", IANAObjectIdentifiers.id_MLDSA87_Ed448_SHAKE256);
29+
algorithmOids.put("MLDSA87-ECDSA-BRAINPOOLP384R1-SHA512", IANAObjectIdentifiers.id_MLDSA87_ECDSA_brainpoolP384r1_SHA512);
30+
algorithmOids.put("MLDSA87-ED448-SHAKE256", IANAObjectIdentifiers.id_MLDSA87_Ed448_SHAKE256);
3131
algorithmOids.put("MLDSA87-RSA4096-PSS-SHA512", IANAObjectIdentifiers.id_MLDSA87_RSA4096_PSS_SHA512);
3232
algorithmOids.put("MLDSA87-ECDSA-P521-SHA512", IANAObjectIdentifiers.id_MLDSA87_ECDSA_P521_SHA512);
3333
algorithmOids.put("MLDSA87-RSA3072-PSS-SHA512", IANAObjectIdentifiers.id_MLDSA87_RSA3072_PSS_SHA512);

prov/src/test/java/org/bouncycastle/jcajce/provider/test/CompositeSignaturesTest.java

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@
5555
public class CompositeSignaturesTest
5656
extends TestCase
5757
{
58-
public static void main(String[] args)
59-
throws Exception
60-
{
61-
CompositeSignaturesTest test = new CompositeSignaturesTest();
62-
test.setUp();
63-
List<Map<String, Object>> testVectors = test.readTestVectorsFromJson("pqc/crypto/composite", "testvectors.json");
64-
test.compositeSignaturesTest(testVectors);
65-
test.testSigningAndVerificationInternal();
66-
}
67-
6858
private static String[] compositeSignaturesOIDs = {
6959
"1.3.6.1.5.5.7.6.37", // id_MLDSA44_RSA2048_PSS_SHA256
7060
"1.3.6.1.5.5.7.6.38", // id_MLDSA44_RSA2048_PKCS15_SHA256
@@ -245,6 +235,43 @@ private void check_ECDSA_Composite(String firstAlg, CompositePublicKey compPub,
245235
TestCase.assertEquals("EC", compPriv.getPrivateKeys().get(1).getAlgorithm());
246236
}
247237

238+
public void testKeyBuilders()
239+
throws Exception
240+
{
241+
String[] algorithms = new String[]{
242+
"MLDSA44-RSA2048-PSS-SHA256",
243+
"MLDSA44-RSA2048-PKCS15-SHA256",
244+
"MLDSA44-Ed25519-SHA512",
245+
"MLDSA44-ECDSA-P256-SHA256",
246+
"MLDSA65-RSA3072-PSS-SHA512",
247+
"MLDSA65-RSA3072-PKCS15-SHA512",
248+
"MLDSA65-RSA4096-PSS-SHA512",
249+
"MLDSA65-RSA4096-PKCS15-SHA512",
250+
"MLDSA65-ECDSA-P256-SHA512",
251+
"MLDSA65-ECDSA-P384-SHA512",
252+
"MLDSA65-ECDSA-brainpoolP256r1-SHA512",
253+
"MLDSA65-Ed25519-SHA512",
254+
"MLDSA87-ECDSA-P384-SHA512",
255+
"MLDSA87-ECDSA-brainpoolP384R1-SHA512",
256+
"MLDSA87-Ed448-SHAKE256",
257+
"MLDSA87-RSA4096-PSS-SHA512",
258+
"MLDSA87-ECDSA-P521-SHA512",
259+
"MLDSA87-RSA3072-PSS-SHA512"
260+
};
261+
262+
CompositePublicKey.Builder pubBuilder = null;
263+
CompositePrivateKey.Builder privBuilder = null;
264+
265+
for (int i = 0; i != algorithms.length; i++)
266+
{
267+
pubBuilder = CompositePublicKey.builder(algorithms[i]);
268+
privBuilder = CompositePrivateKey.builder(algorithms[i]);
269+
}
270+
271+
assertNotNull(pubBuilder);
272+
assertNotNull(privBuilder);
273+
}
274+
248275
public void testSelfComposition()
249276
throws Exception
250277
{

0 commit comments

Comments
 (0)