Camel Components

Crypto (JCE)

Since Camel 2.3

Only producer is supported

With Camel cryptographic endpoints and Java’s Cryptographic extension, it is possible to create Digital Signatures for Exchanges. Camel provides a pair of flexible endpoints which get used in concert to create a signature for an exchange in one part of the exchange’s workflow and then verify the signature in a later part of the workflow.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-crypto</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

Introduction

Digital signatures make use of Asymmetric Cryptographic techniques to sign messages. From a (very) high level, the algorithms use pairs of complimentary keys with the special property that data encrypted with one key can only be decrypted with the other. One, the private key, is closely guarded and used to 'sign' the message while the other, public key, is shared around to anyone interested in verifying the signed messages. Messages are signed by using the private key to encrypting a digest of the message. This encrypted digest is transmitted along with the message. On the other side, the verifier recalculates the message digest and uses the public key to decrypt the digest in the signature. If both digests match, the verifier knows only the holder of the private key could have created the signature.

Camel uses the Signature service from the Java Cryptographic Extension to do all the heavy cryptographic lifting required to create exchange signatures. The following are some excellent resources for explaining the mechanics of Cryptography, Message digests and Digital Signatures and how to leverage them with the JCE.

  • Bruce Schneier’s Applied Cryptography

  • Beginning Cryptography with Java by David Hook

  • The ever insightful Wikipedia Digital_signatures

URI format

As mentioned, Camel provides a pair of crypto endpoints to create and verify signatures

crypto:sign:name[?options]
crypto:verify:name[?options]
  • crypto:sign creates the signature and stores it in the header CamelDigitalSignature.

  • crypto:verify will read in the contents of this header and do the verification calculation.

The message body is the payload that is signed or verified, and it is not changed. A stream body is cached, so the next step of the route still gets the body, also when stream caching is turned off. A message without body is signed as an empty payload by crypto:sign, and crypto:verify fails it with a SignatureException.

To correctly function, the sign and verify process needs a pair of keys to be shared, signing requiring a PrivateKey and verifying a PublicKey (or a Certificate containing one). Using the JCE it is very simple to generate these key pairs, but it is usually most secure to use a KeyStore to house and share your keys. The DSL is very flexible about how keys are supplied and provides a number of mechanisms.

Note a crypto:sign endpoint is typically defined in one route and the complimentary crypto:verify in another, though for simplicity in the examples they appear one after the other. It goes without saying that both signing and verifying should be configured identically.

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The Crypto (JCE) component supports the following options which are listed below.

Name Description Default Type

algorithm (producer)

The standard name of the signature algorithm of the Java Cryptography Architecture, for example SHA256withRSA or SHA256withECDSA. It must match the type of the key, and the sign and verify endpoints must use the same algorithm.

SHA256withRSA

String

alias (producer)

The alias of the keystore entry: the sign operation signs with its private key, and the verify operation verifies with its certificate. If not set and the keystore holds exactly one entry, that entry is used.

String

certificateName (producer)

The name of a java.security.cert.Certificate bean in the registry to use as the certificate option. A name with no such bean is ignored.

String

keystore (producer)

The keystore that holds the private key for the sign operation and the certificate for the verify operation. The alias option selects the entry, or the only entry is used when the keystore holds exactly one. An entry found in the keystore is used instead of the privateKey, certificate and publicKey options.

KeyStore

keystoreName (producer)

The name of a java.security.KeyStore bean in the registry to use as the keystore option. A name with no such bean is ignored.

String

lazyStartProducer (producer)

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 during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

privateKey (producer)

The private key that the sign operation signs with. A private key found in the keystore under the alias is used instead. The verify operation does not use it.

PrivateKey

privateKeyName (producer)

The name of a java.security.PrivateKey bean in the registry to use as the privateKey option. A name with no such bean is ignored.

String

provider (producer)

The name of the security provider that provides the signature algorithm, for example BC for Bouncy Castle. The provider must be installed. If not set, the first installed provider that supports the algorithm is used.

String

publicKeyName (producer)

The name of a java.security.PublicKey bean in the registry to use as the publicKey option. A name with no such bean is ignored.

String

secureRandomName (producer)

