ramu11 commented on code in PR #30945:
URL: https://github.com/apache/camel/pull/30945#discussion_r4726752442


##########
components/camel-pqc/src/main/java/org/apache/camel/component/pqc/BouncyCastlePqcAdapterSupport.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.security.GeneralSecurityException;
+import java.security.Provider;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
+
+import org.apache.camel.component.pqc.spi.Bc186PqcAdapter;
+import org.apache.camel.component.pqc.spi.Bc187PqcAdapter;
+import org.apache.camel.component.pqc.spi.PqcBouncyCastleAdapter;
+
+/** Selects a typed, version-specific Bouncy Castle adapter using the 
installed provider version. */
+public final class BouncyCastlePqcAdapterSupport {
+
+    private BouncyCastlePqcAdapterSupport() {
+    }
+
+    public static PqcBouncyCastleAdapter adapter() {
+        final Provider provider;
+        try {
+            provider = BouncyCastleSupport.getProvider("KeyPairGenerator", 
"LMS");
+        } catch (GeneralSecurityException e) {
+            throw new IllegalStateException("Cannot determine the installed 
Bouncy Castle version", e);
+        }
+
+        String version = provider.getVersionStr();
+        ClassLoader providerLoader = provider.getClass().getClassLoader();
+        if (version.equals("1.86") || version.startsWith("1.86.")) {
+            return load(Bc186PqcAdapter.class, "1.86", providerLoader);
+        }
+        if (version.equals("1.87") || version.startsWith("1.87.")) {
+            return load(Bc187PqcAdapter.class, "1.87", providerLoader);
+        }
+        throw new IllegalStateException(

Review Comment:
   Addressed in commit `1c3fdb93bd0c`. I removed the version-gated 
`BouncyCastlePqcAdapterSupport` and the separate version-specific adapter 
modules.
   
   `BouncyCastlePqcCompatibility` now detects the available public JCA API 
capabilities, preferring the newer BC 1.87 types and falling back to the older 
1.86 package aliases. The selected access path is cached in `ApiHolder.API`. 
There is no provider-version string check or hard 1.86/1.87 restriction.
   
   I also updated `PQCProducer` to check the private-key algorithm before 
entering stateful-key handling, so ordinary non-stateful signing does not 
depend on LMS/XMSS compatibility support. Standardized ML-DSA, ML-KEM and CMCE 
parameter sets use JDK `NamedParameterSpec` rather than version-specific BC 
adapters.
   
   If neither stateful API layout is available, stateful-key support is treated 
as unavailable rather than imposing a component-wide version gate.
   
   Thanks for highlighting this architectural issue.



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