You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2025/03/05 09:17:04 UTC
(santuario-xml-security-java) branch 3.0.x-fixes updated: SANTUARIO-625 Security warning is always logged when using ECDH with AES-KW (#456)
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/santuario-xml-security-java.git
The following commit(s) were added to refs/heads/3.0.x-fixes by this push:
new 8b63bed2 SANTUARIO-625 Security warning is always logged when using ECDH with AES-KW (#456)
8b63bed2 is described below
commit 8b63bed29aa909691bfe2f25e52fc8538a1d6cf7
Author: beth-soptim <46...@users.noreply.github.com>
AuthorDate: Wed Mar 5 10:16:59 2025 +0100
SANTUARIO-625 Security warning is always logged when using ECDH with AES-KW (#456)
---
src/main/java/org/apache/xml/security/utils/KeyUtils.java | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/xml/security/utils/KeyUtils.java b/src/main/java/org/apache/xml/security/utils/KeyUtils.java
index a0963eed..09f0c9bc 100644
--- a/src/main/java/org/apache/xml/security/utils/KeyUtils.java
+++ b/src/main/java/org/apache/xml/security/utils/KeyUtils.java
@@ -208,13 +208,9 @@ public class KeyUtils {
PublicKey publicKey = parameterSpec.getAgreementPublicKey();
PrivateKey privateKey = parameterSpec.getAgreementPrivateKey();
- String algorithm = publicKey.getAlgorithm();
- if ("EC".equalsIgnoreCase(algorithm)) {
- LOG.warn("EC keys are detected for key agreement algorithm! " +
- "Cryptographic algorithm may not be secure, consider using a different algorithm (and keys).");
- }
- algorithm = algorithm + (algorithm.equalsIgnoreCase("EC") ? "DH" : "");
- KeyAgreement keyAgreement = KeyAgreement.getInstance(algorithm);
+ String keyAlgorithm = publicKey.getAlgorithm();
+ String keyAgreementAlgorithm = keyAlgorithm + ("EC".equalsIgnoreCase(keyAlgorithm) ? "DH" : "");
+ KeyAgreement keyAgreement = KeyAgreement.getInstance(keyAgreementAlgorithm);
keyAgreement.init(privateKey);
keyAgreement.doPhase(publicKey, true);
byte[] secret = keyAgreement.generateSecret();