The name of a java.security.SecureRandom bean in the registry to use as the secureRandom option. A name with no such bean is ignored.

String

signatureHeaderName (producer)

The name of the header in which the sign operation stores the Base64 encoded signature, and from which the verify operation reads it. If not set, CamelDigitalSignature is used.

String

autowiredEnabled (advanced)

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 type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

bufferSize (advanced)

The size in bytes of the buffer that reads the message body into the signature. It must be at least 1.

2048

Integer

certificate (advanced)

The certificate whose public key the verify operation checks the signature with. A certificate found in the keystore under the alias is used instead, and this option is used instead of the publicKey option.

Certificate

clearHeaders (advanced)

Whether to remove the headers whose names start with CamelSignature or CamelDigitalSignature after the operation succeeds. The sign operation removes them before it sets the signature header, and the verify operation also removes the signature header when its name matches.

true

boolean

configuration (advanced)

The configuration with the default options of all endpoints. Each endpoint gets a copy of it, and the options of the endpoint change only that copy.

DigitalSignatureConfiguration

keyStoreParameters (advanced)

The KeyStoreParameters (resource, type, password and provider of the keystore) that create the keystore of the keystore option. The keystore is loaded when this option is set.

KeyStoreParameters

publicKey (advanced)

The public key that the verify operation checks the signature with, when neither the keystore nor the certificate option gives a certificate. The sign operation does not use it.

PublicKey

secureRandom (advanced)

The java.security.SecureRandom that the sign operation passes to Signature.initSign. If not set, the signature provider uses its own source of randomness.

SecureRandom

password (security)

The password of the private key entry in the keystore, which the sign operation needs to read the key. It is not the password of the keystore itself.

String

Endpoint Options

The Crypto (JCE) endpoint is configured using URI syntax:

crypto:cryptoOperation:name

With the following path and query parameters:

Path Parameters

Name Description Default Type

cryptoOperation (producer)

Required The operation: sign creates a signature of the message body, and verify checks the signature of the message body. It is the part of the URI after crypto:, as in crypto:sign:name.

Enum values:

  • sign

  • verify

CryptoOperation

name (producer)

Required A name of your choice that tells the endpoints apart, as in crypto:sign:name. The component does not use it.

String

Query Parameters

Name Description Default Type

algorithm (producer)

The standard name of the signature algorithm of the Java Cryptography Architecture, for example SHA256withRSA or SHA256withECDSA. It must match the type of the key, and the sign and verify endpoints must use the same algorithm.

SHA256withRSA

String

alias (producer)

The alias of the keystore entry: the sign operation signs with its private key, and the verify operation verifies with its certificate. If not set and the keystore holds exactly one entry, that entry is used.

String

certificateName (producer)

The name of a java.security.cert.Certificate bean in the registry to use as the certificate option. A name with no such bean is ignored.

String

keystore (producer)

The keystore that holds the private key for the sign operation and the certificate for the verify operation. The alias option selects the entry, or the only entry is used when the keystore holds exactly one. An entry found in the keystore is used instead of the privateKey, certificate and publicKey options.

KeyStore

keystoreName (producer)

The name of a java.security.KeyStore bean in the registry to use as the keystore option. A name with no such bean is ignored.

String

privateKey (producer)

The private key that the sign operation signs with. A private key found in the keystore under the alias is used instead. The verify operation does not use it.

PrivateKey

privateKeyName (producer)

The name of a java.security.PrivateKey bean in the registry to use as the privateKey option. A name with no such bean is ignored.

String

provider (producer)

The name of the security provider that provides the signature algorithm, for example BC for Bouncy Castle. The provider must be installed. If not set, the first installed provider that supports the algorithm is used.

String

publicKeyName (producer)

The name of a java.security.PublicKey bean in the registry to use as the publicKey option. A name with no such bean is ignored.

String

secureRandomName (producer)

The name of a java.security.SecureRandom bean in the registry to use as the secureRandom option. A name with no such bean is ignored.

String

signatureHeaderName (producer)

The name of the header in which the sign operation stores the Base64 encoded signature, and from which the verify operation reads it. If not set, CamelDigitalSignature is used.

