oscerd commented on code in PR #28090:
URL: https://github.com/apache/camel/pull/28090#discussion_r4313363127


##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/crypto/hybrid/HybridKEMCurveTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.crypto.hybrid;
+
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.spec.ECGenParameterSpec;
+
+import javax.crypto.KeyAgreement;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+
+import org.bouncycastle.jcajce.spec.MLKEMParameterSpec;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The ephemeral key of the classical half must be generated on the curve of 
the recipient's key. An EC public key
+ * reports a bare "EC" as its algorithm, so the curve has to come from the key 
itself.
+ */
+class HybridKEMCurveTest {
+
+    @BeforeAll
+    static void setup() {
+        if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
+            Security.addProvider(new BouncyCastleProvider());
+        }
+        if (Security.getProvider(BouncyCastlePQCProvider.PROVIDER_NAME) == 
null) {
+            Security.addProvider(new BouncyCastlePQCProvider());
+        }
+    }

Review Comment:
   Added in 9b7c541 as `x25519RoundTrips()`, alongside the X448 one.
   
   One clarification on the mechanics, since it affects what the test actually 
guards: BouncyCastle's `BCXDHPublicKey implements 
org.bouncycastle.jcajce.interfaces.XDHPublicKey`, not 
`java.security.interfaces.XECPublicKey` — I checked the 1.86 jar. So a 
BC-produced X25519 key does not take the `XECPublicKey` branch; it falls 
through to the final `else` and is resolved by `getAlgorithm()`, which BC 
answers as the concrete `"X25519"`. The `XECPublicKey`/`NamedParameterSpec` 
branch is there for a JDK (SunEC) key.
   
   The test is worth having either way — it is the most commonly configured 
classical half and had no end-to-end coverage at all.
   
   _Claude Code on behalf of @oscerd_



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -212,6 +212,13 @@ also applies to `pollEnrich` and 
`ConsumerTemplate.receive`, which take one file
 until the last file of the directory is received, where before the first 
received file deleted it. This applies to
 camel-ftp, camel-sftp, camel-smb and camel-azure-files as well.
 
+=== camel-pqc - an unknown hybridKdfAlgorithm is rejected
+
+The hybrid KEM operations now fail with an `IllegalArgumentException` when 
`hybridKdfAlgorithm` is not one of
+`HKDF-SHA256`, `HKDF-SHA384` or `HKDF-SHA512`. Before, any other value 
silently fell back to `HKDF-SHA256`, so a typo
+such as `HKDF-SHA-512` went unnoticed - and if only one end of an exchange 
carried the typo, both ends still reported
+success while deriving the key with different digests.
+
 === camel-jbang - camel validate normalize writes one file per input file to 
an output directory
 
 `camel validate normalize <files> --output=<dir>` now writes one normalized 
file per input file into the

Review Comment:
   Documented in 9b7c541, in the existing 4.24 `camel-pqc` section. Wording 
covers that the info string is the symmetric algorithm name, that ASCII values 
such as `AES` are unaffected, and that a JVM whose default charset encodes it 
differently would derive a different key and fail to decrypt earlier material.
   
   _Claude Code on behalf of @oscerd_



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