This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch mlkem
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 7ea4dfaf759b29e82cde9acabe8b6e4368971316
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Apr 18 09:32:24 2025 +0200

    CAMEL-21969 - Camel-PQC: Support KEM operations
    
    Signed-off-by: Andrea Cosentino <[email protected]>
---
 .../pqc/PQCKeyEncapsulationAlgorithms.java         |  3 +-
 ...va => PQCBIKEGenerateEncapsulationAESTest.java} | 17 +++++-----
 .../pqc/PQCMLKEMGenerateEncapsulationAESTest.java  | 37 +++++++++++-----------
 3 files changed, 30 insertions(+), 27 deletions(-)

diff --git 
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCKeyEncapsulationAlgorithms.java
 
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCKeyEncapsulationAlgorithms.java
index 65880e60a16..8d9b4c905fb 100644
--- 
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCKeyEncapsulationAlgorithms.java
+++ 
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCKeyEncapsulationAlgorithms.java
@@ -19,7 +19,8 @@ package org.apache.camel.component.pqc;
 public enum PQCKeyEncapsulationAlgorithms {
 
     // Standardized and implemented
-    MLKEM("ML-KEM");
+    MLKEM("ML-KEM"),
+    BIKE("BIKE");
 
     // Experimental and non-standardized
 
diff --git 
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
 
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCBIKEGenerateEncapsulationAESTest.java
similarity index 85%
copy from 
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
copy to 
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCBIKEGenerateEncapsulationAESTest.java
index 237b129c6f1..d5743e76a0a 100644
--- 
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
+++ 
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCBIKEGenerateEncapsulationAESTest.java
@@ -28,16 +28,16 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.bouncycastle.jcajce.SecretKeyWithEncapsulation;
-import org.bouncycastle.jcajce.spec.MLKEMParameterSpec;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
+import org.bouncycastle.pqc.jcajce.spec.BIKEParameterSpec;
 import org.bouncycastle.util.Arrays;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.*;
 
-public class PQCMLKEMGenerateEncapsulationAESTest extends CamelTestSupport {
+public class PQCBIKEGenerateEncapsulationAESTest extends CamelTestSupport {
 
     @EndpointInject("mock:sign")
     protected MockEndpoint resultSign;
@@ -48,7 +48,7 @@ public class PQCMLKEMGenerateEncapsulationAESTest extends 
CamelTestSupport {
     @EndpointInject("mock:verify")
     protected MockEndpoint resultVerify;
 
-    public PQCMLKEMGenerateEncapsulationAESTest() throws 
NoSuchAlgorithmException {
+    public PQCBIKEGenerateEncapsulationAESTest() throws 
NoSuchAlgorithmException {
     }
 
     @Override
@@ -56,8 +56,9 @@ public class PQCMLKEMGenerateEncapsulationAESTest extends 
CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                
from("direct:sign").to("pqc:keyenc?operation=generateEncapsulation&symmetricKeyAlgorithm=AES").to("mock:sign")
-                        
.to("pqc:keyenc?operation=extractEncapsulation&symmetricKeyAlgorithm=AES").to("mock:verify");
+                
from("direct:sign").to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=AES")
+                        .to("mock:sign")
+                        
.to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=AES").to("mock:verify");
             }
         };
     }
@@ -89,8 +90,8 @@ public class PQCMLKEMGenerateEncapsulationAESTest extends 
CamelTestSupport {
 
     @BindToRegistry("Keypair")
     public KeyPair setKeyPair() throws NoSuchAlgorithmException, 
NoSuchProviderException, InvalidAlgorithmParameterException {
-        KeyPairGenerator kpg = KeyPairGenerator.getInstance("ML-KEM", "BC");
-        kpg.initialize(MLKEMParameterSpec.ml_kem_512, new SecureRandom());
+        KeyPairGenerator kpg = KeyPairGenerator.getInstance("BIKE", "BCPQC");
+        kpg.initialize(BIKEParameterSpec.bike192, new SecureRandom());
         KeyPair kp = kpg.generateKeyPair();
         return kp;
     }
@@ -98,7 +99,7 @@ public class PQCMLKEMGenerateEncapsulationAESTest extends 
CamelTestSupport {
     @BindToRegistry("KeyGenerator")
     public KeyGenerator setKeyGenerator()
             throws NoSuchAlgorithmException, NoSuchProviderException, 
InvalidAlgorithmParameterException {
-        KeyGenerator kg = KeyGenerator.getInstance("ML-KEM", "BC");
+        KeyGenerator kg = KeyGenerator.getInstance("BIKE", "BCPQC");
         return kg;
     }
 }
diff --git 
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
 
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
index 237b129c6f1..7d866d13ea8 100644
--- 
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
+++ 
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationAESTest.java
@@ -39,14 +39,14 @@ import static org.junit.jupiter.api.Assertions.*;
 
 public class PQCMLKEMGenerateEncapsulationAESTest extends CamelTestSupport {
 
-    @EndpointInject("mock:sign")
-    protected MockEndpoint resultSign;
+    @EndpointInject("mock:encapsulate")
+    protected MockEndpoint resultEncapsulate;
 
-    @Produce("direct:sign")
-    protected ProducerTemplate templateSign;
+    @Produce("direct:encapsulate")
+    protected ProducerTemplate templateEncapsulate;
 
-    @EndpointInject("mock:verify")
-    protected MockEndpoint resultVerify;
+    @EndpointInject("mock:extract")
+    protected MockEndpoint resultExtract;
 
     public PQCMLKEMGenerateEncapsulationAESTest() throws 
NoSuchAlgorithmException {
     }
@@ -56,8 +56,9 @@ public class PQCMLKEMGenerateEncapsulationAESTest extends 
CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                
from("direct:sign").to("pqc:keyenc?operation=generateEncapsulation&symmetricKeyAlgorithm=AES").to("mock:sign")
-                        
.to("pqc:keyenc?operation=extractEncapsulation&symmetricKeyAlgorithm=AES").to("mock:verify");
+                
from("direct:encapsulate").to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=AES")
+                        .to("mock:encapsulate")
+                        
.to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=AES").to("mock:extract");
             }
         };
     }
@@ -70,20 +71,20 @@ public class PQCMLKEMGenerateEncapsulationAESTest extends 
CamelTestSupport {
 
     @Test
     void testSignAndVerify() throws Exception {
-        resultSign.expectedMessageCount(1);
-        resultVerify.expectedMessageCount(1);
-        templateSign.sendBody("Hello");
-        resultSign.assertIsSatisfied();
-        
assertNotNull(resultSign.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class));
+        resultEncapsulate.expectedMessageCount(1);
+        resultExtract.expectedMessageCount(1);
+        templateEncapsulate.sendBody("Hello");
+        resultEncapsulate.assertIsSatisfied();
+        
assertNotNull(resultEncapsulate.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class));
         assertEquals(PQCSymmetricAlgorithms.AES.getAlgorithm(),
-                
resultSign.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class).getAlgorithm());
+                
resultEncapsulate.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class).getAlgorithm());
         SecretKeyWithEncapsulation secEncrypted
-                = 
resultSign.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class);
-        
assertNotNull(resultVerify.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class));
+                = 
resultEncapsulate.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class);
+        
assertNotNull(resultExtract.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class));
         assertEquals(PQCSymmetricAlgorithms.AES.getAlgorithm(),
-                
resultVerify.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class).getAlgorithm());
+                
resultExtract.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class).getAlgorithm());
         SecretKeyWithEncapsulation secEncryptedExtracted
-                = 
resultVerify.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class);
+                = 
resultExtract.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class);
         assertTrue(Arrays.areEqual(secEncrypted.getEncoded(), 
secEncryptedExtracted.getEncoded()));
     }
 

Reply via email to