String

lazyStartProducer (producer (advanced))

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 during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

bufferSize (advanced)

The size in bytes of the buffer that reads the message body into the signature. It must be at least 1.

2048

Integer

certificate (advanced)

The certificate whose public key the verify operation checks the signature with. A certificate found in the keystore under the alias is used instead, and this option is used instead of the publicKey option.

Certificate

clearHeaders (advanced)

Whether to remove the headers whose names start with CamelSignature or CamelDigitalSignature after the operation succeeds. The sign operation removes them before it sets the signature header, and the verify operation also removes the signature header when its name matches.

true

boolean

keyStoreParameters (advanced)

The KeyStoreParameters (resource, type, password and provider of the keystore) that create the keystore of the keystore option. The keystore is loaded when this option is set.

KeyStoreParameters

publicKey (advanced)

The public key that the verify operation checks the signature with, when neither the keystore nor the certificate option gives a certificate. The sign operation does not use it.

PublicKey

secureRandom (advanced)

The java.security.SecureRandom that the sign operation passes to Signature.initSign. If not set, the signature provider uses its own source of randomness.

SecureRandom

password (security)

The password of the private key entry in the keystore, which the sign operation needs to read the key. It is not the password of the keystore itself.

String

Message Headers

The Crypto (JCE) component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelSignaturePrivateKey (producer)

Constant: SIGNATURE_PRIVATE_KEY

The PrivateKey that should be used to sign the message.

PrivateKey

CamelSignaturePublicKeyOrCert (producer)

Constant: SIGNATURE_PUBLIC_KEY_OR_CERT

The Certificate or PublicKey that should be used to verify the signature. When set, it is used instead of the publicKey, certificate or keystore of the endpoint.

PublicKey

CamelDigitalSignature (producer)

Constant: SIGNATURE

The signature of the message, set by the sign operation and read by the verify operation (the signatureHeaderName option changes the header name).

byte[] (Base64 encoded)

CamelSignatureKeyStoreAlias (producer)

Constant: KEYSTORE_ALIAS

The alias used to query the KeyStore for keys and Certificates to be used in signing and verifying exchanges.

String

CamelSignatureKeyStorePassword (producer)

Constant: KEYSTORE_PASSWORD

The password used to access an aliased PrivateKey in the KeyStore.

char[]

Message Body

The message body at each side of the Crypto (JCE) component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

text, bytes, stream, file or null

The payload to sign or verify, read as a stream: text, bytes, a stream or a file. A Map, a POJO or a number fails: marshal it first. A stream body is cached, so the next step still gets it. No body: sign signs an empty payload, and verify fails with a SignatureException. The signature is not in the body: sign sets it, Base64 encoded, in the CamelDigitalSignature header (signatureHeaderName), which verify reads.

Producer output

unchanged

The body is unchanged: a signature that does not verify fails the exchange with a SignatureException.

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Usage

Raw keys

The most basic way to sign and verify an exchange is with a KeyPair as follows.

Java-only: requires Java KeyPair objects
KeyPair keyPair = KeyGenerator.getInstance("RSA").generateKeyPair();

from("direct:sign")
    .setHeader("CamelSignaturePrivateKey", constant(keyPair.getPrivate()))
    .to("crypto:sign:message")
    .to("direct:verify");

from("direct:verify")
    .setHeader("CamelSignaturePublicKeyOrCert", constant(keyPair.getPublic()))
    .to("crypto:verify:check");

The same can be achieved with the Spring XML Extensions using references to keys

KeyStores and Aliases.

The JCE provides a very versatile keystore concept for housing pairs of private keys and certificates, keeping them encrypted and password protected. They can be retrieved by applying an alias to the retrieval APIs. There are a number of ways to get keys and Certificates into a keystore, most often this is done with the external 'keytool' application.

The following command will create a keystore containing a key and certificate aliased by bob, which can be used in the following examples. The password for the keystore and the key is letmein.

keytool -genkey -keyalg RSA -keysize 2048 -keystore keystore.jks -storepass letmein -alias bob -dname "CN=Bob,OU=IT,O=Camel" -noprompt

