James Netherton created CAMEL-27541:
---------------------------------------
Summary: camel-pqc - make the component resilient to Bouncy
Castle version changes
Key: CAMEL-27541
URL: https://issues.apache.org/jira/browse/CAMEL-27541
Project: Camel
Issue Type: Improvement
Components: camel-pqc
Reporter: James Netherton
camel-pqc is tightly coupled to Bouncy Castle (BC) internals. Each BC upgrade
risks breaking it: algorithms get removed or deprecated, packages move,
algorithms move from the BCPQC provider to BC, and algorithm behaviour changes.
The 1.87 upgrade (CAMEL-27309) hit all of these:
- it removed org.bouncycastle.pqc.crypto.lms and .xmss
- CMCE was deprecated
- existing HQC keys no longer work with the new code
- NTRU, NTRU LPRime and SNTRU Prime now apply a KDF
Runtimes that get the BC version independently of Camel, such as Camel Quarkus
through quarkus-bom, can end up on a different BC version than Camel was built
and tested with. When that happens camel-pqc can fail at runtime.
Current exposure:
- About 35 classes import BC types, some from internal packages rather than the
public JCA API (org.bouncycastle.crypto.*).
- The PQCDefault*Material classes generate keys in static {} blocks. A missing
or changed algorithm then shows up as an ExceptionInInitializerError, not a
clear error.
- PQCKeyEncapsulationAlgorithms and PQCSignatureAlgorithms fix the provider (BC
or BCPQC) for each algorithm, so they break when BC moves an algorithm to the
other provider.
- Nothing detects BC behaviour changes that make stored keys or ciphertexts
incompatible.
Some ideas that could potentially help:
* Resolve algorithms and parameter sets by JCA name (e.g.
KeyPairGenerator.getInstance("ML-DSA-65")) instead of BC *ParameterSpec
constants. Check availability with Provider.getService(...) so a missing
algorithm gives a clear per-algorithm error.
* Put the BC-specific code that must stay (KEM specs, LMS/XMSS key interfaces,
HKDF) in one support class. Consider the JDK javax.crypto.KEM API where BC
supports it. Add a test that rejects imports outside org.bouncycastle.jcajce /
org.bouncycastle.jce.
* Create the default key material lazily on first use, not in static
initializers.
* Find the provider at runtime (try BC, then BCPQC) instead of fixing it per
algorithm.
* Consider deprecating the non-standardized KEMs that NIST dropped (SABER,
NTRU, NTRU LPRime, SNTRU Prime), or moving them to an opt-in module. These
cause most of the churn. This needs a project decision.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)