@@ -1367,8 +1367,6 @@ public void checkCertificate(
1367
1367
Certificate cert = fact .generateCertificate (bIn );
1368
1368
1369
1369
PublicKey k = cert .getPublicKey ();
1370
- // System.out.println("****** " + id + " ******");
1371
- // System.out.println(cert);
1372
1370
}
1373
1371
catch (Exception e )
1374
1372
{
@@ -5426,29 +5424,49 @@ private void checkSerialisation()
5426
5424
5427
5425
// TESTS REGARDING COMPOSITES https://www.ietf.org/archive/id/draft-ounsworth-pq-composite-sigs-13.html
5428
5426
private static String [] compositeSignaturesOIDs = {
5429
- "2.16.840.1.114027.80.8.1.1" , //id-MLDSA44-RSA2048-PSS-SHA256
5430
- "2.16.840.1.114027.80.8.1.2" , //id-MLDSA44-RSA2048-PKCS15-SHA256
5431
- "2.16.840.1.114027.80.8.1.3" , //id-MLDSA44-Ed25519-SHA512
5432
- "2.16.840.1.114027.80.8.1.4" , //id-MLDSA44-ECDSA-P256-SHA256
5433
- "2.16.840.1.114027.80.8.1.5" , //id-MLDSA44-ECDSA-brainpoolP256r1-SHA256
5434
- "2.16.840.1.114027.80.8.1.6" , //id-MLDSA65-RSA3072-PSS-SHA512
5435
- "2.16.840.1.114027.80.8.1.7" , //id-MLDSA65-RSA3072-PKCS15-SHA512
5436
- "2.16.840.1.114027.80.8.1.8" , //id-MLDSA65-ECDSA-P256-SHA512
5437
- "2.16.840.1.114027.80.8.1.9" , //id-MLDSA65-ECDSA-brainpoolP256r1-SHA512
5438
- "2.16.840.1.114027.80.8.1.10" , //id-MLDSA65-Ed25519-SHA512
5439
- "2.16.840.1.114027.80.8.1.11" , //id-MLDSA87-ECDSA-P384-SHA512
5440
- "2.16.840.1.114027.80.8.1.12" , //id-MLDSA87-ECDSA-brainpoolP384r1-SHA512
5441
- "2.16.840.1.114027.80.8.1.13" , //id-MLDSA87-Ed448-SHA512
5442
- // Falcon composites below were excluded from the draft. See MiscObjectIdentifiers for details.
5443
- "2.16.840.1.114027.80.8.1.14" , //id-Falcon512-ECDSA-P256-SHA256
5444
- "2.16.840.1.114027.80.8.1.15" , //id-Falcon512-ECDSA-brainpoolP256r1-SHA256
5445
- "2.16.840.1.114027.80.8.1.16" , //id-Falcon512-Ed25519-SHA512
5427
+ "2.16.840.1.114027.80.8.1.1" , //id-MLDSA44-RSA2048-PSS-SHA256
5428
+ "2.16.840.1.114027.80.8.1.2" , //id-MLDSA44-RSA2048-PKCS15-SHA256
5429
+ "2.16.840.1.114027.80.8.1.3" , //id-MLDSA44-Ed25519-SHA512
5430
+ "2.16.840.1.114027.80.8.1.4" , //id-MLDSA44-ECDSA-P256-SHA256
5431
+ "2.16.840.1.114027.80.8.1.5" , //id-MLDSA44-ECDSA-brainpoolP256r1-SHA256
5432
+ "2.16.840.1.114027.80.8.1.6" , //id-MLDSA65-RSA3072-PSS-SHA512
5433
+ "2.16.840.1.114027.80.8.1.7" , //id-MLDSA65-RSA3072-PKCS15-SHA512
5434
+ "2.16.840.1.114027.80.8.1.8" , //id-MLDSA65-ECDSA-P256-SHA512
5435
+ "2.16.840.1.114027.80.8.1.9" , //id-MLDSA65-ECDSA-brainpoolP256r1-SHA512
5436
+ "2.16.840.1.114027.80.8.1.10" , //id-MLDSA65-Ed25519-SHA512
5437
+ "2.16.840.1.114027.80.8.1.11" , //id-MLDSA87-ECDSA-P384-SHA512
5438
+ "2.16.840.1.114027.80.8.1.12" , //id-MLDSA87-ECDSA-brainpoolP384r1-SHA512
5439
+ "2.16.840.1.114027.80.8.1.13" , //id-MLDSA87-Ed448-SHA512
5440
+ // Falcon composites below were excluded from the draft. See MiscObjectIdentifiers for details.
5441
+ "2.16.840.1.114027.80.8.1.14" , //id-Falcon512-ECDSA-P256-SHA256
5442
+ "2.16.840.1.114027.80.8.1.15" , //id-Falcon512-ECDSA-brainpoolP256r1-SHA256
5443
+ "2.16.840.1.114027.80.8.1.16" , //id-Falcon512-Ed25519-SHA512
5444
+ };
5445
+
5446
+ private static String [] compositeSignaturesIDs = {
5447
+ "MLDSA44-RSA2048-PSS-SHA256" ,
5448
+ "MLDSA44-RSA2048-PKCS15-SHA256" ,
5449
+ "MLDSA44-ED25519-SHA512" ,
5450
+ "MLDSA44-ECDSA-P256-SHA256" ,
5451
+ "MLDSA44-ECDSA-BRAINPOOLP256R1-SHA256" ,
5452
+ "MLDSA65-RSA3072-PSS-SHA512" ,
5453
+ "MLDSA65-RSA3072-PKCS15-SHA512" ,
5454
+ "MLDSA65-ECDSA-P256-SHA512" ,
5455
+ "MLDSA65-ECDSA-BRAINPOOLP256R1-SHA512" ,
5456
+ "MLDSA65-ED25519-SHA512" ,
5457
+ "MLDSA87-ECDSA-P384-SHA512" ,
5458
+ "MLDSA87-ECDSA-BRAINPOOLP384R1-SHA512" ,
5459
+ "MLDSA87-ED448-SHA512" ,
5460
+ "FALCON512-ECDSA-P256-SHA256" ,
5461
+ "FALCON512-ECDSA-BRAINPOOLP256R1-SHA256" ,
5462
+ "FALCON512-ED25519-SHA512"
5446
5463
};
5447
5464
5448
5465
private void checkCompositeSignatureCertificateCreation ()
5449
5466
{
5450
5467
try
5451
5468
{
5469
+ int index = 0 ;
5452
5470
for (String oid : compositeSignaturesOIDs )
5453
5471
{
5454
5472
KeyPairGenerator keyPairGenerator = KeyPairGenerator .getInstance (oid , "BC" );
@@ -5462,22 +5480,23 @@ private void checkCompositeSignatureCertificateCreation()
5462
5480
X500Name subject = new X500Name (subjectName );
5463
5481
5464
5482
JcaX509v3CertificateBuilder certificateBuilder = new JcaX509v3CertificateBuilder (issuer , serial , notBefore , notAfter , subject , keyPair .getPublic ());
5465
- X509CertificateHolder certHolder = certificateBuilder .build (new JcaContentSignerBuilder (oid ).build (keyPair .getPrivate ()));
5483
+ X509CertificateHolder certHolder = certificateBuilder .build (new JcaContentSignerBuilder (compositeSignaturesIDs [ index ] ).build (keyPair .getPrivate ()));
5466
5484
X509Certificate cert = new JcaX509CertificateConverter ().setProvider ("BC" ).getCertificate (certHolder );
5467
5485
5468
5486
isEquals (oid , cert .getSigAlgOID ());
5469
5487
CompositePublicKey compositePublicKey = (CompositePublicKey )cert .getPublicKey ();
5470
- isEquals (CompositeSignaturesConstants .ASN1IdentifierAlgorithmNameMap .get (new ASN1ObjectIdentifier (oid )), compositePublicKey .getAlgorithm ());
5471
5488
5489
+ isEquals (CompositeSignaturesConstants .ASN1IdentifierAlgorithmNameMap .get (new ASN1ObjectIdentifier (oid )).getId (), compositePublicKey .getAlgorithm ());
5490
+
5472
5491
isEquals (subjectName , cert .getSubjectX500Principal ().getName ());
5473
5492
5474
5493
cert .verify (cert .getPublicKey ());
5475
-
5494
+ index ++;
5476
5495
}
5477
5496
}
5478
5497
catch (NoSuchAlgorithmException | NoSuchProviderException | CertificateException | OperatorCreationException |
5479
5498
SignatureException | InvalidKeyException | TestFailedException e )
5480
- {
5499
+ { e . printStackTrace ();
5481
5500
fail ("checkCompositeSignatureCertificateCreation failed: " + e .getMessage ());
5482
5501
}
5483
5502
}
0 commit comments