The following route first signs an exchange using Bob’s alias from the KeyStore bound into the Camel Registry, and then verifies it using the same alias.

  • Java

  • XML

  • YAML

from("direct:sign")
    .to("crypto:sign:keystoreSign?alias=bob&keystoreName=myKeystore&password=letmein")
    .log("Signature: ${header.CamelDigitalSignature}")
    .to("crypto:verify:keystoreVerify?alias=bob&keystoreName=myKeystore&password=letmein")
    .log("Verified: ${body}");
<route>
  <from uri="direct:sign"/>
  <to uri="crypto:sign:keystoreSign?alias=bob&amp;keystoreName=myKeystore&amp;password=letmein"/>
  <log message="Signature: ${header.CamelDigitalSignature}"/>
  <to uri="crypto:verify:keystoreVerify?alias=bob&amp;keystoreName=myKeystore&amp;password=letmein"/>
  <log message="Verified: ${body}"/>
</route>
- route:
    from:
      uri: direct:sign
      steps:
        - to:
            uri: crypto:sign:keystoreSign
            parameters:
              alias: bob
              keystoreName: myKeystore
              password: letmein
        - log:
            message: "Signature: ${header.CamelDigitalSignature}"
        - to:
            uri: crypto:verify:keystoreVerify
            parameters:
              alias: bob
              keystoreName: myKeystore
              password: letmein
        - log:
            message: "Verified: ${body}"

The following code shows how to load the keystore created using the above keytool command and bind it into the registry with the name myKeystore for use in the above route. The example makes use of the @Configuration and @BindToRegistry annotations introduced in Camel 3 to instantiate the KeyStore and register it with the name myKeyStore.

Java-only: KeyStore bean configuration with `@BindToRegistry`
@Configuration
public class KeystoreConfig {

    @BindToRegistry
    public KeyStore myKeystore() throws Exception {
        KeyStore store = KeyStore.getInstance("JKS");
        try (FileInputStream fis = new FileInputStream("keystore.jks")) {
            store.load(fis, "letmein".toCharArray());
        }
        return store;
    }
}

Again in Spring, a ref is used to look up an actual keystore instance.

Changing JCE Provider and Algorithm

Changing the Signature algorithm or the Security provider is a simple matter of specifying their names. You will need to also use Keys that are compatible with the algorithm you choose.

Changing the Signature Message Header

It may be desirable to change the message header used to store the signature. A different header name can be specified in the route definition as follows

  • Java

  • XML

  • YAML

from("direct:sign")
    .to("crypto:sign:keystoreSign?alias=bob&keystoreName=myKeystore&password=letmein&signatureHeaderName=mySignature")
    .log("Signature: ${header.mySignature}")
    .to("crypto:verify:keystoreVerify?alias=bob&keystoreName=myKeystore&password=letmein&signatureHeaderName=mySignature");
<route>
  <from uri="direct:sign"/>
  <to uri="crypto:sign:keystoreSign?alias=bob&amp;keystoreName=myKeystore&amp;password=letmein&amp;signatureHeaderName=mySignature"/>
  <log message="Signature: ${header.mySignature}"/>
  <to uri="crypto:verify:keystoreVerify?alias=bob&amp;keystoreName=myKeystore&amp;password=letmein&amp;signatureHeaderName=mySignature"/>
</route>
- route:
    from:
      uri: direct:sign
      steps:
        - to:
            uri: crypto:sign:keystoreSign
            parameters:
              alias: bob
              keystoreName: myKeystore
              password: letmein
              signatureHeaderName: mySignature
        - log:
            message: "Signature: ${header.mySignature}"
        - to:
            uri: crypto:verify:keystoreVerify
            parameters:
              alias: bob
              keystoreName: myKeystore
              password: letmein
              signatureHeaderName: mySignature

Changing the bufferSize

In case you need to update the size of the buffer…​

Supplying Keys dynamically.

When using a Recipient list or similar EIP, the recipient of an exchange can vary dynamically. Using the same key across all recipients may be neither feasible nor desirable. It would be useful to be able to specify signature keys dynamically on a per-exchange basis. The exchange could then be dynamically enriched with the key of its target recipient prior to signing. To facilitate this, the signature mechanisms allow for keys to be supplied dynamically via the message headers below

  • CamelSignaturePrivateKey

  • CamelSignaturePublicKeyOrCert

