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


##########
components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java:
##########
@@ -1616,29 +1614,15 @@ private void warnKeyUsageNotRecorded(boolean stateful, 
String reason) {
      * Returns the remaining signatures for a stateful private key, or -1 if 
the key is not stateful.
      */
     static long getStatefulKeyRemaining(PrivateKey privateKey) {
-        if (privateKey instanceof XMSSPrivateKey xmssPrivateKey) {
-            return xmssPrivateKey.getUsagesRemaining();
-        } else if (privateKey instanceof XMSSMTPrivateKey xmssmtPrivateKey) {
-            return xmssmtPrivateKey.getUsagesRemaining();
-        } else if (privateKey instanceof LMSPrivateKey lmsPrivateKey) {
-            return lmsPrivateKey.getUsagesRemaining();
-        }
-        return -1;
+        return 
BouncyCastlePqcCompatibility.getStatefulKeyRemaining(privateKey);

Review Comment:
   Addressed in commit `1c3fdb93bd0c`.
   
   I updated the stateful-key handling to check `privateKey.getAlgorithm()` 
first and only query the compatibility layer for LMS, HSS, XMSS or XMSSMT keys. 
Other algorithms, including ML-DSA, bypass the stateful-key compatibility check 
entirely.
   
   The compatibility methods also safely return the non-stateful fallback when 
the key is null or its algorithm is not one of the supported stateful 
algorithms.
   
   Thanks for highlighting this unnecessary dependency for ordinary signing 
operations.



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