This is an automated email from the ASF dual-hosted git repository. JiriOndrusek pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit d069ff17f02b636148dfcd87d0ac06f2fbbb185b Author: Jiri Ondrusek <[email protected]> AuthorDate: Tue Jul 14 14:04:01 2026 +0200 Adapt PQC integration tests for Bouncy Castle 1.85 algorithm renames Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../quarkus/component/pqc/it/PqcProducers.java | 28 +++++++++++++--------- .../quarkus/component/pqc/it/PqcResource.java | 26 ++++++++++++++++---- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcProducers.java b/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcProducers.java index 076b329a68..3b3a83d0f0 100644 --- a/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcProducers.java +++ b/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcProducers.java @@ -22,9 +22,14 @@ import java.security.spec.AlgorithmParameterSpec; import jakarta.enterprise.inject.Produces; import jakarta.inject.Named; import jakarta.inject.Singleton; +import org.bouncycastle.jcajce.spec.MLDSAParameterSpec; +import org.bouncycastle.jcajce.spec.MLKEMParameterSpec; +import org.bouncycastle.jcajce.spec.SLHDSAParameterSpec; import org.bouncycastle.pqc.crypto.lms.LMOtsParameters; import org.bouncycastle.pqc.crypto.lms.LMSigParameters; -import org.bouncycastle.pqc.jcajce.spec.*; +import org.bouncycastle.pqc.jcajce.spec.FalconParameterSpec; +import org.bouncycastle.pqc.jcajce.spec.LMSParameterSpec; +import org.bouncycastle.pqc.jcajce.spec.XMSSParameterSpec; @Singleton public class PqcProducers { @@ -36,53 +41,54 @@ public class PqcProducers { @Singleton @Named("dilithiumKeyPair") KeyPair dilithiumKeyPair() throws Exception { - return generateKeyPair("Dilithium", DilithiumParameterSpec.dilithium2); + return generateKeyPair("ML-DSA", "BC", MLDSAParameterSpec.ml_dsa_44); } @Produces @Singleton @Named("falconKeyPair") public KeyPair falconKeyPair() throws Exception { - return generateKeyPair("Falcon", FalconParameterSpec.falcon_512); + return generateKeyPair("Falcon", "BCPQC", FalconParameterSpec.falcon_512); } @Produces @Singleton @Named("sphincsKeyPair") public KeyPair sphincsKeyPair() throws Exception { - return generateKeyPair("SPHINCSPlus", SPHINCSPlusParameterSpec.sha2_128f); + return generateKeyPair("SLH-DSA", "BC", SLHDSAParameterSpec.slh_dsa_sha2_128s); } @Produces @Singleton @Named("lmsKeyPair") public KeyPair lmsKeyPair() throws Exception { - return generateKeyPair("LMS", new LMSParameterSpec(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4)); + return generateKeyPair("LMS", "BCPQC", + new LMSParameterSpec(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w4)); } @Produces @Singleton @Named("xmssKeyPair") public KeyPair xmssKeyPair() throws Exception { - return generateKeyPair("XMSS", XMSSParameterSpec.SHA2_10_256); + return generateKeyPair("XMSS", "BCPQC", XMSSParameterSpec.SHA2_10_256); } @Produces @Singleton @Named("kyberKeyPair") public KeyPair kyberKeyPair() throws Exception { - return generateKeyPair("Kyber", KyberParameterSpec.kyber512); + return generateKeyPair("ML-KEM", "BC", MLKEMParameterSpec.ml_kem_512); } @Produces @Singleton - @Named("kyberWrongKeyPair") //second keypair for negative scenario + @Named("kyberWrongKeyPair") public KeyPair kyberWrongKeyPair() throws Exception { - return generateKeyPair("Kyber", KyberParameterSpec.kyber512); + return generateKeyPair("ML-KEM", "BC", MLKEMParameterSpec.ml_kem_512); } - private KeyPair generateKeyPair(String algorithm, AlgorithmParameterSpec spec) throws Exception { - KeyPairGenerator gen = KeyPairGenerator.getInstance(algorithm, "BCPQC"); + private KeyPair generateKeyPair(String algorithm, String provider, AlgorithmParameterSpec spec) throws Exception { + KeyPairGenerator gen = KeyPairGenerator.getInstance(algorithm, provider); gen.initialize(spec, secureRandom); return gen.generateKeyPair(); } diff --git a/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcResource.java b/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcResource.java index 5fdc95c8c0..01a4f8b013 100644 --- a/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcResource.java +++ b/integration-tests/pqc/src/main/java/org/apache/camel/quarkus/component/pqc/it/PqcResource.java @@ -57,7 +57,8 @@ public class PqcResource { @jakarta.ws.rs.Produces(MediaType.TEXT_PLAIN) public String sign(String message, @PathParam("algorithm") String algorithm) { Exchange exchange = producerTemplate.request( - "pqc:sign?operation=sign&signatureAlgorithm=%s&keyPair=%s".formatted(algorithm, toKeyPair(algorithm)), + "pqc:sign?operation=sign&signatureAlgorithm=%s&keyPair=%s".formatted(toEnumName(algorithm), + toKeyPair(algorithm)), ex -> ex.getIn().setBody(message.getBytes(StandardCharsets.UTF_8))); // The sign operation outputs signature in the HEADER, not the body @@ -78,7 +79,8 @@ public class PqcResource { headers.put("CamelPQCSignature", signatureBytes); Exchange exchange = producerTemplate.request( - "pqc:verify?operation=verify&signatureAlgorithm=%s&keyPair=%s".formatted(algorithm, toKeyPair(algorithm)), + "pqc:verify?operation=verify&signatureAlgorithm=%s&keyPair=%s".formatted(toEnumName(algorithm), + toKeyPair(algorithm)), ex -> { ex.getIn().setBody(message.getBytes(StandardCharsets.UTF_8)); ex.getIn().setHeaders(headers); @@ -96,7 +98,7 @@ public class PqcResource { @PathParam("length") int length) { SecretKeyWithEncapsulation secretKeyWithEncapsulation = producerTemplate.requestBody( "pqc:encapsulate?operation=generateSecretKeyEncapsulation&keyEncapsulationAlgorithm=%s&symmetricKeyAlgorithm=%s&symmetricKeyLength=%s&keyPair=%s" - .formatted(algorithm, keyAlgorithm, length, toKeyPair(algorithm)), + .formatted(toEnumName(algorithm), keyAlgorithm, length, toKeyPair(algorithm)), null, SecretKeyWithEncapsulation.class); String enc = Base64.getEncoder().encodeToString(secretKeyWithEncapsulation.getEncapsulation()); @@ -120,14 +122,28 @@ public class PqcResource { SecretKeyWithEncapsulation result = producerTemplate.requestBody( "pqc:extract?operation=extractSecretKeyEncapsulation&keyEncapsulationAlgorithm=%s&symmetricKeyAlgorithm=%s&symmetricKeyLength=%s&keyPair=%s" - .formatted(algorithm, keyAlgorithm, length, toKeyPair(algorithm)), + .formatted(toEnumName(algorithm), keyAlgorithm, length, toKeyPair(algorithm)), privateKeyWithEncapsulation, SecretKeyWithEncapsulation.class); return Base64.getEncoder().encodeToString(result.getEncoded()); } + private String toEnumName(String algorithm) { + return switch (algorithm) { + case "ML-DSA" -> "DILITHIUM"; + case "SLH-DSA" -> "SPHINCSPLUS"; + case "ML-KEM" -> "KYBER"; + default -> algorithm; + }; + } + private String toKeyPair(String algorithm) { - return "SPHINCSPLUS".equals(algorithm) ? "#sphincsKeyPair" : "#" + algorithm.toLowerCase() + "KeyPair"; + return switch (algorithm) { + case "ML-DSA" -> "#dilithiumKeyPair"; + case "SLH-DSA" -> "#sphincsKeyPair"; + case "ML-KEM" -> "#kyberKeyPair"; + default -> "#" + algorithm.toLowerCase() + "KeyPair"; + }; } // Body tests: binary data
