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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]