The CamelSignaturePublicKeyOrCert header, when set, wins over the publicKey, certificate or keystore of the crypto:verify endpoint. The CamelSignaturePrivateKey header is used only when the crypto:sign endpoint has no private key (no privateKey, and no keystore with a key for the alias).

Even better would be to dynamically supply a keystore alias. Again, the alias can be supplied in a message header

  • CamelSignatureKeyStoreAlias

The header would be set as follows:

Java-only: Java test API (ProducerTemplate)
Exchange unsigned = getMandatoryEndpoint("direct:alias-sign").createExchange();
unsigned.getIn().setBody(payload);
unsigned.getIn().setHeader("CamelSignatureKeyStoreAlias", "bob");
unsigned.getIn().setHeader("CamelSignatureKeyStorePassword", "letmein".toCharArray());
template.send("direct:alias-sign", unsigned);
Exchange signed = getMandatoryEndpoint("direct:alias-sign").createExchange();
signed.getIn().copyFrom(unsigned.getMessage());
signed.getIn().setHeader("CamelSignatureKeyStoreAlias", "bob");
template.send("direct:alias-verify", signed);

Using Post-Quantum Cryptography (PQC) Algorithms

The Digital Signature EIP supports Post-Quantum Cryptography algorithms through the standard JCE provider mechanism. Since the algorithm and provider options accept any value supported by the underlying JCE implementation, you can use PQC signature algorithms such as ML-DSA (NIST FIPS 204) by registering a Bouncy Castle provider and supplying the corresponding keys.

This approach is useful when you want to apply PQC signatures directly using the crypto:sign / crypto:verify pair without the full camel-pqc component. For hybrid signatures (combining classical + PQC) or key lifecycle management, use the PQC component instead.

Prerequisites

Add the Bouncy Castle provider dependencies to your project:

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk18on</artifactId>
    <version>${bouncycastle.version}</version>
</dependency>
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcpkix-jdk18on</artifactId>
    <version>${bouncycastle.version}</version>
</dependency>

Register the Bouncy Castle provider at application startup:

Java-only: static provider registration
import org.bouncycastle.jce.provider.BouncyCastleProvider;

Security.addProvider(new BouncyCastleProvider());

ML-DSA (NIST FIPS 204)

ML-DSA (Module-Lattice Digital Signature Algorithm, formerly Dilithium) is the primary NIST-standardized post-quantum signature algorithm.

Java DSL

  • Raw keys

  • Dynamic keys via headers

private KeyPair mlDsaKeyPair;

private KeyPair getMlDsaKeyPair() throws Exception {
    if (mlDsaKeyPair == null) {
        KeyPairGenerator kpGen = KeyPairGenerator.getInstance("ML-DSA", "BC");
        kpGen.initialize(MLDSAParameterSpec.ml_dsa_65);
        mlDsaKeyPair = kpGen.generateKeyPair();
    }
    return mlDsaKeyPair;
}

@BindToRegistry("mlDsaPrivateKey")
public PrivateKey mlDsaPrivateKey() throws Exception {
    return getMlDsaKeyPair().getPrivate();
}

@BindToRegistry("mlDsaPublicKey")
public PublicKey mlDsaPublicKey() throws Exception {
    return getMlDsaKeyPair().getPublic();
}

from("direct:sign")
    .to("crypto:sign:pqc?algorithm=ML-DSA&provider=BC&privateKeyName=#mlDsaPrivateKey")
    .to("direct:verify");

from("direct:verify")
    .to("crypto:verify:pqc?algorithm=ML-DSA&provider=BC&publicKeyName=#mlDsaPublicKey")
    .to("mock:result");
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("ML-DSA", "BC");
kpGen.initialize(MLDSAParameterSpec.ml_dsa_65);
KeyPair kp = kpGen.generateKeyPair();

from("direct:sign")
    .setHeader("CamelSignaturePrivateKey", constant(kp.getPrivate()))
    .to("crypto:sign:pqc?algorithm=ML-DSA&provider=BC")
    .to("direct:verify");

