Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.component.pqc.crypto.*;
import org.apache.camel.component.pqc.crypto.kem.*;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultBIKEMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultCMCEMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultFRODOMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultHQCMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultMLKEMMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultNTRULPRimeMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultNTRUMaterial;
import org.apache.camel.component.pqc.crypto.kem.PQCDefaultSABERMaterial;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.HealthCheckComponent;
Expand Down Expand Up @@ -70,6 +77,18 @@ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Obje
configuration.setSigner(PQCDefaultXMSSMaterial.signer);
configuration.setKeyPair(PQCDefaultXMSSMaterial.keyPair);
break;
case "FALCON":
configuration.setSigner(PQCDefaultFalconMaterial.signer);
configuration.setKeyPair(PQCDefaultFalconMaterial.keyPair);
break;
case "PICNIC":
configuration.setSigner(PQCDefaultPicnicMaterial.signer);
configuration.setKeyPair(PQCDefaultPicnicMaterial.keyPair);
break;
case "RAINBOW":
configuration.setSigner(PQCDefaultRainbowMaterial.signer);
configuration.setKeyPair(PQCDefaultRainbowMaterial.keyPair);
break;
default:
break;
}
Expand Down Expand Up @@ -103,6 +122,14 @@ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Obje
configuration.setKeyGenerator(PQCDefaultFRODOMaterial.keyGenerator);
configuration.setKeyPair(PQCDefaultFRODOMaterial.keyPair);
break;
case "NTRU":
configuration.setKeyGenerator(PQCDefaultNTRUMaterial.keyGenerator);
configuration.setKeyPair(PQCDefaultNTRUMaterial.keyPair);
break;
case "NTRULPRime":
configuration.setKeyGenerator(PQCDefaultNTRULPRimeMaterial.keyGenerator);
configuration.setKeyPair(PQCDefaultNTRULPRimeMaterial.keyPair);
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.*;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.pqc.jcajce.spec.FalconParameterSpec;

public class PQCDefaultFalconMaterial {
public static final KeyPair keyPair;
public static final Signature signer;

static {
KeyPairGenerator generator;
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance(PQCSignatureAlgorithms.FALCON.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.FALCON.getAlgorithm(),
PQCSignatureAlgorithms.FALCON.getBcProvider());
kpGen.initialize(FalconParameterSpec.falcon_1024);
return kpGen;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.NoSuchProviderException;
import java.security.Signature;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.pqc.crypto.lms.LMOtsParameters;
import org.bouncycastle.pqc.crypto.lms.LMSigParameters;
import org.bouncycastle.pqc.jcajce.spec.LMSKeyGenParameterSpec;
Expand All @@ -36,15 +37,16 @@ public class PQCDefaultLMSMaterial {
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance("LMS");
signer = Signature.getInstance(PQCSignatureAlgorithms.LMS.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("LMS", "BC");
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.LMS.getAlgorithm(),
PQCSignatureAlgorithms.LMS.getBcProvider());
kpGen.initialize(new LMSKeyGenParameterSpec(LMSigParameters.lms_sha256_n32_h5, LMOtsParameters.sha256_n32_w1));
return kpGen;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.security.SecureRandom;
import java.security.Signature;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.jcajce.spec.MLDSAParameterSpec;

public class PQCDefaultMLDSAMaterial {
Expand All @@ -35,15 +36,16 @@ public class PQCDefaultMLDSAMaterial {
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance("ML-DSA");
signer = Signature.getInstance(PQCSignatureAlgorithms.MLDSA.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("ML-DSA", "BC");
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.MLDSA.getAlgorithm(),
PQCSignatureAlgorithms.MLDSA.getBcProvider());
kpGen.initialize(MLDSAParameterSpec.ml_dsa_65, new SecureRandom());
return kpGen;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.*;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.pqc.jcajce.spec.PicnicParameterSpec;

public class PQCDefaultPicnicMaterial {
public static final KeyPair keyPair;
public static final Signature signer;

static {
KeyPairGenerator generator;
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance(PQCSignatureAlgorithms.PICNIC.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.PICNIC.getAlgorithm(),
PQCSignatureAlgorithms.PICNIC.getBcProvider());
kpGen.initialize(PicnicParameterSpec.picnic3l5);
return kpGen;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.*;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.pqc.jcajce.spec.RainbowParameterSpec;

public class PQCDefaultRainbowMaterial {
public static final KeyPair keyPair;
public static final Signature signer;

static {
KeyPairGenerator generator;
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance(PQCSignatureAlgorithms.RAINBOW.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.RAINBOW.getAlgorithm(),
PQCSignatureAlgorithms.RAINBOW.getBcProvider());
kpGen.initialize(RainbowParameterSpec.rainbowVclassic);
return kpGen;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.security.SecureRandom;
import java.security.Signature;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.jcajce.spec.SLHDSAParameterSpec;

public class PQCDefaultSLHDSAMaterial {
Expand All @@ -35,15 +36,16 @@ public class PQCDefaultSLHDSAMaterial {
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance("SLH-DSA");
signer = Signature.getInstance(PQCSignatureAlgorithms.SLHDSA.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("SLH-DSA", "BC");
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.SLHDSA.getAlgorithm(),
PQCSignatureAlgorithms.SLHDSA.getBcProvider());
kpGen.initialize(SLHDSAParameterSpec.slh_dsa_sha2_128s, new SecureRandom());
return kpGen;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.security.SecureRandom;
import java.security.Signature;

import org.apache.camel.component.pqc.PQCSignatureAlgorithms;
import org.bouncycastle.pqc.jcajce.spec.XMSSParameterSpec;

public class PQCDefaultXMSSMaterial {
Expand All @@ -35,15 +36,16 @@ public class PQCDefaultXMSSMaterial {
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
signer = Signature.getInstance("XMSS");
signer = Signature.getInstance(PQCSignatureAlgorithms.XMSS.getAlgorithm());
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("XMSS", "BCPQC");
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(PQCSignatureAlgorithms.XMSS.getAlgorithm(),
PQCSignatureAlgorithms.XMSS.getBcProvider());
kpGen.initialize(new XMSSParameterSpec(10, XMSSParameterSpec.SHA256), new SecureRandom());
return kpGen;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.kem;

import java.security.*;

import javax.crypto.KeyGenerator;

import org.apache.camel.component.pqc.PQCKeyEncapsulationAlgorithms;
import org.bouncycastle.pqc.jcajce.spec.NTRULPRimeParameterSpec;

public class PQCDefaultNTRULPRimeMaterial {

public static final KeyPair keyPair;
public static final KeyGenerator keyGenerator;
public static final KeyPairGenerator generator;

static {
try {
generator = prepareKeyPair();
keyPair = generator.generateKeyPair();
keyGenerator = prepareKeyGenerator();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected static KeyPairGenerator prepareKeyPair()
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
KeyPairGenerator kpg = KeyPairGenerator.getInstance(PQCKeyEncapsulationAlgorithms.NTRULPRime.getAlgorithm(),
PQCKeyEncapsulationAlgorithms.NTRULPRime.getBcProvider());
kpg.initialize(NTRULPRimeParameterSpec.ntrulpr761, new SecureRandom());
return kpg;
}

protected static KeyGenerator prepareKeyGenerator() throws NoSuchAlgorithmException, NoSuchProviderException {
KeyGenerator kg = KeyGenerator.getInstance(PQCKeyEncapsulationAlgorithms.NTRULPRime.getAlgorithm(),
PQCKeyEncapsulationAlgorithms.NTRULPRime.getBcProvider());
return kg;
}
}
Loading