This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-21971-pqc-def in repository https://gitbox.apache.org/repos/asf/camel.git
commit 23a68350dedb1806c14998f54c61bab2f94a62ce Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Wed Apr 16 13:58:09 2025 +0200 CAMEL-21971 - camel-pqc - Provide default KeyPair and Signature Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../apache/camel/component/pqc/PQCComponent.java | 30 +++++++++++++ .../pqc/crypto/PQCDefaultLMSMaterial.java | 51 ++++++++++++++++++++++ .../pqc/crypto/PQCDefaultMLDSAMaterial.java | 50 +++++++++++++++++++++ .../pqc/crypto/PQCDefaultSLHDSAMaterial.java | 50 +++++++++++++++++++++ .../pqc/crypto/PQCDefaultXMSSMaterial.java | 50 +++++++++++++++++++++ .../PQCSignatureFalconNoSignerAutowiredTest.java | 7 ++- .../component/pqc/PQCSignatureFalconTest.java | 8 +++- ...st.java => PQCSignatureLMSNoAutowiredTest.java} | 21 +++------ .../camel/component/pqc/PQCSignatureLMSTest.java | 8 +++- ....java => PQCSignatureMLDSANoAutowiredTest.java} | 17 ++------ .../pqc/PQCSignatureNoAutowiredSignatureTest.java | 7 ++- .../component/pqc/PQCSignaturePicnicTest.java | 8 +++- .../component/pqc/PQCSignatureRainbowTest.java | 8 +++- ...java => PQCSignatureSLHDSANoAutowiredTest.java} | 21 +++------ .../component/pqc/PQCSignatureSLHDSATest.java | 8 +++- .../camel/component/pqc/PQCSignatureTest.java | 8 +++- .../pqc/PQCSignatureWrongKeyPairSignatureTest.java | 8 +++- ...t.java => PQCSignatureXMSSNoAutowiredTest.java} | 21 +++------ .../camel/component/pqc/PQCSignatureXMSSTest.java | 9 +++- 19 files changed, 322 insertions(+), 68 deletions(-) diff --git a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCComponent.java b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCComponent.java index 8028e79aafb..0007ef8d2a4 100644 --- a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCComponent.java +++ b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCComponent.java @@ -20,9 +20,14 @@ import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; +import org.apache.camel.component.pqc.crypto.PQCDefaultLMSMaterial; +import org.apache.camel.component.pqc.crypto.PQCDefaultMLDSAMaterial; +import org.apache.camel.component.pqc.crypto.PQCDefaultSLHDSAMaterial; +import org.apache.camel.component.pqc.crypto.PQCDefaultXMSSMaterial; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.HealthCheckComponent; +import org.apache.camel.util.ObjectHelper; /** * For working with Post Quantum Cryptography Algorithms @@ -48,6 +53,31 @@ public class PQCComponent extends HealthCheckComponent { PQCEndpoint endpoint = new PQCEndpoint(uri, this, configuration); setProperties(endpoint, parameters); + if (ObjectHelper.isEmpty(configuration.getSigner()) && ObjectHelper.isEmpty(configuration.getKeyPair())) { + switch (configuration.getSignatureAlgorithm()) { + case "MLDSA": + configuration.setSigner(PQCDefaultMLDSAMaterial.signer); + configuration.setKeyPair(PQCDefaultMLDSAMaterial.keyPair); + break; + case "SLHDSA": + configuration.setSigner(PQCDefaultSLHDSAMaterial.signer); + configuration.setKeyPair(PQCDefaultSLHDSAMaterial.keyPair); + break; + case "LMS": + configuration.setSigner(PQCDefaultLMSMaterial.signer); + configuration.setKeyPair(PQCDefaultLMSMaterial.keyPair); + break; + case "XMSS": + configuration.setSigner(PQCDefaultXMSSMaterial.signer); + configuration.setKeyPair(PQCDefaultXMSSMaterial.keyPair); + break; + default: + break; + } + ; + + } + return endpoint; } diff --git a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultLMSMaterial.java b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultLMSMaterial.java new file mode 100644 index 00000000000..0c9d37c2da4 --- /dev/null +++ b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultLMSMaterial.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.pqc.crypto; + +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Signature; + +import org.bouncycastle.pqc.crypto.lms.LMOtsParameters; +import org.bouncycastle.pqc.crypto.lms.LMSigParameters; +import org.bouncycastle.pqc.jcajce.spec.LMSKeyGenParameterSpec; + +public class PQCDefaultLMSMaterial { + public static final KeyPair keyPair; + public static final Signature signer; + + static { + KeyPairGenerator generator; + try { + generator = prepareKeyPair(); + keyPair = generator.generateKeyPair(); + signer = Signature.getInstance("LMS"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected static KeyPairGenerator prepareKeyPair() + throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { + KeyPairGenerator kpGen = KeyPairGenerator.getInstance("LMS", "BC"); + kpGen.initialize(new LMSKeyGenParameterSpec(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w1)); + return kpGen; + } +} diff --git a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultMLDSAMaterial.java b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultMLDSAMaterial.java new file mode 100644 index 00000000000..3584582b0ae --- /dev/null +++ b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultMLDSAMaterial.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.pqc.crypto; + +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.Signature; + +import org.bouncycastle.jcajce.spec.MLDSAParameterSpec; + +public class PQCDefaultMLDSAMaterial { + public static final KeyPair keyPair; + public static final Signature signer; + + static { + KeyPairGenerator generator; + try { + generator = prepareKeyPair(); + keyPair = generator.generateKeyPair(); + signer = Signature.getInstance("ML-DSA"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected static KeyPairGenerator prepareKeyPair() + throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { + KeyPairGenerator kpGen = KeyPairGenerator.getInstance("ML-DSA", "BC"); + kpGen.initialize(MLDSAParameterSpec.ml_dsa_65, new SecureRandom()); + return kpGen; + } +} diff --git a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultSLHDSAMaterial.java b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultSLHDSAMaterial.java new file mode 100644 index 00000000000..4d783915556 --- /dev/null +++ b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultSLHDSAMaterial.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.pqc.crypto; + +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.Signature; + +import org.bouncycastle.jcajce.spec.SLHDSAParameterSpec; + +public class PQCDefaultSLHDSAMaterial { + public static final KeyPair keyPair; + public static final Signature signer; + + static { + KeyPairGenerator generator; + try { + generator = prepareKeyPair(); + keyPair = generator.generateKeyPair(); + signer = Signature.getInstance("SLH-DSA"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected static KeyPairGenerator prepareKeyPair() + throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { + KeyPairGenerator kpGen = KeyPairGenerator.getInstance("SLH-DSA", "BC"); + kpGen.initialize(SLHDSAParameterSpec.slh_dsa_sha2_128s, new SecureRandom()); + return kpGen; + } +} diff --git a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultXMSSMaterial.java b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultXMSSMaterial.java new file mode 100644 index 00000000000..48cc6d5e550 --- /dev/null +++ b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultXMSSMaterial.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.pqc.crypto; + +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.Signature; + +import org.bouncycastle.pqc.jcajce.spec.XMSSParameterSpec; + +public class PQCDefaultXMSSMaterial { + public static final KeyPair keyPair; + public static final Signature signer; + + static { + KeyPairGenerator generator; + try { + generator = prepareKeyPair(); + keyPair = generator.generateKeyPair(); + signer = Signature.getInstance("XMSS"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected static KeyPairGenerator prepareKeyPair() + throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { + KeyPairGenerator kpGen = KeyPairGenerator.getInstance("XMSS", "BCPQC"); + kpGen.initialize(new XMSSParameterSpec(10, XMSSParameterSpec.SHA256), new SecureRandom()); + return kpGen; + } +} diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java index b5b25b539de..6df67bfc356 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java @@ -16,7 +16,12 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconTest.java index f848d40d87b..41a1264cb40 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconTest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSNoAutowiredTest.java similarity index 77% copy from components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java copy to components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSNoAutowiredTest.java index 902e1add9d9..0a907a4127b 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSNoAutowiredTest.java @@ -16,23 +16,22 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.NoSuchAlgorithmException; +import java.security.Security; -import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit5.CamelTestSupport; -import org.bouncycastle.jcajce.spec.MLDSAParameterSpec; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; -public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { +public class PQCSignatureLMSNoAutowiredTest extends CamelTestSupport { @EndpointInject("mock:sign") protected MockEndpoint resultSign; @@ -43,7 +42,7 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { @Produce("direct:sign") protected ProducerTemplate templateSign; - public PQCSignatureNoAutowiredSignatureTest() throws NoSuchAlgorithmException { + public PQCSignatureLMSNoAutowiredTest() throws NoSuchAlgorithmException { } @Override @@ -51,8 +50,8 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("direct:sign").to("pqc:sign?operation=sign&signatureAlgorithm=MLDSA").to("mock:sign") - .to("pqc:verify?operation=verify&signatureAlgorithm=MLDSA") + from("direct:sign").to("pqc:sign?operation=sign&signatureAlgorithm=LMS").to("mock:sign") + .to("pqc:verify?operation=verify&signatureAlgorithm=LMS") .to("mock:verify"); } }; @@ -72,12 +71,4 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { resultVerify.assertIsSatisfied(); assertTrue(resultVerify.getExchanges().get(0).getMessage().getHeader(PQCConstants.VERIFY, Boolean.class)); } - - @BindToRegistry("Keypair") - public KeyPair setKeyPair() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { - KeyPairGenerator kpGen = KeyPairGenerator.getInstance("MLDSA", "BC"); - kpGen.initialize(MLDSAParameterSpec.ml_dsa_65); - KeyPair kp = kpGen.generateKeyPair(); - return kp; - } } diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSTest.java index 6bfb1b20834..40d3b6cd276 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureLMSTest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureMLDSANoAutowiredTest.java similarity index 79% copy from components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java copy to components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureMLDSANoAutowiredTest.java index 902e1add9d9..3b596865ece 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureMLDSANoAutowiredTest.java @@ -16,23 +16,22 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.NoSuchAlgorithmException; +import java.security.Security; -import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit5.CamelTestSupport; -import org.bouncycastle.jcajce.spec.MLDSAParameterSpec; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; -public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { +public class PQCSignatureMLDSANoAutowiredTest extends CamelTestSupport { @EndpointInject("mock:sign") protected MockEndpoint resultSign; @@ -43,7 +42,7 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { @Produce("direct:sign") protected ProducerTemplate templateSign; - public PQCSignatureNoAutowiredSignatureTest() throws NoSuchAlgorithmException { + public PQCSignatureMLDSANoAutowiredTest() throws NoSuchAlgorithmException { } @Override @@ -72,12 +71,4 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { resultVerify.assertIsSatisfied(); assertTrue(resultVerify.getExchanges().get(0).getMessage().getHeader(PQCConstants.VERIFY, Boolean.class)); } - - @BindToRegistry("Keypair") - public KeyPair setKeyPair() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { - KeyPairGenerator kpGen = KeyPairGenerator.getInstance("MLDSA", "BC"); - kpGen.initialize(MLDSAParameterSpec.ml_dsa_65); - KeyPair kp = kpGen.generateKeyPair(); - return kp; - } } diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java index 902e1add9d9..8c3fc0f1eea 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java @@ -16,7 +16,12 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignaturePicnicTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignaturePicnicTest.java index 6aec74e6097..e809089d78c 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignaturePicnicTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignaturePicnicTest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureRainbowTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureRainbowTest.java index a54159ba043..315de084896 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureRainbowTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureRainbowTest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSANoAutowiredTest.java similarity index 77% copy from components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java copy to components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSANoAutowiredTest.java index 902e1add9d9..65086098f60 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureNoAutowiredSignatureTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSANoAutowiredTest.java @@ -16,23 +16,22 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.NoSuchAlgorithmException; +import java.security.Security; -import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit5.CamelTestSupport; -import org.bouncycastle.jcajce.spec.MLDSAParameterSpec; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; -public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { +public class PQCSignatureSLHDSANoAutowiredTest extends CamelTestSupport { @EndpointInject("mock:sign") protected MockEndpoint resultSign; @@ -43,7 +42,7 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { @Produce("direct:sign") protected ProducerTemplate templateSign; - public PQCSignatureNoAutowiredSignatureTest() throws NoSuchAlgorithmException { + public PQCSignatureSLHDSANoAutowiredTest() throws NoSuchAlgorithmException { } @Override @@ -51,8 +50,8 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("direct:sign").to("pqc:sign?operation=sign&signatureAlgorithm=MLDSA").to("mock:sign") - .to("pqc:verify?operation=verify&signatureAlgorithm=MLDSA") + from("direct:sign").to("pqc:sign?operation=sign&signatureAlgorithm=SLHDSA").to("mock:sign") + .to("pqc:verify?operation=verify&signatureAlgorithm=SLHDSA") .to("mock:verify"); } }; @@ -72,12 +71,4 @@ public class PQCSignatureNoAutowiredSignatureTest extends CamelTestSupport { resultVerify.assertIsSatisfied(); assertTrue(resultVerify.getExchanges().get(0).getMessage().getHeader(PQCConstants.VERIFY, Boolean.class)); } - - @BindToRegistry("Keypair") - public KeyPair setKeyPair() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { - KeyPairGenerator kpGen = KeyPairGenerator.getInstance("MLDSA", "BC"); - kpGen.initialize(MLDSAParameterSpec.ml_dsa_65); - KeyPair kp = kpGen.generateKeyPair(); - return kp; - } } diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSATest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSATest.java index 716786ee000..7b6c0fe2d86 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSATest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureSLHDSATest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureTest.java index b7c45eeb566..586400bbc73 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureTest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureWrongKeyPairSignatureTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureWrongKeyPairSignatureTest.java index 52b1fb35184..80e123908c5 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureWrongKeyPairSignatureTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureWrongKeyPairSignatureTest.java @@ -16,7 +16,13 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; import org.apache.camel.*; import org.apache.camel.builder.RouteBuilder; diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSNoAutowiredTest.java similarity index 77% copy from components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java copy to components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSNoAutowiredTest.java index b5b25b539de..f6e4c3b8f3c 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureFalconNoSignerAutowiredTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSNoAutowiredTest.java @@ -16,9 +16,9 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.NoSuchAlgorithmException; +import java.security.Security; -import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; @@ -27,13 +27,12 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit5.CamelTestSupport; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider; -import org.bouncycastle.pqc.jcajce.spec.FalconParameterSpec; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; -public class PQCSignatureFalconNoSignerAutowiredTest extends CamelTestSupport { +public class PQCSignatureXMSSNoAutowiredTest extends CamelTestSupport { @EndpointInject("mock:sign") protected MockEndpoint resultSign; @@ -44,7 +43,7 @@ public class PQCSignatureFalconNoSignerAutowiredTest extends CamelTestSupport { @Produce("direct:sign") protected ProducerTemplate templateSign; - public PQCSignatureFalconNoSignerAutowiredTest() throws NoSuchAlgorithmException { + public PQCSignatureXMSSNoAutowiredTest() throws NoSuchAlgorithmException { } @Override @@ -52,8 +51,8 @@ public class PQCSignatureFalconNoSignerAutowiredTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() { - from("direct:sign").to("pqc:sign?operation=sign&signatureAlgorithm=FALCON").to("mock:sign") - .to("pqc:verify?operation=verify&signatureAlgorithm=FALCON") + from("direct:sign").to("pqc:sign?operation=sign&signatureAlgorithm=XMSS").to("mock:sign") + .to("pqc:verify?operation=verify&signatureAlgorithm=XMSS") .to("mock:verify"); } }; @@ -74,12 +73,4 @@ public class PQCSignatureFalconNoSignerAutowiredTest extends CamelTestSupport { resultVerify.assertIsSatisfied(); assertTrue(resultVerify.getExchanges().get(0).getMessage().getHeader(PQCConstants.VERIFY, Boolean.class)); } - - @BindToRegistry("Keypair") - public KeyPair setKeyPair() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { - KeyPairGenerator kpGen = KeyPairGenerator.getInstance("Falcon", "BCPQC"); - kpGen.initialize(FalconParameterSpec.falcon_1024); - KeyPair kp = kpGen.generateKeyPair(); - return kp; - } } diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSTest.java index 768d375eb27..0a36f8ca3a3 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCSignatureXMSSTest.java @@ -16,7 +16,14 @@ */ package org.apache.camel.component.pqc; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.Security; +import java.security.Signature; import org.apache.camel.BindToRegistry; import org.apache.camel.EndpointInject;