from("direct:verify")
    .setHeader("CamelSignaturePublicKeyOrCert", constant(kp.getPublic()))
    .to("crypto:verify:pqc?algorithm=ML-DSA&provider=BC")
    .to("mock:result");

YAML DSL

- route:
    id: sign-route
    from:
      uri: direct:sign
      steps:
        - to:
            uri: crypto:sign:pqc
            parameters:
              algorithm: ML-DSA
              provider: BC
              privateKeyName: "#mlDsaPrivateKey"
        - to:
            uri: direct:verify

- route:
    id: verify-route
    from:
      uri: direct:verify
      steps:
        - to:
            uri: crypto:verify:pqc
            parameters:
              algorithm: ML-DSA
              provider: BC
              publicKeyName: "#mlDsaPublicKey"
        - to:
            uri: mock:result

ML-DSA parameter sets

The following ML-DSA parameter sets are available:

Parameter Set Security Level Signature Size Use Case

ml_dsa_44

NIST Level 2

~2,420 bytes

General-purpose signing

ml_dsa_65

NIST Level 3

~3,309 bytes

Recommended default

ml_dsa_87

NIST Level 5

~4,627 bytes

Highest security

SLH-DSA (NIST FIPS 205)

SLH-DSA (Stateless Hash-Based Digital Signature Algorithm, formerly SPHINCS+) is the secondary NIST-standardized PQC signature algorithm, based on hash functions.

Java-only: requires Java KeyPair and registry binding
private KeyPair slhDsaKeyPair;

private KeyPair getSlhDsaKeyPair() throws Exception {
    if (slhDsaKeyPair == null) {
        KeyPairGenerator kpGen = KeyPairGenerator.getInstance("SLH-DSA", "BC");
        kpGen.initialize(SLHDSAParameterSpec.slh_dsa_sha2_128s);
        slhDsaKeyPair = kpGen.generateKeyPair();
    }
    return slhDsaKeyPair;
}

@BindToRegistry("slhDsaPrivateKey")
public PrivateKey slhDsaPrivateKey() throws Exception {
    return getSlhDsaKeyPair().getPrivate();
}

@BindToRegistry("slhDsaPublicKey")
public PublicKey slhDsaPublicKey() throws Exception {
    return getSlhDsaKeyPair().getPublic();
}

from("direct:sign")
    .to("crypto:sign:pqc?algorithm=SLH-DSA&provider=BC&privateKeyName=#slhDsaPrivateKey")
    .to("direct:verify");

from("direct:verify")
    .to("crypto:verify:pqc?algorithm=SLH-DSA&provider=BC&publicKeyName=#slhDsaPublicKey")
    .to("mock:result");

Hybrid Signatures (Classical + PQC)

For hybrid signatures that combine a classical algorithm (e.g., ECDSA) with a PQC algorithm (e.g., ML-DSA) in a single route, the recommended approach is to use the PQC component which provides built-in hybrid operations.

The camel-pqc component has dedicated hybridSign and hybridVerify operations that produce a single combined signature:

  • Java DSL

  • YAML DSL

from("direct:sign")
    .to("pqc:hybrid?operation=hybridSign"
        + "&signatureAlgorithm=MLDSA"
        + "&classicalSignatureAlgorithm=ECDSA_P256")
    .to("direct:verify");

from("direct:verify")
    .to("pqc:hybrid?operation=hybridVerify"
        + "&signatureAlgorithm=MLDSA"
        + "&classicalSignatureAlgorithm=ECDSA_P256")
    .to("mock:result");
- route:
    id: hybrid-sign-route
    from:
      uri: direct:sign
      steps:
        - to:
            uri: pqc:hybrid
            parameters:
              operation: hybridSign
              signatureAlgorithm: MLDSA
              classicalSignatureAlgorithm: ECDSA_P256
        - to:
            uri: direct:verify

- route:
    id: hybrid-verify-route
    from:
      uri: direct:verify
      steps:
        - to:
            uri: pqc:hybrid
            parameters:
              operation: hybridVerify
              signatureAlgorithm: MLDSA
              classicalSignatureAlgorithm: ECDSA_P256
        - to:
            uri: mock:result

