oscerd opened a new pull request, #24644:
URL: https://github.com/apache/camel/pull/24644
# CAMEL-23847: Camel-PQC — stream sign/verify for large payloads
## Motivation
`PQCProducer` sign/verify materialised the entire body as a String
(`getMandatoryBody(String.class)`) before feeding it to
`Signature.update()`. For large payloads
(files, large messages) this loaded everything into memory, and for
non-UTF-8 binary payloads the
String round-trip corrupted the data, so verification failed.
## What this does
`signature()` and `verification()` now feed the signature directly from the
message body via an
`updateSignatureFromBody(Signature, Message)` helper:
- a **`byte[]`** body is used as-is;
- an **`InputStream`** body is read in **chunks** (8 KB buffer) — never
fully materialised — and is
**reset** afterwards when it is a re-readable `StreamCache`, so downstream
processors still see
the payload;
- any other body type falls back to its String representation (String
**charset** handling is the
sibling bug **CAMEL-23843**).
The **hybrid** sign/verify variants obtain the payload as a `byte[]` (via
`bodyToByteArray(Message)`)
without a String round-trip (`HybridSignature` needs the full array in
memory).
## Testing
`PQCStreamingSignatureTest` (5 tests, all green):
- `byte[]` sign/verify round trip;
- sign an `InputStream`, verify the same bytes;
- sign bytes, verify an `InputStream`;
- **binary** (non-UTF-8) payloads sign and verify correctly — this fails
with the old String
materialisation;
- a **1 MB** stream signs and verifies within one route (stream caching →
`StreamCache` reset).
## Documentation
`pqc-component.adoc` gains a note on payload streaming under *Signature and
Verification*.
## Backport
None — improvement, `main` only (4.22.0). The related String-charset
correctness fix is tracked
separately as **CAMEL-23843** (a bug, which is the backport candidate).
---
_Claude Code on behalf of Andrea Cosentino._
--
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]