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

   ## Summary
   
   Migrate `PQCDataFormat` from the legacy v1 wire format to the same 
self-describing v2 header
   already used by `HybridKEM` and `HybridSignature` (introduced in 
CAMEL-25803).
   
   ## Wire Format
   
   **v2 header (8 bytes, new writes):**
   ```
   [0x50 0x51][version 0x01][format 0x01][kemAlgId 2B][symAlgId 2B]
   ```
   Followed by: `[4B encap len][encap][12B nonce][ciphertext+tag]`
   
   **v1 (legacy, read-only):**
   ```
   [4B encap len][encap][12B nonce][ciphertext+tag]
   ```
   
   ## Changes
   
   **`PQCDataFormat.java`**
   - `marshal()`: writes the 8-byte v2 header using `PQCAlgorithmId` constants 
before the existing encapsulation/nonce/ciphertext payload.
   - `unmarshal()`: uses a `PushbackInputStream` to peek at the first 2 bytes; 
routes to `unmarshalV2()` on `0x50 0x51` magic, falls back to `unmarshalV1()` 
otherwise.
   - Added `unmarshalV2()`, `unmarshalV1()`, `decryptPayload()`, and 
`lookupKemAlgId()` helpers.
   - Added header constants (`MAGIC_BYTE_0`, `MAGIC_BYTE_1`, `WIRE_VERSION`, 
`FORMAT_TYPE_KEM`, `HEADER_LENGTH`) with package-private visibility for use in 
tests.
   - Updated class Javadoc to document both wire formats.
   
   **`PQCDataFormatWireFormatTest.java`** (new)
   - `marshalWritesV2Header`: verifies magic bytes, version, format type, and 
algorithm IDs in the written header.
   - `v2RoundTrip`: full marshal/unmarshal round-trip using the new format.
   - `v1BackwardCompatibility`: hand-crafted v1 message decrypts correctly 
(backward compat).
   
   **`PQCDataFormatConcurrencyTest.java`**
   - `encapsulationOf()`: updated to skip the 8-byte v2 header before reading 
the encapsulation length.
   
   **`camel-4x-upgrade-guide-4_24.adoc`**
   - Documents the wire format change and backward-compatibility guarantee.
   
   ## Backward Compatibility
   
   Unmarshal auto-detects v1 vs v2: existing encrypted messages (pre-4.24) 
continue to decrypt without any configuration change. New messages (4.24+) use 
v2 and are **not** readable by earlier Camel versions.
   
   ## Tests
   
   All 421 unit tests in `camel-pqc` pass locally (1 pre-existing skip 
unrelated to this change).
   
   Fixes CAMEL-27548
   
   ---
   _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
   


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