You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/10/19 10:32:38 UTC

[PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

oscerd opened a new pull request, #28106:
URL: https://github.com/apache/camel/pull/28106

   Fixes [CAMEL-25802](https://issues.apache.org/jira/browse/CAMEL-25802) — the three items with real behaviour behind
   them. The remaining cosmetic items on that issue are deferred; see the bottom.
   
   ## 1. Five key materials used the provider default RNG
   
   Sixteen of the twenty-one `PQCDefault*Material` classes pass `SecureRandomHelper.getSecureRandom()`. Five did not:
   
   ```java
   kpGen.initialize(FalconParameterSpec.falcon_1024);      // Falcon
   kpGen.initialize(MayoParameterSpec.mayo5);              // MAYO
   kpGen.initialize(SnovaParameterSpec.SNOVA_24_5_5_SHAKE_SSK);  // SNOVA
   kpGen.initialize(new LMSKeyGenParameterSpec(...));      // LMS
   kpGen.initialize(new LMSHSSKeyGenParameterSpec(...));   // HSS
   ```
   
   `SecureRandomHelper` exists precisely to centralise that choice, and `PQCComponent.resolveKeyPair` always seeds — so
   the same algorithm got a different RNG depending on whether `parameterSpec` was set. All twenty-one now seed from
   the shared helper. No key format or parameter set changes.
   
   ## 2. `parameterSpec` was refused for MAYO and SNOVA on a false premise
   
   ```java
    * algorithms (XMSS, XMSSMT, LMS, HSS) and MAYO/SNOVA have no name-addressable BouncyCastle parameter spec and are
    * therefore not supported here
   ```
   
   Verified against `bcprov-jdk18on-1.86.jar`:
   
   ```
   public static org.bouncycastle.pqc.jcajce.spec.MayoParameterSpec fromName(java.lang.String);
   public static org.bouncycastle.pqc.jcajce.spec.SnovaParameterSpec fromName(java.lang.String);
   ```
   
   Both exist, and neither algorithm is stateful, so the exclusion had no basis — MAYO and SNOVA users were locked to
   one hardcoded security level with no way to pick another short of registering their own `KeyPair` bean. Both are now
   resolvable. The stateful hash-based algorithms remain excluded, correctly: `XMSSParameterSpec` genuinely has no
   `fromName`.
   
   `PQCParameterSpecResolverTest` asserted `assertFalse(isSupported("MAYO"))`, encoding the wrong premise; updated.
   
   ## 3. Two aliases were told to switch to themselves
   
   `DILITHIUM` and `SPHINCSPLUS` were in `NON_FIPS_PQ_SIGNATURES`, which drives:
   
   > PQC signature algorithm {} is not part of NIST FIPS 204/205. Consider using ML-DSA (FIPS 204) or SLH-DSA (FIPS 205)
   > for production hybrid deployments.
   
   But `DILITHIUM("ML-DSA", "BC")` and `SPHINCSPLUS("SLH-DSA", "BC")` resolve to precisely those algorithms — the module
   already says so in `PQCParameterSpecResolver`. Both are removed from the set. `FALCON`, `MAYO`, `SNOVA`, `XMSS` and
   `XMSSMT` still warn.
   
   ## Tests
   
   New `PQCMaterialConsistencyTest` guards the rules rather than the instances, so the next clone-and-tweak cannot
   reintroduce the drift: it walks the material sources asserting every one seeds from `SecureRandomHelper`, checks
   MAYO/SNOVA resolve every documented level while the stateful algorithms still do not, and asserts the two aliases
   stay out of the non-FIPS set.
   
   Full `camel-pqc` build green: 245 tests, 0 failures.
   
   ## Deferred from the umbrella issue
   
   Left out deliberately, as cosmetic or needing a separate decision:
   
   - **Residual `"BCPQC"` provider strings** on 12 enum constants. I verified in BC 1.86 that `FALCON`, `XMSS` and
     `XMSSMT` are registered identically under both `BC` and `BCPQC`, so this is naming inconsistency with no
     behavioural effect.
   - **The `label` `@UriPath`** — declared `required = true` with no getter, no setter, and `createEndpoint` never
     reading `remaining`. Making it bindable or dropping it both change the published catalog, so it wants its own call.
   - **Metrics coverage and the missing class Javadoc** on the 21 material classes — additive work rather than a fix.
   
   The structural fix the issue really points at is replacing the clone-and-tweak material classes with one
   parameterised factory driven by `PQCParameterSpecResolver`; that would remove this whole defect class, along with
   the missing-switch-arm family behind #28098. Worth a separate discussion.
   
   ---
   _Reported, analysed and fixed by Claude Code (AI agent) on behalf of @oscerd._
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #28106:
URL: https://github.com/apache/camel/pull/28106


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28106:
URL: https://github.com/apache/camel/pull/28106#issuecomment-6273488909

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `catalog/camel-catalog`
   - `components/camel-pqc`
   - `docs`
   - `dsl/camel-componentdsl`
   - `dsl/camel-endpointdsl`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 8 of 707 tested, 23 compile-only — current: 8 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **8 affected modules** (current approach: 8).
   
   **Skip-tests mode would test 8 modules** (5 direct + 7 downstream), **skip tests for 23** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (8)</summary>
   
   - `camel-jbang-mcp` ← downstream of org.apache.camel:camel-catalog
   - `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-catalog
   - `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-yaml-dsl-validator
   - `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
   - `camel-pqc` ← components/camel-pqc/src/generated/resources/META-INF/org/apache/camel/component/pqc/pqc.json, components/camel-pqc/src/main/docs/pqc-component.adoc, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCConfiguration.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCParameterSpecResolver.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultFalconMaterial.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultHSSMaterial.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultLMSMaterial.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultMAYOMaterial.java, components/camel-pqc/src/main/java/org/apache/camel/component/pqc/crypto/PQCDefaultSNOVAMaterial.java, components/camel-pqc/src/test/java/org/apache/
 camel/component/pqc/PQCMaterialConsistencyTest.java, components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCParameterSpecResolverTest.java
   - `camel-yaml-dsl-validator` ← downstream of org.apache.camel:camel-catalog
   - `camel-yaml-dsl-validator-maven-plugin` ← downstream of org.apache.camel:camel-yaml-dsl-validator
   
   </details>
   
   <details><summary>Modules with tests skipped (23)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog-console`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `dummy-component`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   <details><summary>All tested modules (35 modules, 5m 38s total)</summary>
   
   **Total reactor time:** 5m 38s
   
   | Module | Duration | Status |
   | --- | --- | --- |
   | Camel :: Launcher | 49.0s | SUCCESS |
   | Camel :: Component DSL | 45.7s | SUCCESS |
   | Camel :: JBang :: MCP | 40.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: Validate | 29.7s | SUCCESS |
   | Camel :: YAML DSL | 23.6s | SUCCESS |
   | Camel :: Catalog :: Camel Catalog | 22.9s | SUCCESS |
   | Camel :: YAML DSL :: Validator | 18.2s | SUCCESS |
   | Camel :: Docs | 15.0s | SUCCESS |
   | Camel :: JBang :: Plugin :: Kubernetes | 11.9s | SUCCESS |
   | Camel :: Kamelet Main | 11.6s | SUCCESS |
   | Camel :: JBang :: Plugin :: Testing | 10.3s | SUCCESS |
   | Camel :: YAML DSL :: Validator Maven Plugin | 9.0s | SUCCESS |
   | Camel :: YAML DSL :: Deserializers | 8.2s | SUCCESS |
   | Camel :: Catalog :: Camel Route Parser | 7.6s | SUCCESS |
   | Camel :: Catalog :: Camel Report Maven Plugin | 6.8s | SUCCESS |
   | Camel :: Catalog :: Suggest (deprecated) | 5.9s | SUCCESS |
   | Camel :: All Components Sync point | 5.4s | SUCCESS |
   | Camel :: YAML DSL :: Maven Plugins | 2.6s | SUCCESS |
   | Camel :: Catalog :: Maven | 2.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: Edit | 1.9s | SUCCESS |
   | Camel :: Assembly | 1.4s | SUCCESS |
   | Camel :: Catalog :: Dummy Component | 1.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: Generate | 1.2s | SUCCESS |
   | Camel :: Coverage | 1.2s | SUCCESS |
   | Camel :: JBang :: Integration tests | 1.1s | SUCCESS |
   | Camel :: Catalog :: Console | 0.9s | SUCCESS |
   | Camel :: Endpoint DSL :: Support | 0.8s | SUCCESS |
   | Camel :: Launcher :: Container | 0.7s | SUCCESS |
   | Camel :: JBang :: Main | 0.7s | SUCCESS |
   | Camel :: JBang :: Plugin :: MCP | 0.5s | SUCCESS |
   | Camel :: Endpoint DSL | n/a |  |
   | Camel :: Integration Tests | n/a |  |
   | Camel :: JBang :: Core | n/a |  |
   | Camel :: JBang :: Plugin :: TUI | n/a |  |
   | Camel :: PQC | n/a |  |
   
   **Top 20 slowest modules:**
   - `Camel :: Launcher` (49.0s)
   - `Camel :: Component DSL` (45.7s)
   - `Camel :: JBang :: MCP` (40.2s)
   - `Camel :: JBang :: Plugin :: Validate` (29.7s)
   - `Camel :: YAML DSL` (23.6s)
   - `Camel :: Catalog :: Camel Catalog` (22.9s)
   - `Camel :: YAML DSL :: Validator` (18.2s)
   - `Camel :: Docs` (15.0s)
   - `Camel :: JBang :: Plugin :: Kubernetes` (11.9s)
   - `Camel :: Kamelet Main` (11.6s)
   - `Camel :: JBang :: Plugin :: Testing` (10.3s)
   - `Camel :: YAML DSL :: Validator Maven Plugin` (9.0s)
   - `Camel :: YAML DSL :: Deserializers` (8.2s)
   - `Camel :: Catalog :: Camel Route Parser` (7.6s)
   - `Camel :: Catalog :: Camel Report Maven Plugin` (6.8s)
   - `Camel :: Catalog :: Suggest (deprecated)` (5.9s)
   - `Camel :: All Components Sync point` (5.4s)
   - `Camel :: YAML DSL :: Maven Plugins` (2.6s)
   - `Camel :: Catalog :: Maven` (2.2s)
   - `Camel :: JBang :: Plugin :: Edit` (1.9s)
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/39277478860)


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #28106:
URL: https://github.com/apache/camel/pull/28106#discussion_r4312881608


##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMaterialConsistencyTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Guards the consistency rules the sibling key material classes are meant to follow but drifted away from, so the next
+ * clone-and-tweak does not reintroduce the divergence.
+ */
+class PQCMaterialConsistencyTest {
+
+    private static Path materialSourceRoot() throws URISyntaxException {
+        // the tests run from the module directory, so the sources sit at a fixed relative path
+        Path root = Paths.get("src/main/java/org/apache/camel/component/pqc/crypto");
+        assertTrue(Files.isDirectory(root), "cannot locate the key material sources at " + root.toAbsolutePath());
+        return root;
+    }
+
+    private static List<Path> materialSources() throws Exception {
+        List<Path> sources = new ArrayList<>();
+        try (Stream<Path> files = Files.walk(materialSourceRoot())) {
+            files.filter(p -> p.getFileName().toString().startsWith("PQCDefault"))
+                    .filter(p -> p.getFileName().toString().endsWith("Material.java"))
+                    .forEach(sources::add);
+        }
+        assertFalse(sources.isEmpty(), "no key material sources found");
+        return sources;
+    }
+
+    @Test
+    void everyKeyMaterialSeedsItsGeneratorWithSecureRandomHelper() throws Exception {
+        List<String> offenders = new ArrayList<>();
+        for (Path source : materialSources()) {
+            String text = Files.readString(source, StandardCharsets.UTF_8);
+            if (!text.contains("SecureRandomHelper.getSecureRandom()")) {
+                offenders.add(source.getFileName().toString());
+            }
+        }
+
+        assertTrue(offenders.isEmpty(),
+                "these key material classes fall back to the provider default RNG instead of the shared"
+                                        + " SecureRandomHelper: " + offenders);
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = { "MAYO", "SNOVA" })
+    void mayoAndSnovaAcceptANamedParameterSet(String algorithm) {
+        assertTrue(PQCParameterSpecResolver.isSupported(algorithm),
+                algorithm + " has a name-addressable BouncyCastle parameter spec and must accept parameterSpec");
+    }
+
+    @Test
+    void mayoResolvesEveryDocumentedLevel() {
+        for (String name : new String[] { "mayo1", "mayo2", "mayo3", "mayo5" }) {
+            assertTrue(PQCParameterSpecResolver.resolve("MAYO", name).toString().toLowerCase().contains("mayo"),
+                    "MAYO must resolve " + name);

Review Comment:
   ⚠️ **Fragile assertion + latent NPE risk.** This assertion works today only by accident: `MayoParameterSpec` has no `toString()` override, so `Object.toString()` returns `org.bouncycastle.pqc.jcajce.spec.MayoParameterSpec@<hash>` — the class name happens to contain `"mayo"` after `.toLowerCase()`. If BouncyCastle ever adds a `toString()` that doesn't include the word `"mayo"`, this test silently breaks.
   
   More critically: `MayoParameterSpec.fromName()` is a map lookup that returns **`null`** for unknown parameter-set names (it does not throw). If `doResolve()` returns null (e.g. because a new MAYO level name isn't in the map yet), `.toString()` will NPE instead of failing with a meaningful assertion message.
   
   `MayoParameterSpec` exposes `getName()` which returns the canonical level name (`"mayo1"`, `"mayo2"`, etc.). Use that:
   
   ```suggestion
           for (String name : new String[] { "mayo1", "mayo2", "mayo3", "mayo5" }) {
               AlgorithmParameterSpec spec = PQCParameterSpecResolver.resolve("MAYO", name);
               assertNotNull(spec, "MAYO must resolve " + name);
               assertInstanceOf(MayoParameterSpec.class, spec,
                       "MAYO must resolve to MayoParameterSpec for " + name);
               assertEquals(name, ((MayoParameterSpec) spec).getName(),
                       "resolved MAYO parameter set name must match requested " + name);
           }
   ```



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #28106:
URL: https://github.com/apache/camel/pull/28106#discussion_r4314494687


##########
components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCParameterSpecResolver.java:
##########
@@ -120,6 +122,10 @@ private static AlgorithmParameterSpec doResolve(String algorithm, String paramet
                 return MLDSAParameterSpec.fromName(parameterSpec);
             case "SPHINCSPLUS":
                 return SLHDSAParameterSpec.fromName(parameterSpec);
+            case "MAYO":
+                return MayoParameterSpec.fromName(parameterSpec);
+            case "SNOVA":

Review Comment:
   Confirmed and fixed in 1157864. I reproduced it against bcprov 1.86 before changing anything:
   
   ```
   Snova  SNOVA_24_5_5_SHAKE_SSK -> SNOVA_24_5_5_SHAKE_SSK
   Snova  SNOVA-24-5-5-SHAKE-SSK -> null
   Snova  snova_24_5_5_shake_ssk -> SNOVA_24_5_5_SHAKE_SSK
   Mayo   mayo1 -> MAYO-1
   Mayo   MAYO-1 -> MAYO-1
   Mayo   mayo_1 -> MAYO-1
   ```
   
   So I had advertised SNOVA support while making every SNOVA name unreachable, which is worse than the refusal it replaced. The name is now tried as written first and the dash rewrite is only a fallback, which keeps the `ml_dsa_87` alias working for the specs that need it.
   
   _Claude Code on behalf of @oscerd_



##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMaterialConsistencyTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.bouncycastle.pqc.jcajce.spec.MayoParameterSpec;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Guards the consistency rules the sibling key material classes are meant to follow but drifted away from, so the next
+ * clone-and-tweak does not reintroduce the divergence.
+ */
+class PQCMaterialConsistencyTest {
+
+    private static Path materialSourceRoot() throws URISyntaxException {
+        // the tests run from the module directory, so the sources sit at a fixed relative path
+        Path root = Paths.get("src/main/java/org/apache/camel/component/pqc/crypto");
+        assertTrue(Files.isDirectory(root), "cannot locate the key material sources at " + root.toAbsolutePath());
+        return root;
+    }
+
+    private static List<Path> materialSources() throws Exception {
+        List<Path> sources = new ArrayList<>();
+        try (Stream<Path> files = Files.walk(materialSourceRoot())) {
+            files.filter(p -> p.getFileName().toString().startsWith("PQCDefault"))
+                    .filter(p -> p.getFileName().toString().endsWith("Material.java"))
+                    .forEach(sources::add);
+        }
+        assertFalse(sources.isEmpty(), "no key material sources found");
+        return sources;
+    }
+
+    @Test
+    void everyKeyMaterialSeedsItsGeneratorWithSecureRandomHelper() throws Exception {
+        List<String> offenders = new ArrayList<>();
+        for (Path source : materialSources()) {
+            String text = Files.readString(source, StandardCharsets.UTF_8);
+            if (!text.contains("SecureRandomHelper.getSecureRandom()")) {
+                offenders.add(source.getFileName().toString());
+            }
+        }
+
+        assertTrue(offenders.isEmpty(),
+                "these key material classes fall back to the provider default RNG instead of the shared"
+                                        + " SecureRandomHelper: " + offenders);
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = { "MAYO", "SNOVA" })
+    void mayoAndSnovaAcceptANamedParameterSet(String algorithm) {

Review Comment:
   Right — `isSupported` alone was not enough, which is precisely why the underscore mapping slipped through. Fixed in 1157864.
   
   The parameterised test now covers both algorithms and asserts the level that comes back, including `SNOVA,SNOVA_24_5_5_SHAKE_SSK,SNOVA_24_5_5_SHAKE_SSK` and the lowercase spelling. It fails against the previous commit.
   
   _Claude Code on behalf of @oscerd_



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on PR #28106:
URL: https://github.com/apache/camel/pull/28106#issuecomment-6265352633

   💡 **Minor: no SNOVA level coverage in the new test** (low severity)
   
   `mayoResolvesEveryDocumentedLevel` checks all four MAYO parameter sets. SNOVA has its own set of named parameter specs in BC 1.86 (`SNOVA_24_5_5_SHAKE_SSK`, `SNOVA_37_8_4_SHAKE_SSK`, etc. — accessible via `SnovaParameterSpec.fromName()`). The PR description claims SNOVA is now fully resolvable, but the test only verifies that `SNOVA` is supported (via the parameterized `mayoAndSnovaAcceptANamedParameterSet` test) — it doesn't verify any named level actually resolves.
   
   Consider adding a `snovaResolvesEveryDocumentedLevel` test parallel to the MAYO one, asserting at minimum one or two well-known SNOVA levels resolve to a non-null `SnovaParameterSpec` instance.
   
   _This comment was generated by an AI agent, Hermès on behalf of @gnodet._
   
   <!-- reviewer: gnodet-bot -->


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #28106:
URL: https://github.com/apache/camel/pull/28106#discussion_r4313368531


##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMaterialConsistencyTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Guards the consistency rules the sibling key material classes are meant to follow but drifted away from, so the next
+ * clone-and-tweak does not reintroduce the divergence.
+ */
+class PQCMaterialConsistencyTest {
+
+    private static Path materialSourceRoot() throws URISyntaxException {
+        // the tests run from the module directory, so the sources sit at a fixed relative path
+        Path root = Paths.get("src/main/java/org/apache/camel/component/pqc/crypto");
+        assertTrue(Files.isDirectory(root), "cannot locate the key material sources at " + root.toAbsolutePath());
+        return root;
+    }
+
+    private static List<Path> materialSources() throws Exception {
+        List<Path> sources = new ArrayList<>();
+        try (Stream<Path> files = Files.walk(materialSourceRoot())) {
+            files.filter(p -> p.getFileName().toString().startsWith("PQCDefault"))
+                    .filter(p -> p.getFileName().toString().endsWith("Material.java"))
+                    .forEach(sources::add);
+        }
+        assertFalse(sources.isEmpty(), "no key material sources found");
+        return sources;
+    }
+
+    @Test
+    void everyKeyMaterialSeedsItsGeneratorWithSecureRandomHelper() throws Exception {
+        List<String> offenders = new ArrayList<>();
+        for (Path source : materialSources()) {
+            String text = Files.readString(source, StandardCharsets.UTF_8);
+            if (!text.contains("SecureRandomHelper.getSecureRandom()")) {
+                offenders.add(source.getFileName().toString());
+            }
+        }
+
+        assertTrue(offenders.isEmpty(),
+                "these key material classes fall back to the provider default RNG instead of the shared"
+                                        + " SecureRandomHelper: " + offenders);
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = { "MAYO", "SNOVA" })
+    void mayoAndSnovaAcceptANamedParameterSet(String algorithm) {
+        assertTrue(PQCParameterSpecResolver.isSupported(algorithm),
+                algorithm + " has a name-addressable BouncyCastle parameter spec and must accept parameterSpec");
+    }
+
+    @Test
+    void mayoResolvesEveryDocumentedLevel() {
+        for (String name : new String[] { "mayo1", "mayo2", "mayo3", "mayo5" }) {
+            assertTrue(PQCParameterSpecResolver.resolve("MAYO", name).toString().toLowerCase().contains("mayo"),
+                    "MAYO must resolve " + name);

Review Comment:
   Both points were right — fixed in 996df4a.
   
   The assertion now checks non-null, the spec type, and the resolved level via `getName()`.
   
   One adjustment to the suggested snippet: `getName()` answers the canonical form rather than echoing the requested name, so `assertEquals(name, spec.getName())` fails with `expected: <mayo1> but was: <MAYO-1>`. The test is now a `@CsvSource` pinning each requested name to its canonical result (`mayo1,MAYO-1` and so on), which has the side benefit of verifying that the level requested is the level returned, not merely that something resolved.
   
   _Claude Code on behalf of @oscerd_



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #28106:
URL: https://github.com/apache/camel/pull/28106#issuecomment-6290362453

   Rebased onto `main`. The only conflict was the 4.24 upgrade guide, where several camel-pqc PRs had added their note at the same spot; this one now sits before the `camel-cli-connector - every action with a request id gets an answer` section, at a different place from the other open camel-pqc PRs, so they stop conflicting with each other. `pqc-component.adoc` and its catalog mirror merged cleanly. No code change.
   
   Verification: camel-pqc on JDK 21 (`mvn clean install`) and JDK 25 (`mvn test`: 287 tests, 0 failures); reactor from camel-pqc through the catalog and DSL modules `BUILD SUCCESS`, the generated `pqc.json`, `PQCEndpointBuilderFactory` and `PqcComponentBuilderFactory` unchanged by the regeneration.
   
   _Claude Code on behalf of oscerd_
   


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28106:
URL: https://github.com/apache/camel/pull/28106#issuecomment-6270807827

   <!-- regen-patch -->
   ### :warning: Generated files are out of date
   
   The [CI build](https://github.com/apache/camel/actions/runs/39261568742) regenerated files that are not committed on this PR.
   
   If *Allow edits from maintainers* is enabled, a maintainer bot will automatically
   push a "Regen" commit to this branch shortly.
   
   Otherwise, you can apply the patch manually — the missing changes are available
   as the `regen-patch` artifact of that run:
   
   ```bash
   gh pr checkout 28106 --repo apache/camel
   gh run download 39261568742 --repo apache/camel -n regen-patch
   git apply --index regen.patch && rm regen.patch pr-number
   git commit -m "Regen" && git push
   ```
   
   Alternatively, run `./etc/scripts/regen.sh` locally and commit the resulting changes.
   If the patch does not apply cleanly, update the branch from the base branch first —
   the patch was generated against the merge with the base branch.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #28106:
URL: https://github.com/apache/camel/pull/28106#discussion_r4313848493


##########
components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCParameterSpecResolver.java:
##########
@@ -120,6 +122,10 @@ private static AlgorithmParameterSpec doResolve(String algorithm, String paramet
                 return MLDSAParameterSpec.fromName(parameterSpec);
             case "SPHINCSPLUS":
                 return SLHDSAParameterSpec.fromName(parameterSpec);
+            case "MAYO":
+                return MayoParameterSpec.fromName(parameterSpec);
+            case "SNOVA":

Review Comment:
   This lookup gets the name after `parameterSpec.replace('_', '-')`, so a SNOVA name never matches. BC's SNOVA names keep their underscores (`SNOVA_24_5_5_SHAKE_SSK`), and the dashed form returns `null`, which then fails as "Unknown parameterSpec".



##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMaterialConsistencyTest.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.bouncycastle.pqc.jcajce.spec.MayoParameterSpec;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Guards the consistency rules the sibling key material classes are meant to follow but drifted away from, so the next
+ * clone-and-tweak does not reintroduce the divergence.
+ */
+class PQCMaterialConsistencyTest {
+
+    private static Path materialSourceRoot() throws URISyntaxException {
+        // the tests run from the module directory, so the sources sit at a fixed relative path
+        Path root = Paths.get("src/main/java/org/apache/camel/component/pqc/crypto");
+        assertTrue(Files.isDirectory(root), "cannot locate the key material sources at " + root.toAbsolutePath());
+        return root;
+    }
+
+    private static List<Path> materialSources() throws Exception {
+        List<Path> sources = new ArrayList<>();
+        try (Stream<Path> files = Files.walk(materialSourceRoot())) {
+            files.filter(p -> p.getFileName().toString().startsWith("PQCDefault"))
+                    .filter(p -> p.getFileName().toString().endsWith("Material.java"))
+                    .forEach(sources::add);
+        }
+        assertFalse(sources.isEmpty(), "no key material sources found");
+        return sources;
+    }
+
+    @Test
+    void everyKeyMaterialSeedsItsGeneratorWithSecureRandomHelper() throws Exception {
+        List<String> offenders = new ArrayList<>();
+        for (Path source : materialSources()) {
+            String text = Files.readString(source, StandardCharsets.UTF_8);
+            if (!text.contains("SecureRandomHelper.getSecureRandom()")) {
+                offenders.add(source.getFileName().toString());
+            }
+        }
+
+        assertTrue(offenders.isEmpty(),
+                "these key material classes fall back to the provider default RNG instead of the shared"
+                                        + " SecureRandomHelper: " + offenders);
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = { "MAYO", "SNOVA" })
+    void mayoAndSnovaAcceptANamedParameterSet(String algorithm) {

Review Comment:
   `isSupported` passes for SNOVA, but no test resolves a SNOVA name, which is why the underscore mapping in `resolve()` went unnoticed. A `SNOVA` row in the `@CsvSource` test would catch it.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25802: camel-pqc - align the key material classes and correct two false premises [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28106:
URL: https://github.com/apache/camel/pull/28106#issuecomment-6265336996

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org