Skip to content

Commit 6885254

Browse files
beth-soptimcoheigea
authored andcommitted
SANTUARIO-625 Security warning is always logged when using ECDH with AES-KW (#456)
1 parent b4b3612 commit 6885254

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/main/java/org/apache/xml/security/utils/KeyUtils.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,9 @@ public static SecretKey aesWrapKeyWithDHGeneratedKey(KeyAgreementParameters para
208208
PublicKey publicKey = parameterSpec.getAgreementPublicKey();
209209
PrivateKey privateKey = parameterSpec.getAgreementPrivateKey();
210210

211-
String algorithm = publicKey.getAlgorithm();
212-
if ("EC".equalsIgnoreCase(algorithm)) {
213-
LOG.log(Level.WARNING, "EC keys are detected for key agreement algorithm! " +
214-
"Cryptographic algorithm may not be secure, consider using a different algorithm (and keys).");
215-
}
216-
algorithm = algorithm + (algorithm.equalsIgnoreCase("EC") ? "DH" : "");
217-
KeyAgreement keyAgreement = KeyAgreement.getInstance(algorithm);
211+
String keyAlgorithm = publicKey.getAlgorithm();
212+
String keyAgreementAlgorithm = keyAlgorithm + ("EC".equalsIgnoreCase(keyAlgorithm) ? "DH" : "");
213+
KeyAgreement keyAgreement = KeyAgreement.getInstance(keyAgreementAlgorithm);
218214
keyAgreement.init(privateKey);
219215
keyAgreement.doPhase(publicKey, true);
220216
byte[] secret = keyAgreement.generateSecret();

0 commit comments

Comments
 (0)