Other hybrid combinations include:

  • ED25519 + MLDSA — Edwards curve + ML-DSA

  • RSA_3072 + MLDSA — RSA 3072-bit + ML-DSA

  • ECDSA_P384 + SLHDSA — ECDSA P-384 + SLH-DSA

See the PQC component for the full list of supported classical algorithms and details on the hybrid wire format.

Chaining crypto: endpoints (manual approach)

Alternatively, you can chain two crypto:sign / crypto:verify endpoints to produce both a classical and a PQC signature, storing each in a separate header:

  • Java

  • XML

  • YAML

from("direct:sign")
    .to("crypto:sign:classical?algorithm=SHA256withECDSA&privateKeyName=#ecPrivateKey&signatureHeaderName=ClassicalSignature")
    .to("crypto:sign:pqc?algorithm=ML-DSA&provider=BC&privateKeyName=#mlDsaPrivateKey&signatureHeaderName=PQCSignature")
    .to("direct:verify");

from("direct:verify")
    .to("crypto:verify:classical?algorithm=SHA256withECDSA&publicKeyName=#ecPublicKey&signatureHeaderName=ClassicalSignature")
    .to("crypto:verify:pqc?algorithm=ML-DSA&provider=BC&publicKeyName=#mlDsaPublicKey&signatureHeaderName=PQCSignature")
    .to("mock:result");
<route>
  <from uri="direct:sign"/>
  <to uri="crypto:sign:classical?algorithm=SHA256withECDSA&amp;privateKeyName=#ecPrivateKey&amp;signatureHeaderName=ClassicalSignature"/>
  <to uri="crypto:sign:pqc?algorithm=ML-DSA&amp;provider=BC&amp;privateKeyName=#mlDsaPrivateKey&amp;signatureHeaderName=PQCSignature"/>
  <to uri="direct:verify"/>
</route>

<route>
  <from uri="direct:verify"/>
  <to uri="crypto:verify:classical?algorithm=SHA256withECDSA&amp;publicKeyName=#ecPublicKey&amp;signatureHeaderName=ClassicalSignature"/>
  <to uri="crypto:verify:pqc?algorithm=ML-DSA&amp;provider=BC&amp;publicKeyName=#mlDsaPublicKey&amp;signatureHeaderName=PQCSignature"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:sign
      steps:
        - to:
            uri: crypto:sign:classical
            parameters:
              algorithm: SHA256withECDSA
              privateKeyName: "#ecPrivateKey"
              signatureHeaderName: ClassicalSignature
        - to:
            uri: crypto:sign:pqc
            parameters:
              algorithm: ML-DSA
              provider: BC
              privateKeyName: "#mlDsaPrivateKey"
              signatureHeaderName: PQCSignature
        - to:
            uri: direct:verify
- route:
    from:
      uri: direct:verify
      steps:
        - to:
            uri: crypto:verify:classical
            parameters:
              algorithm: SHA256withECDSA
              publicKeyName: "#ecPublicKey"
              signatureHeaderName: ClassicalSignature
        - to:
            uri: crypto:verify:pqc
            parameters:
              algorithm: ML-DSA
              provider: BC
              publicKeyName: "#mlDsaPublicKey"
              signatureHeaderName: PQCSignature
        - to:
            uri: mock:result
The chaining approach stores two independent signatures in separate headers, while the PQC component’s hybrid operations produce a single combined signature. For new implementations, the PQC component’s hybrid operations are recommended as they handle the wire format, key management, and verification logic in a single step.

Choosing Between camel-crypto and camel-pqc

Feature camel-crypto (Digital Signature EIP) camel-pqc component

PQC-only signatures

Supported (set algorithm and provider)

Supported (built-in algorithm support)

Hybrid signatures

Manual chaining of two endpoints

Built-in hybridSign / hybridVerify

Key lifecycle management

Not included

Generate, rotate, expire, revoke keys

Key encapsulation (KEM)

Not supported

Built-in support

Additional dependencies

Only Bouncy Castle

Only Bouncy Castle

Best for

Adding PQC to existing crypto: routes

New PQC-focused implementations