Skip to content

Commit 00f728f

Browse files
committed
Fixed typo Ed -> ED
1 parent 27f6831 commit 00f728f

File tree

2 files changed

+42
-47
lines changed

2 files changed

+42
-47
lines changed

pkix/src/main/java/org/bouncycastle/operator/DefaultSignatureAlgorithmIdentifierFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private static RSASSAPSSparams createPSSParams(AlgorithmIdentifier hashAlgId, in
337337
addAlgorithm("MLDSA65-ECDSA-P256-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_P256_SHA512);
338338
addAlgorithm("MLDSA65-ECDSA-P384-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_P384_SHA512);
339339
addAlgorithm("MLDSA65-ECDSA-BRAINPOOLP256R1-SHA512", IANAObjectIdentifiers.id_MLDSA65_ECDSA_brainpoolP256r1_SHA512);
340-
addAlgorithm("MLDSA65-Ed25519-SHA512", IANAObjectIdentifiers.id_MLDSA65_Ed25519_SHA512);
340+
addAlgorithm("MLDSA65-ED25519-SHA512", IANAObjectIdentifiers.id_MLDSA65_Ed25519_SHA512);
341341
addAlgorithm("MLDSA87-ECDSA-P384-SHA512", IANAObjectIdentifiers.id_MLDSA87_ECDSA_P384_SHA512);
342342
addAlgorithm("MLDSA87-ECDSA-BRAINPOOLP384R1-SHA512", IANAObjectIdentifiers.id_MLDSA87_ECDSA_brainpoolP384r1_SHA512);
343343
addAlgorithm("MLDSA87-ED448-SHAKE256", IANAObjectIdentifiers.id_MLDSA87_Ed448_SHAKE256);

pkix/src/test/java/org/bouncycastle/cert/test/CertTest.java

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
import org.bouncycastle.crypto.params.DSAValidationParameters;
102102
import org.bouncycastle.crypto.params.RSAKeyParameters;
103103
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
104+
import org.bouncycastle.internal.asn1.iana.IANAObjectIdentifiers;
104105
import org.bouncycastle.jcajce.CompositePrivateKey;
105106
import org.bouncycastle.jcajce.CompositePublicKey;
106107
import org.bouncycastle.jcajce.spec.CompositeAlgorithmSpec;
@@ -2890,14 +2891,11 @@ public void checkCRLCompositeCreation()
28902891
PrivateKey ecPriv = ecKp.getPrivate();
28912892
PublicKey ecPub = ecKp.getPublic();
28922893

2893-
KeyPairGenerator lmsKpg = KeyPairGenerator.getInstance("LMS", "BCPQC");
2894-
2895-
lmsKpg.initialize(new LMSKeyGenParameterSpec(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w1));
2894+
KeyPairGenerator mlDsaKpg = KeyPairGenerator.getInstance("ML-DSA", "BC");
28962895

2897-
KeyPair lmsKp = lmsKpg.generateKeyPair();
2896+
mlDsaKpg.initialize(MLDSAParameterSpec.ml_dsa_65);
28982897

2899-
PrivateKey lmsPriv = lmsKp.getPrivate();
2900-
PublicKey lmsPub = lmsKp.getPublic();
2898+
KeyPair mlDsaKp = mlDsaKpg.generateKeyPair();
29012899

29022900
//
29032901
// distinguished name table.
@@ -2907,14 +2905,10 @@ public void checkCRLCompositeCreation()
29072905
//
29082906
// create the certificate - version 3
29092907
//
2910-
CompositeAlgorithmSpec compAlgSpec = new CompositeAlgorithmSpec.Builder()
2911-
.add("SHA256withECDSA")
2912-
.add("LMS")
2913-
.build();
2914-
CompositePublicKey compPub = new CompositePublicKey(ecPub, lmsPub);
2915-
CompositePrivateKey compPrivKey = new CompositePrivateKey(ecPriv, lmsPriv);
2908+
CompositePublicKey compPub = new CompositePublicKey(IANAObjectIdentifiers.id_MLDSA65_ECDSA_P256_SHA512, mlDsaKp.getPublic(), ecPub);
2909+
CompositePrivateKey compPrivKey = new CompositePrivateKey(IANAObjectIdentifiers.id_MLDSA65_ECDSA_P256_SHA512, mlDsaKp.getPrivate(), ecPriv);
29162910

2917-
ContentSigner sigGen = new JcaContentSignerBuilder("Composite", compAlgSpec).setProvider(BC).build(compPrivKey);
2911+
ContentSigner sigGen = new JcaContentSignerBuilder("MLDSA65-ECDSA-P256-SHA512").setProvider(BC).build(compPrivKey);
29182912

29192913
Date now = new Date();
29202914

@@ -2956,14 +2950,15 @@ public void checkCRLCompositeCreation()
29562950
try
29572951
{
29582952
crl.verify(new CompositePublicKey(new PublicKey[]{null, null}));
2953+
fail("no exception");
29592954
}
29602955
catch (InvalidKeyException e)
29612956
{
2962-
isTrue(e.getMessage().equals("no matching key found"));
2957+
isTrue(e.getMessage().equals("provided composite public key cannot be used with the composite signature algorithm"));
29632958
}
29642959

29652960
// single key test
2966-
crl.verify(ecPub, BC);
2961+
// crl.verify(ecPub, BC); no longer supported... possibly TODO
29672962

29682963
if (!crl.getIssuerX500Principal().equals(new X500Principal("CN=Test CA")))
29692964
{
@@ -3012,14 +3007,14 @@ public void checkCRLCompositeCreation()
30123007
fail("CRL entry reasonCode not found");
30133008
}
30143009

3015-
sigGen = new JcaContentSignerBuilder("SHA256withECDSA", compAlgSpec).setProvider(BC).build(compPrivKey);
3016-
3017-
crlHolder = crlGen.build(sigGen);
3018-
3019-
crl = new JcaX509CRLConverter().setProvider(BC).getCRL(crlHolder);
3020-
3021-
// comp test - single key
3022-
crl.verify(compPub);
3010+
// sigGen = new JcaContentSignerBuilder("SHA256withECDSA", compAlgSpec).setProvider(BC).build(compPrivKey);
3011+
//
3012+
// crlHolder = crlGen.build(sigGen);
3013+
//
3014+
// crl = new JcaX509CRLConverter().setProvider(BC).getCRL(crlHolder);
3015+
//
3016+
// // comp test - single key
3017+
// crl.verify(compPub);
30233018
}
30243019

30253020
public void checkCrlECDSAwithDilithiumCreation()
@@ -5469,26 +5464,26 @@ private void checkSerialisation()
54695464
}
54705465

54715466
// TESTS REGARDING COMPOSITES https://www.ietf.org/archive/id/draft-ounsworth-pq-composite-sigs-13.html
5472-
private static final String[] compositeSignaturesOIDs = {
5473-
"2.16.840.1.114027.80.9.1.0", //id-MLDSA44-RSA2048-PSS-SHA256
5474-
"2.16.840.1.114027.80.9.1.1", //id-MLDSA44-RSA2048-PKCS15-SHA256
5475-
"2.16.840.1.114027.80.9.1.2", //id-MLDSA44-Ed25519-SHA512
5476-
"2.16.840.1.114027.80.9.1.3", //id-MLDSA44-ECDSA-P256-SHA256
5477-
"2.16.840.1.114027.80.9.1.4", //id-MLDSA65-RSA3072-PSS-SHA512
5478-
"2.16.840.1.114027.80.9.1.5", //id-MLDSA65-RSA3072-PKCS15-SHA512
5479-
"2.16.840.1.114027.80.9.1.6", //id-MLDSA65-RSA4096-PSS-SHA512
5480-
"2.16.840.1.114027.80.9.1.7", //id-MLDSA65-RSA4096-PKCS15-SHA512
5481-
"2.16.840.1.114027.80.9.1.8", //id-MLDSA65-ECDSA-P256-SHA512
5482-
"2.16.840.1.114027.80.9.1.9", //id-MLDSA65-ECDSA-P384-SHA512
5483-
"2.16.840.1.114027.80.9.1.10", //id-MLDSA65-ECDSA-brainpoolP256r1-SHA512
5484-
"2.16.840.1.114027.80.9.1.11", //id-MLDSA65-Ed25519-SHA512
5485-
"2.16.840.1.114027.80.9.1.12", //id-MLDSA87-ECDSA-P384-SHA512
5486-
"2.16.840.1.114027.80.9.1.13", //id-MLDSA87-ECDSA-brainpoolP384r1-SHA512
5487-
"2.16.840.1.114027.80.9.1.14", //id-MLDSA87-Ed448-SHAKE256
5488-
"2.16.840.1.114027.80.9.1.15", //id-MLDSA87-RSA3072-PSS-SHA512
5489-
"2.16.840.1.114027.80.9.1.16", //id-MLDSA87-RSA4096-PSS-SHA512
5490-
"2.16.840.1.114027.80.9.1.17", //id-MLDSA87-ECDSA-P521-SHA512
5491-
};
5467+
private static String[] compositeSignaturesOIDs = {
5468+
"1.3.6.1.5.5.7.6.37", // id_MLDSA44_RSA2048_PSS_SHA256
5469+
"1.3.6.1.5.5.7.6.38", // id_MLDSA44_RSA2048_PKCS15_SHA256
5470+
"1.3.6.1.5.5.7.6.39", // id_MLDSA44_Ed25519_SHA512
5471+
"1.3.6.1.5.5.7.6.40", // id_MLDSA44_ECDSA_P256_SHA256
5472+
"1.3.6.1.5.5.7.6.41", // id_MLDSA65_RSA3072_PSS_SHA512
5473+
"1.3.6.1.5.5.7.6.42", // id_MLDSA65_RSA3072_PKCS15_SHA512
5474+
"1.3.6.1.5.5.7.6.43", // id_MLDSA65_RSA4096_PSS_SHA512
5475+
"1.3.6.1.5.5.7.6.44", // id_MLDSA65_RSA4096_PKCS15_SHA512
5476+
"1.3.6.1.5.5.7.6.45", // id_MLDSA65_ECDSA_P256_SHA512
5477+
"1.3.6.1.5.5.7.6.46", // id_MLDSA65_ECDSA_P384_SHA512
5478+
"1.3.6.1.5.5.7.6.47", // id_MLDSA65_ECDSA_brainpoolP256r1_SHA512
5479+
"1.3.6.1.5.5.7.6.48", // id_MLDSA65_Ed25519_SHA512
5480+
"1.3.6.1.5.5.7.6.49", // id_MLDSA87_ECDSA_P384_SHA512
5481+
"1.3.6.1.5.5.7.6.50", // id_MLDSA87_ECDSA_brainpoolP384r1_SHA512
5482+
"1.3.6.1.5.5.7.6.51", // id_MLDSA87_Ed448_SHAKE256
5483+
"1.3.6.1.5.5.7.6.52", // id_MLDSA87_RSA3072_PSS_SHA512
5484+
"1.3.6.1.5.5.7.6.53", // id_MLDSA87_RSA4096_PSS_SHA512
5485+
"1.3.6.1.5.5.7.6.54" // id_MLDSA87_ECDSA_P521_SHA512
5486+
};
54925487

54935488
private static final String[] compositeSignaturesIDs = {
54945489
"MLDSA44-RSA2048-PSS-SHA256",
@@ -5549,7 +5544,7 @@ private void checkParseCompositePublicKey()
55495544
// //compositePublicKeyExampleRFC.pem contains the sample public key from https://www.ietf.org/archive/id/draft-ounsworth-pq-composite-sigs-13.html
55505545
// PEMParser pemParser = new PEMParser(new InputStreamReader(TestResourceFinder.findTestResource("pqc/composite", "compositePublicKeyExampleRFC.pem")));
55515546
// SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)pemParser.readObject();
5552-
// isEquals(subjectPublicKeyInfo.getAlgorithm().getAlgorithm(), MiscObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256);
5547+
// isEquals(subjectPublicKeyInfo.getAlgorithm().getAlgorithm(), IANAObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256);
55535548
//
55545549
// CompositePublicKey compositePublicKey = new CompositePublicKey(subjectPublicKeyInfo);
55555550
//
@@ -5573,7 +5568,7 @@ private void checkParseCompositePublicKey()
55735568
// PEMParser pemParser = new PEMParser(new InputStreamReader(TestResourceFinder.findTestResource("pqc/composite", "compositePrivateKeyExample.pem")));
55745569
// PrivateKeyInfo privateKeyInfo = (PrivateKeyInfo)pemParser.readObject();
55755570
//
5576-
// isEquals(privateKeyInfo.getPrivateKeyAlgorithm().getAlgorithm(), MiscObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256);
5571+
// isEquals(privateKeyInfo.getPrivateKeyAlgorithm().getAlgorithm(), IANAObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256);
55775572
//
55785573
// CompositePrivateKey compositePrivateKey = new CompositePrivateKey(privateKeyInfo);
55795574
//
@@ -5596,7 +5591,7 @@ private void checkParseAndVerifyCompositeCertificate()
55965591
// JcaX509CertificateConverter x509Converter = new JcaX509CertificateConverter().setProvider("BC");
55975592
// X509Certificate certificate = x509Converter.getCertificate(certificateHolder);
55985593
//
5599-
// isEquals(certificate.getSigAlgOID(), MiscObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256.toString());
5594+
// isEquals(certificate.getSigAlgOID(), IANAObjectIdentifiers.id_MLDSA44_ECDSA_P256_SHA256.toString());
56005595
//
56015596
// CompositePublicKey compositePublicKey = (CompositePublicKey)certificate.getPublicKey();
56025597
//

0 commit comments

Comments
 (0)