This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new a911791503a CAMEL-21995 - Camel-PQC: Add an
extractSecretKeyFromEncapsulation producer operation (#17804)
a911791503a is described below
commit a911791503a741badc8434a4a913a6ac46f40284
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Apr 18 15:53:15 2025 +0200
CAMEL-21995 - Camel-PQC: Add an extractSecretKeyFromEncapsulation producer
operation (#17804)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../org/apache/camel/catalog/components/pqc.json | 4 +--
.../org/apache/camel/component/pqc/pqc.json | 4 +--
.../apache/camel/component/pqc/PQCOperations.java | 3 ++-
.../apache/camel/component/pqc/PQCProducer.java | 19 +++++++++++++
.../component/pqc/PQCSymmetricAlgorithms.java | 3 ++-
...erateEncapsulationCryptoRoundTripAriaTest.java} | 31 +++++++---------------
...EMGenerateEncapsulationCryptoRoundTripTest.java | 18 +++----------
7 files changed, 40 insertions(+), 42 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pqc.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pqc.json
index 56a677dff2e..141ce7e15b2 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pqc.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pqc.json
@@ -26,7 +26,7 @@
"componentProperties": {
"configuration": { "index": 0, "kind": "property", "displayName":
"Configuration", "group": "producer", "label": "", "required": false, "type":
"object", "javaType": "org.apache.camel.component.pqc.PQCConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description":
"Component configuration" },
"lazyStartProducer": { "index": 1, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "operation": { "index": 2, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "object",
"javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [ "sign",
"verify", "generateSecretKeyEncapsulation", "extractSecretKeyEncapsulation" ],
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "configurationClass": "org.apache.camel.component.pqc.PQCConfiguration",
"configurationField": "configura [...]
+ "operation": { "index": 2, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "object",
"javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [ "sign",
"verify", "generateSecretKeyEncapsulation", "extractSecretKeyEncapsulation",
"extractSecretKeyFromEncapsulation" ], "deprecated": false, "deprecationNote":
"", "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfigurati [...]
"autowiredEnabled": { "index": 3, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
"keyEncapsulationAlgorithm": { "index": 4, "kind": "property",
"displayName": "Key Encapsulation Algorithm", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configuration", "description": "In case there is no keyGenerator, we specify
an algorithm t [...]
"keyGenerator": { "index": 5, "kind": "property", "displayName": "Key
Generator", "group": "advanced", "label": "advanced", "required": false,
"type": "object", "javaType": "javax.crypto.KeyGenerator", "deprecated": false,
"deprecationNote": "", "autowired": true, "secret": false,
"configurationClass": "org.apache.camel.component.pqc.PQCConfiguration",
"configurationField": "configuration", "description": "The Key Generator to be
used in encapsulation and extraction" },
@@ -44,7 +44,7 @@
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configuration", "description": "Logical name" },
- "operation": { "index": 1, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"object", "javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [
"sign", "verify", "generateSecretKeyEncapsulation",
"extractSecretKeyEncapsulation" ], "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configur [...]
+ "operation": { "index": 1, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"object", "javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [
"sign", "verify", "generateSecretKeyEncapsulation",
"extractSecretKeyEncapsulation", "extractSecretKeyFromEncapsulation" ],
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "configurationClass": "org.apache.camel.component.pqc.PQCConfigurat [...]
"lazyStartProducer": { "index": 2, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
"keyEncapsulationAlgorithm": { "index": 3, "kind": "parameter",
"displayName": "Key Encapsulation Algorithm", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configuration", "description": "In case there is no keyGenerator, we specify
an algorithm [...]
"keyGenerator": { "index": 4, "kind": "parameter", "displayName": "Key
Generator", "group": "advanced", "label": "advanced", "required": false,
"type": "object", "javaType": "javax.crypto.KeyGenerator", "deprecated": false,
"deprecationNote": "", "autowired": true, "secret": false,
"configurationClass": "org.apache.camel.component.pqc.PQCConfiguration",
"configurationField": "configuration", "description": "The Key Generator to be
used in encapsulation and extraction" },
diff --git
a/components/camel-pqc/src/generated/resources/META-INF/org/apache/camel/component/pqc/pqc.json
b/components/camel-pqc/src/generated/resources/META-INF/org/apache/camel/component/pqc/pqc.json
index 56a677dff2e..141ce7e15b2 100644
---
a/components/camel-pqc/src/generated/resources/META-INF/org/apache/camel/component/pqc/pqc.json
+++
b/components/camel-pqc/src/generated/resources/META-INF/org/apache/camel/component/pqc/pqc.json
@@ -26,7 +26,7 @@
"componentProperties": {
"configuration": { "index": 0, "kind": "property", "displayName":
"Configuration", "group": "producer", "label": "", "required": false, "type":
"object", "javaType": "org.apache.camel.component.pqc.PQCConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description":
"Component configuration" },
"lazyStartProducer": { "index": 1, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "operation": { "index": 2, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "object",
"javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [ "sign",
"verify", "generateSecretKeyEncapsulation", "extractSecretKeyEncapsulation" ],
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "configurationClass": "org.apache.camel.component.pqc.PQCConfiguration",
"configurationField": "configura [...]
+ "operation": { "index": 2, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "object",
"javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [ "sign",
"verify", "generateSecretKeyEncapsulation", "extractSecretKeyEncapsulation",
"extractSecretKeyFromEncapsulation" ], "deprecated": false, "deprecationNote":
"", "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfigurati [...]
"autowiredEnabled": { "index": 3, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
"keyEncapsulationAlgorithm": { "index": 4, "kind": "property",
"displayName": "Key Encapsulation Algorithm", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configuration", "description": "In case there is no keyGenerator, we specify
an algorithm t [...]
"keyGenerator": { "index": 5, "kind": "property", "displayName": "Key
Generator", "group": "advanced", "label": "advanced", "required": false,
"type": "object", "javaType": "javax.crypto.KeyGenerator", "deprecated": false,
"deprecationNote": "", "autowired": true, "secret": false,
"configurationClass": "org.apache.camel.component.pqc.PQCConfiguration",
"configurationField": "configuration", "description": "The Key Generator to be
used in encapsulation and extraction" },
@@ -44,7 +44,7 @@
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configuration", "description": "Logical name" },
- "operation": { "index": 1, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"object", "javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [
"sign", "verify", "generateSecretKeyEncapsulation",
"extractSecretKeyEncapsulation" ], "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configur [...]
+ "operation": { "index": 1, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"object", "javaType": "org.apache.camel.component.pqc.PQCOperations", "enum": [
"sign", "verify", "generateSecretKeyEncapsulation",
"extractSecretKeyEncapsulation", "extractSecretKeyFromEncapsulation" ],
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "configurationClass": "org.apache.camel.component.pqc.PQCConfigurat [...]
"lazyStartProducer": { "index": 2, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
"keyEncapsulationAlgorithm": { "index": 3, "kind": "parameter",
"displayName": "Key Encapsulation Algorithm", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.pqc.PQCConfiguration", "configurationField":
"configuration", "description": "In case there is no keyGenerator, we specify
an algorithm [...]
"keyGenerator": { "index": 4, "kind": "parameter", "displayName": "Key
Generator", "group": "advanced", "label": "advanced", "required": false,
"type": "object", "javaType": "javax.crypto.KeyGenerator", "deprecated": false,
"deprecationNote": "", "autowired": true, "secret": false,
"configurationClass": "org.apache.camel.component.pqc.PQCConfiguration",
"configurationField": "configuration", "description": "The Key Generator to be
used in encapsulation and extraction" },
diff --git
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCOperations.java
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCOperations.java
index 45d6abdc5c1..f1e892ced37 100644
---
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCOperations.java
+++
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCOperations.java
@@ -20,5 +20,6 @@ public enum PQCOperations {
sign,
verify,
generateSecretKeyEncapsulation,
- extractSecretKeyEncapsulation
+ extractSecretKeyEncapsulation,
+ extractSecretKeyFromEncapsulation
}
diff --git
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java
index 08fcad12404..2f3692d6af7 100644
---
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java
+++
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java
@@ -19,6 +19,8 @@ package org.apache.camel.component.pqc;
import java.security.*;
import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
@@ -60,6 +62,9 @@ public class PQCProducer extends DefaultProducer {
case extractSecretKeyEncapsulation:
extractEncapsulation(exchange);
break;
+ case extractSecretKeyFromEncapsulation:
+ extractSecretKeyFromEncapsulation(exchange);
+ break;
default:
throw new IllegalArgumentException("Unsupported operation");
}
@@ -169,4 +174,18 @@ public class PQCProducer extends DefaultProducer {
exchange.getMessage().setBody(secEnc2,
SecretKeyWithEncapsulation.class);
}
+ private void extractSecretKeyFromEncapsulation(Exchange exchange)
+ throws InvalidPayloadException {
+ // initialise for creating an encapsulation and shared secret.
+ SecretKeyWithEncapsulation payload =
exchange.getMessage().getMandatoryBody(SecretKeyWithEncapsulation.class);
+
+ if
(ObjectHelper.isEmpty(getConfiguration().getSymmetricKeyAlgorithm())) {
+ throw new IllegalArgumentException("Symmetric Algorithm needs to
be specified");
+ }
+
+ SecretKey restoredKey = new SecretKeySpec(payload.getEncoded(),
getConfiguration().getSymmetricKeyAlgorithm());
+
+ exchange.getMessage().setBody(restoredKey, SecretKey.class);
+ }
+
}
diff --git
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCSymmetricAlgorithms.java
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCSymmetricAlgorithms.java
index b54e5232428..2e384d48581 100644
---
a/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCSymmetricAlgorithms.java
+++
b/components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCSymmetricAlgorithms.java
@@ -20,7 +20,8 @@ public enum PQCSymmetricAlgorithms {
// Standardized and implemented
AES("AES"),
- RC5("RC5");
+ RC5("RC5"),
+ ARIA("ARIA");
private final String algorithm;
diff --git
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripAriaTest.java
similarity index 77%
copy from
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
copy to
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripAriaTest.java
index 61c5ead452c..77de14af67d 100644
---
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
+++
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripAriaTest.java
@@ -19,13 +19,9 @@ package org.apache.camel.component.pqc;
import java.security.*;
import javax.crypto.KeyGenerator;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
import org.apache.camel.BindToRegistry;
import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
@@ -39,9 +35,10 @@ import
org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class PQCMLKEMGenerateEncapsulationCryptoRoundTripTest extends
CamelTestSupport {
+public class PQCMLKEMGenerateEncapsulationCryptoRoundTripAriaTest extends
CamelTestSupport {
@EndpointInject("mock:encapsulate")
protected MockEndpoint resultEncapsulate;
@@ -55,7 +52,7 @@ public class PQCMLKEMGenerateEncapsulationCryptoRoundTripTest
extends CamelTestS
@EndpointInject("mock:unencrypted")
protected MockEndpoint resultDecrypted;
- public PQCMLKEMGenerateEncapsulationCryptoRoundTripTest() throws
NoSuchAlgorithmException {
+ public PQCMLKEMGenerateEncapsulationCryptoRoundTripAriaTest() throws
NoSuchAlgorithmException {
}
@Override
@@ -64,20 +61,12 @@ public class
PQCMLKEMGenerateEncapsulationCryptoRoundTripTest extends CamelTestS
return new RouteBuilder() {
@Override
public void configure() {
-
from("direct:encapsulate").to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=AES")
+
from("direct:encapsulate").to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=ARIA")
.to("mock:encapsulate")
-
.to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=AES")
- .log("${body}")
- .process(new Processor() {
- @Override
- public void process(Exchange exchange) throws
Exception {
- SecretKeyWithEncapsulation encapsulatedSecret
- =
exchange.getMessage().getBody(SecretKeyWithEncapsulation.class);
- SecretKey restoredKey = new
SecretKeySpec(encapsulatedSecret.getEncoded(), "AES");
-
exchange.getMessage().setHeader(CryptoDataFormat.KEY, restoredKey);
- exchange.getMessage().setBody("Hello",
String.class);
- }
- })
+
.to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=ARIA")
+
.to("pqc:keyenc?operation=extractSecretKeyFromEncapsulation&symmetricKeyAlgorithm=ARIA")
+ .setHeader(CryptoDataFormat.KEY, body())
+ .setBody(constant("Hello"))
.marshal(cryptoFormat)
.log("Encrypted ${body}")
.to("mock:encrypted")
@@ -103,7 +92,7 @@ public class
PQCMLKEMGenerateEncapsulationCryptoRoundTripTest extends CamelTestS
templateEncapsulate.sendBody("Hello");
resultEncapsulate.assertIsSatisfied();
assertNotNull(resultEncapsulate.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class));
- assertEquals(PQCSymmetricAlgorithms.AES.getAlgorithm(),
+ assertEquals(PQCSymmetricAlgorithms.ARIA.getAlgorithm(),
resultEncapsulate.getExchanges().get(0).getMessage().getBody(SecretKeyWithEncapsulation.class).getAlgorithm());
assertNotNull(resultEncrypted.getExchanges().get(0).getMessage().getBody());
assertEquals("Hello",
resultDecrypted.getExchanges().get(0).getMessage().getBody(String.class));
diff --git
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
index 61c5ead452c..b9f1cdb6add 100644
---
a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
+++
b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripTest.java
@@ -19,13 +19,9 @@ package org.apache.camel.component.pqc;
import java.security.*;
import javax.crypto.KeyGenerator;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
import org.apache.camel.BindToRegistry;
import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
@@ -67,17 +63,9 @@ public class
PQCMLKEMGenerateEncapsulationCryptoRoundTripTest extends CamelTestS
from("direct:encapsulate").to("pqc:keyenc?operation=generateSecretKeyEncapsulation&symmetricKeyAlgorithm=AES")
.to("mock:encapsulate")
.to("pqc:keyenc?operation=extractSecretKeyEncapsulation&symmetricKeyAlgorithm=AES")
- .log("${body}")
- .process(new Processor() {
- @Override
- public void process(Exchange exchange) throws
Exception {
- SecretKeyWithEncapsulation encapsulatedSecret
- =
exchange.getMessage().getBody(SecretKeyWithEncapsulation.class);
- SecretKey restoredKey = new
SecretKeySpec(encapsulatedSecret.getEncoded(), "AES");
-
exchange.getMessage().setHeader(CryptoDataFormat.KEY, restoredKey);
- exchange.getMessage().setBody("Hello",
String.class);
- }
- })
+
.to("pqc:keyenc?operation=extractSecretKeyFromEncapsulation&symmetricKeyAlgorithm=AES")
+ .setHeader(CryptoDataFormat.KEY, body())
+ .setBody(constant("Hello"))
.marshal(cryptoFormat)
.log("Encrypted ${body}")
.to("mock:encrypted")