ramu11 commented on PR #30945:
URL: https://github.com/apache/camel/pull/30945#issuecomment-7217313741

   > Thanks @ramu11, this is a big step toward what 
[CAMEL-27541](https://issues.apache.org/jira/browse/CAMEL-27541) asks for. The 
default materials are now created lazily, with clear errors instead of 
`ExceptionInInitializerError`; providers are resolved per JCA service instead 
of fixed per algorithm; `Hkdf` reproduces the previous BC output and is checked 
against an RFC 5869 vector; and the 1.86/1.87 notes in `pqc-component.adoc` / 
`pqc-dataformat.adoc` are useful.
   > 
   > I checked the BC claims against `bcprov-jdk18on` 1.86 and 1.87 (the 
version in `parent/pom.xml`) with a small standalone probe. The service map in 
the docs is correct: ML-KEM, CMCE and FrodoKEM have a KEM service in BC; HQC, 
NTRU, NTRULPRime and SNTRUPrime in BCPQC; BIKE and SABER have KeyGenerator 
only. Where an algorithm is in both providers (NTRU, Falcon, LMS, XMSS) both 
use the same SPI classes, so "BC first, then BCPQC" is safe.
   > 
   > **Important**
   > 
   > 1. **The new workflow fails on this PR.** The `compatibility` job 
bootstraps with `-Dquickly -pl components/camel-pqc -am install`, which does 
not install `camel-buildtools`, so the next step (`-Dbouncycastle-version=1.86 
clean test-compile`) fails in `formatter-maven-plugin` with `Could not find 
artifact org.apache.camel:camel-buildtools:jar:4.24.0-SNAPSHOT`. Beyond the 
fix, two design questions, as a component-specific workflow is a project 
decision:
   >    
   >    * It runs on every camel-pqc PR and resolves "latest" from Maven 
Central, so a new BC release could turn unrelated PRs red. Could the latest leg 
run only on `schedule` / `workflow_dispatch`?
   >    * The ticket asked for a _test_ that rejects BC imports. 
`check-camel-pqc-bouncycastle-imports.py` could be a JUnit test that scans 
`src/main/java`, so it runs in the normal build and locally with `mvn test`.
   > 2. **On BC 1.86, PQCDataFormat now derives a different key for HQC, NTRU, 
NTRULPRime and SNTRUPrime.** Without a configured `keyGenerator`, 
`encapsulateKem` / `decapsulateKem` (`PQCDataFormat.java:347-395`) now use the 
JDK `KEM` API (`BouncyCastleKemSupport.java:219`). On 1.86 that path does 
**not** agree with `KeyGenerator` + `KEMGenerateSpec` for these four 
algorithms: my probe gets a different secret in both directions, while ML-KEM, 
CMCE and FrodoKEM agree (on 1.87 all seven agree). On a runtime pinned to 1.86 
(the Quarkus BOM case from the ticket; 1.86 is the PR's "minimum tested" 
version and what [camel-4](https://issues.apache.org/jira/browse/CAMEL-4).22.x 
ships), this breaks (a) messages from Camel 4.22 / pre-PR 4.24, and (b) a 
sender with `keyGenerator` set and a receiver without it, or the other way 
round: the AEAD check fails. `PQCBCVersionBehaviorTest` only exercises the 
KeyGenerator path, so the matrix does not catch it. Could the data format keep 
the KeyGenerator p
 ath when the provider has one, and use the JDK KEM only when there is no 
KeyGenerator service? Otherwise please add a test that crosses the two paths 
and document the 1.86 behaviour.
   > 3. **Upgrade guide.** The public static fields `keyPair` / `signer` / 
`keyGenerator` / `generator` of the `PQCDefault*Material` classes are removed, 
and these classes are documented in `pqc-component.adoc`, so this breaks the 
Java API. Also user-visible: `getBcProvider()` is deprecated and resolved at 
runtime (XMSS, XMSSMT and FALCON now return `BC` instead of `BCPQC`), 
`KeyAlgorithmSupport.getDefaultParameterSpec` now throws instead of returning 
`null`, and the body-type metadata changed to `javax.crypto.SecretKey`. These 
need an entry in the camel-pqc section of `camel-4x-upgrade-guide-4_24.adoc`.
   > 4. **FQCNs**, which CLAUDE.md does not allow: 
`BouncyCastlePqcCompatibility.java:291,331,332,374,381`, 
`PQCKeyEncapsulationAlgorithms.java:54`, `PQCSignatureAlgorithms.java:50`, 
`PQCDataFormat.java:347,363`, and in the new tests (e.g. `java.util.Arrays`, 
`org.junit.jupiter.api.Assumptions`, `java.security.NoSuchAlgorithmException`). 
Please import them and run `mvn formatter:format impsort:sort`.
   > 
   > **Design questions**
   > 
   > 5. Going from "BC imports in one support class" (the ticket's suggestion: 
allow `org.bouncycastle.jcajce` / `jce`) to "no imports, everything through 
reflection" (about 1,200 lines in three new classes) trades a compile-time 
break for a runtime one, and a class name in a string also gets around the 
import fence. For the standardized algorithms BC advertises JCA names such as 
`KeyPairGenerator.getInstance("ML-DSA-65")` / `"ML-KEM-768"`, as the ticket 
suggests, so no `*ParameterSpec` is needed there. Is reflection still needed 
for anything beyond LMS/XMSS and the KEM specs? It would be good to have 
@oscerd's view as he maintains camel-pqc.
   > 6. The ticket's last idea (deprecate or move SABER/NTRU/NTRU LPRime/SNTRU 
Prime) is not addressed. Fine as a separate decision, but please say so in the 
PR description.
   > 
   > **Minor**
   > 
   > * `BouncyCastleSupport.java:112` has an orphan Javadoc ("Package-visible 
seam ...") right before another Javadoc block.
   > * `KeyAlgorithmSupport.java:162` logs at ERROR and then throws; please do 
one or the other.
   > * In `Hkdf.derive` the second `switch` for the hash length repeats the 
first one.
   > * `BouncyCastleSupport.getProvider` calls `ensureProviders()` every time, 
so an enum getter (`getBcProvider(String)`) now registers providers JVM-wide as 
a side effect.
   > * The new workflow has no `if: github.repository == 'apache/camel'` guard 
for the cron.
   > * Commit title: missing space after `CAMEL-27541:`.
   > 
   > The three open gnodet-bot threads are not addressed yet either (redundant 
outer `PQCKemLocks` synchronization, BC imports in `HybridKEMHkdfTest`, the "no 
global caches" Javadoc wording).
   > 
   > _Claude Code on behalf of Claus Ibsen. This review was generated by an AI 
agent and may contain inaccuracies; please verify all suggestions before 
applying._
   
   Thanks @davsclaus for the thorough review. I've pushed a follow-up 
addressing the actionable points, including the BC 1.86 KEM interoperability 
issue, cross-path regression tests, JUnit import fence, provider 
initialization, workflow safeguards, upgrade guide and code cleanup.
   
   Validation passed: Maven compile, install, unit tests and full verify, plus 
the Bouncy Castle 1.86/1.87 compatibility matrix (458 tests per version, no 
failures).
   
   I've kept the broader reflection design and experimental algorithm 
deprecation as separate discussions, as suggested. Thanks again!


-- 
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