Andrea Cosentino created CAMEL-25824:
----------------------------------------
Summary: camel-pqc - the hybrid KEM operations stamp the enum name
on the secret key instead of the JCE name
Key: CAMEL-25824
URL: https://issues.apache.org/jira/browse/CAMEL-25824
Project: Camel
Issue Type: Bug
Components: camel-pqc
Reporter: Andrea Cosentino
The hybrid key encapsulation operations stamp the raw enum name on the derived
secret key, while {{hybridExtractSecretKeyFromEncapsulation}} maps it through
the enum. The two ends of a hybrid exchange therefore disagree for the two
algorithms whose enum name differs from the JCE name, in the same way
CAMEL-25798 fixed for the non-hybrid operations.
{{PQCProducer}} (around lines 846 and 890):
{code:java}
String symmetricAlgorithm = getConfiguration().getSymmetricKeyAlgorithm();
{code}
is handed straight to {{HybridKEM.encapsulate}} / {{HybridKEM.extract}}, so
{{DESEDE}} and {{GOST3412_2015}} reach the {{SecretKeySpec}} as the enum name,
which is not a resolvable cipher algorithm.
h3. Care needed
This is *not* the same one-line change as CAMEL-25798. {{HybridKEM}} uses that
same string twice:
# as the algorithm of the returned {{SecretKeySpec}} - this is the label that
should be mapped;
# as the HKDF {{info}} input of {{combineSecrets}} - changing this changes the
derived key, and would break interoperability with every previously produced
encapsulation.
So only the label may be mapped. The HKDF info must keep whatever value it has
today, or the change becomes a wire-format break.
h3. Suggested approach
Map the name at the point the {{SecretKeySpec}} is constructed inside
{{HybridKEM}}, leaving the value passed to {{combineSecrets}} untouched, and
add a round-trip test with {{symmetricKeyAlgorithm=DESEDE}} asserting that the
generate and extract ends agree and that the stamped name resolves through
{{Cipher.getInstance}}.
Reported by [~davsclaus] while reviewing the CAMEL-25798 pull request
(https://github.com/apache/camel/pull/28093).
----
_Reported by Claude Code (AI agent) on behalf of [~oscerd]._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)