File tree 2 files changed +11
-8
lines changed
closed/src/java.base/share/classes/sun/security/ec
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 25
25
26
26
/*
27
27
* ===========================================================================
28
- * (c) Copyright IBM Corp. 2022, 2024 All Rights Reserved
28
+ * (c) Copyright IBM Corp. 2022, 2025 All Rights Reserved
29
29
* ===========================================================================
30
30
*/
31
31
60
60
import sun .security .util .ArrayUtil ;
61
61
import sun .security .util .CurveDB ;
62
62
import sun .security .util .ECUtil ;
63
+ import sun .security .util .KeyUtil ;
63
64
import sun .security .util .NamedCurve ;
64
65
65
66
/**
@@ -343,11 +344,11 @@ protected SecretKey engineGenerateSecret(String algorithm)
343
344
if (algorithm == null ) {
344
345
throw new NoSuchAlgorithmException ("Algorithm must not be null" );
345
346
}
346
- if (!( algorithm . equals ( "TlsPremasterSecret" ) )) {
347
- throw new NoSuchAlgorithmException
348
- ( "Only supported for algorithm TlsPremasterSecret" );
347
+ if (!KeyUtil . isSupportedKeyAgreementOutputAlgorithm ( algorithm )) {
348
+ throw new NoSuchAlgorithmException (
349
+ "Unsupported secret key algorithm: " + algorithm );
349
350
}
350
- return new SecretKeySpec (engineGenerateSecret (), "TlsPremasterSecret" );
351
+ return new SecretKeySpec (engineGenerateSecret (), algorithm );
351
352
}
352
353
353
354
/**
Original file line number Diff line number Diff line change 25
25
26
26
/*
27
27
* ===========================================================================
28
- * (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
28
+ * (c) Copyright IBM Corp. 2023, 2025 All Rights Reserved
29
29
* ===========================================================================
30
30
*/
31
31
49
49
50
50
import jdk .crypto .jniprovider .NativeCrypto ;
51
51
52
+ import sun .security .util .KeyUtil ;
52
53
import sun .security .x509 .X509Key ;
53
54
54
55
public class NativeXDHKeyAgreement extends KeyAgreementSpi {
@@ -259,8 +260,9 @@ protected SecretKey engineGenerateSecret(String algorithm)
259
260
throw new NoSuchAlgorithmException ("Algorithm must not be null" );
260
261
}
261
262
262
- if (!(algorithm .equals ("TlsPremasterSecret" ))) {
263
- throw new NoSuchAlgorithmException ("Only supported for algorithm TlsPremasterSecret" );
263
+ if (!KeyUtil .isSupportedKeyAgreementOutputAlgorithm (algorithm )) {
264
+ throw new NoSuchAlgorithmException (
265
+ "Unsupported secret key algorithm: " + algorithm );
264
266
}
265
267
return new SecretKeySpec (engineGenerateSecret (), algorithm );
266
268
}
You can’t perform that action at this time.
0 commit comments