From 547d9d33c7ec30b404032381ac4aa2ecf1755760 Mon Sep 17 00:00:00 2001 From: David Hook Date: Fri, 23 Aug 2024 15:37:56 +1000 Subject: [PATCH] moved MLKEM into regular provider package to correspond to class for replacement, filled in missing entries --- .../provider/asymmetric}/MLKEM.java | 15 +++++++++------ .../asymmetric}/mlkem/MLKEMDecapsulatorSpi.java | 2 +- .../asymmetric}/mlkem/MLKEMEncapsulatorSpi.java | 2 +- .../provider/asymmetric}/mlkem/MLKEMSpi.java | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) rename prov/src/main/jdk21/org/bouncycastle/{pqc/jcajce/provider => jcajce/provider/asymmetric}/MLKEM.java (80%) rename prov/src/main/jdk21/org/bouncycastle/{pqc/jcajce/provider => jcajce/provider/asymmetric}/mlkem/MLKEMDecapsulatorSpi.java (98%) rename prov/src/main/jdk21/org/bouncycastle/{pqc/jcajce/provider => jcajce/provider/asymmetric}/mlkem/MLKEMEncapsulatorSpi.java (98%) rename prov/src/main/jdk21/org/bouncycastle/{pqc/jcajce/provider => jcajce/provider/asymmetric}/mlkem/MLKEMSpi.java (97%) diff --git a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/MLKEM.java b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java similarity index 80% rename from prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/MLKEM.java rename to prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java index 68fc0a41ab..f8dc9c2d9f 100644 --- a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/MLKEM.java +++ b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java @@ -1,4 +1,4 @@ -package org.bouncycastle.pqc.jcajce.provider; +package org.bouncycastle.jcajce.provider.asymmetric; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; @@ -9,7 +9,7 @@ public class MLKEM { - private static final String PREFIX = "org.bouncycastle.pqc.jcajce.provider" + ".mlkem."; + private static final String PREFIX = "org.bouncycastle.jcajce.provider.asymmetric" + ".mlkem."; public static class Mappings extends AsymmetricAlgorithmProvider @@ -26,7 +26,6 @@ public void configure(ConfigurableProvider provider) addKeyFactoryAlgorithm(provider, "ML-KEM-768", PREFIX + "MLKEMKeyFactorySpi$MLKEM768", NISTObjectIdentifiers.id_alg_ml_kem_768, new MLKEMKeyFactorySpi.MLKEM768()); addKeyFactoryAlgorithm(provider, "ML-KEM-1024", PREFIX + "MLKEMKeyFactorySpi$MLKEM1024", NISTObjectIdentifiers.id_alg_ml_kem_1024, new MLKEMKeyFactorySpi.MLKEM1024()); - provider.addAlgorithm("KeyPairGenerator.ML-KEM", PREFIX + "MLKEMKeyPairGeneratorSpi"); addKeyPairGeneratorAlgorithm(provider, "ML-KEM-512", PREFIX + "MLKEMKeyPairGeneratorSpi$MLKEM512", NISTObjectIdentifiers.id_alg_ml_kem_512); @@ -48,10 +47,14 @@ public void configure(ConfigurableProvider provider) addCipherAlgorithm(provider, "ML-KEM-768", PREFIX + "MLKEMCipherSpi$MLKEM768", NISTObjectIdentifiers.id_alg_ml_kem_768); addCipherAlgorithm(provider, "ML-KEM-1024", PREFIX + "MLKEMCipherSpi$MLKEM1024", NISTObjectIdentifiers.id_alg_ml_kem_1024); - registerOid(provider, (ASN1ObjectIdentifier) null, "ML-KEM", keyFact); - + provider.addKeyInfoConverter(NISTObjectIdentifiers.id_alg_ml_kem_512, keyFact); + provider.addKeyInfoConverter(NISTObjectIdentifiers.id_alg_ml_kem_768, keyFact); + provider.addKeyInfoConverter(NISTObjectIdentifiers.id_alg_ml_kem_1024, keyFact); + provider.addAlgorithm("Kem.ML-KEM", PREFIX + "MLKEMSpi"); - provider.addAlgorithm("Alg.Alias.Kem", "ML-KEM"); + provider.addAlgorithm("Alg.Alias.Kem." + NISTObjectIdentifiers.id_alg_ml_kem_512, "ML-KEM"); + provider.addAlgorithm("Alg.Alias.Kem." + NISTObjectIdentifiers.id_alg_ml_kem_768, "ML-KEM"); + provider.addAlgorithm("Alg.Alias.Kem." + NISTObjectIdentifiers.id_alg_ml_kem_1024, "ML-KEM"); } } } diff --git a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMDecapsulatorSpi.java b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMDecapsulatorSpi.java similarity index 98% rename from prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMDecapsulatorSpi.java rename to prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMDecapsulatorSpi.java index 2b86a30748..5a3c0c1487 100644 --- a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMDecapsulatorSpi.java +++ b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMDecapsulatorSpi.java @@ -1,4 +1,4 @@ -package org.bouncycastle.pqc.jcajce.provider.mlkem; +package org.bouncycastle.jcajce.provider.asymmetric.mlkem; import org.bouncycastle.jcajce.provider.asymmetric.mlkem.BCMLKEMPrivateKey; import org.bouncycastle.jcajce.spec.KTSParameterSpec; diff --git a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMEncapsulatorSpi.java b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMEncapsulatorSpi.java similarity index 98% rename from prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMEncapsulatorSpi.java rename to prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMEncapsulatorSpi.java index 2c1ec41cf7..8972072c23 100644 --- a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMEncapsulatorSpi.java +++ b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMEncapsulatorSpi.java @@ -1,4 +1,4 @@ -package org.bouncycastle.pqc.jcajce.provider.mlkem; +package org.bouncycastle.jcajce.provider.asymmetric.mlkem; import org.bouncycastle.crypto.SecretWithEncapsulation; import org.bouncycastle.jcajce.provider.asymmetric.mlkem.BCMLKEMPublicKey; diff --git a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMSpi.java b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java similarity index 97% rename from prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMSpi.java rename to prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java index 58d1097cfe..db4fed4ff4 100644 --- a/prov/src/main/jdk21/org/bouncycastle/pqc/jcajce/provider/mlkem/MLKEMSpi.java +++ b/prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java @@ -1,4 +1,4 @@ -package org.bouncycastle.pqc.jcajce.provider.mlkem; +package org.bouncycastle.jcajce.provider.asymmetric.mlkem; import org.bouncycastle.jcajce.provider.asymmetric.mlkem.BCMLKEMPrivateKey; import org.bouncycastle.jcajce.provider.asymmetric.mlkem.BCMLKEMPublicKey;