gnodet commented on PR #30777:
URL: https://github.com/apache/camel/pull/30777#issuecomment-7163097585

   Thanks @davsclaus for the thorough review!
   
   **1. Breaking change → upgrade guide + backport**
   
   You are right: `sign()`, `encapsulate()`, and the 2-arg 
`combineSignatures`/`combineEncapsulations` now write v2, so a 4.24 writer 
paired with a pre-4.24 reader will fail. I will add an entry in 
`camel-4x-upgrade-guide-4_24.adoc` covering:
   - The wire format change and mixed-version impact
   - The removed `PQCAlgorithmId` constants (`DILITHIUM`, `SPHINCSPLUS`, 
`PICNIC`, `KYBER`)
   - The `HybridSignatureComponents` and `HybridEncapsulationComponents` record 
constructor changes (2 → 5 args)
   
   For backporting: I will add v2 *reading* only (the auto-detection by magic 
bytes) to the `camel-4.22.x` and `camel-4.18.x` LTS branches. Writing stays v1 
on those branches — the goal is to let an upgraded reader accept v2 blobs 
written by a 4.24 node, without flipping the wire format for existing LTS 
deployments.
   
   **2. Doc fixes**
   
   All confirmed:
   - `"default since Camel 4.19"` / `"Since Camel 4.19"` → `"Since Camel 4.24"` 
in Javadoc and `pqc-hybrid.adoc` (lines 104, 217, 291)
   - `pqc-hybrid.adoc:316`: KYBER (`0x040A`) is listed in the table but the 
constant was removed from the enum — will remove from the table
   - `pqc-hybrid.adoc:395-406`: the `0x03` / KEM DataFormat row in the 
format-types table and the "Writing" bullet claim that `marshal()` produces v2, 
but `PQCDataFormat` still writes the v1 layout `[int len][encap][nonce][ct]`. 
This is the gap the JIRA already names. I will scope it out in the docs: remove 
the `0x03` row from the table, remove `marshal()` from the "Writing" bullet, 
and add a note that the data format retains v1 for now and will migrate in a 
follow-up. The JIRA will track it.
   
   **3. Algorithm IDs not authenticated**
   
   Agreed that the doc snippet at `pqc-hybrid.adoc:354-358` (reading 
`classicalAlgorithmId()` from parsed input and using it to pick a verifier) is 
dangerous guidance. I will add a Javadoc warning to `HybridSignatureComponents` 
and `HybridEncapsulationComponents` making clear the IDs are 
informational/unauthenticated hints and must not be used to select the 
cryptographic operation. I will also update the doc snippet to reflect this.
   
   On whether to actively reject a header ID that does not match 
`fromJcaName(signer.getAlgorithm())`: in Camel's own path the algorithms are 
always configured by the operator, so a mismatch means a bug rather than an 
attack. I will add the validation in `verify()` and `extract()` for 
defence-in-depth (reject header IDs that are not `UNKNOWN` and do not match the 
configured algorithm), and add a test with a tampered ID.
   
   **4. KEM combiner**
   
   Keeping the current construction (`HKDF(ss_classical || ss_pqc, salt=null, 
info=symmetricAlg)`) in v2, with an explicit note in the JIRA and docs that 
ciphertext/public-key binding is deferred. Rationale: the ciphertext and public 
key binding would require a v3 format and significantly more scope (a new 
encapsulate/extract API surface that takes the ciphertext as additional input 
to HKDF). The current construction is what ANSSI and BSI recommend for a 
concatenation-based combiner and is safe against a passive adversary. The 
binding against a re-encapsulation attack is a worthwhile future hardening, but 
adding it here would delay the PR considerably. I will add a comment in the 
code and an explicit statement in the JIRA and in the docs acknowledging this 
trade-off.
   
   **Smaller points**
   
   - `PQCAlgorithmId`: will add a comment that `0x0206`, `0x0208`, `0x0209`, 
and `0x040A` are retired IDs that must never be reused.
   - **Missing tests**: will add:
     - Malformed v2 input cases (header only, `classicalLength` larger than 
remaining, unknown version, wrong format type, empty PQC part)
     - v1 blob through `verify()`/`extract()` end-to-end (not just `parse()`)
     - Valid classical half + garbage PQC half (proves both halves are 
independently checked)
   
   _Claude Code on behalf of Guillaume Nodet_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to