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

   Fixes [CAMEL-25805](https://issues.apache.org/jira/browse/CAMEL-25805).
   
   ## Problem
   
   `doStart()` builds the `Signature` only for the signature operations and the 
`KeyGenerator` only for the KEM ones,
   but `determineOperation()` let the documented `CamelPQCOperation` header 
select any operation:
   
   ```java
   PQCOperations operation = exchange.getIn().getHeader(PQCConstants.OPERATION, 
PQCOperations.class);
   if (operation == null) {
       operation = getConfiguration().getOperation();
   }
   ```
   
   With `operation=sign` on the endpoint and 
`CamelPQCOperation=generateSecretKeyEncapsulation` on the message,
   `keyGeneratorForExchange()` returns the null field and `synchronized 
(generator)` throws:
   
   ```
   java.lang.NullPointerException: Cannot enter synchronized block because 
"generator" is null
   ```
   
   with nothing to indicate the header was the cause. `CamelPQCOperation` is 
public, `@Metadata`-documented API, and no
   test in the module set it at all.
   
   ## Fix
   
   An override is checked against the resources this producer actually holds 
and rejected with a message naming the
   requested operation, the configured one, and what is missing.
   
   Overrides **within** a family, and to the operations that need no key 
material (the lifecycle operations,
   `extractSecretKeyFromEncapsulation`), keep working. Supporting a genuine 
cross-family override would need separate
   key material per family — the component autowires one `keyPair` from 
whichever algorithm option is set, so an
   ML-DSA key pair cannot serve a KEM operation. That is a configuration-model 
change, not a bug fix, so this PR makes
   the failure clear rather than pretending to support it.
   
   ## Two smaller items in the same dispatch path
   
   - the unsupported-operation error now names the operation it rejected, 
instead of a bare `"Unsupported operation"`;
   - an unknown classical signature algorithm was swallowed by an empty `catch` 
with a comment and no log line; it is
     now logged at debug.
   
   ## Header metadata corrections
   
   Two declarations carried the wrong `javaType`, which is mirrored into the 
catalog and the rendered header table:
   
   - `CamelPQCOperation` is read as `PQCOperations`, declared `String`;
   - `CamelPQCSecretKey` is set to a `SecretKey` (`PQCProducer`), declared 
`Boolean` — `HYBRID_SECRET_KEY` already
     declares it correctly.
   
   Runtime values are unchanged. The regenerated `pqc.json` and its catalog 
mirror are included.
   
   ## Tests
   
   New `PQCOperationHeaderOverrideTest`:
   
   - `anOverrideCrossingToTheKemFamilyIsRejectedWithAClearMessage` — against 
`main` this is the NPE above;
   - `anOverrideToTheConfiguredOperationStillWorks`;
   - `anOverrideToAnOperationNeedingNoKeyMaterialIsAllowed` — guards that the 
check is not over-eager;
   - `noHeaderUsesTheConfiguredOperation`.
   
   Full `camel-pqc` build green: 243 tests, 0 failures.
   
   ## Upgrade guide
   
   Added a 4.24 entry for the rejection and the two `javaType` corrections.
   
   ---
   _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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to