Skip to content

Commit e63df85

Browse files
authored
Merge pull request #869 from KostasTsiounis/syncup_native
Sync up NativeECDHKeyAgreement class with non-native equivalent
2 parents 9d41efb + dcdd0a8 commit e63df85

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

closed/adds/jdk/src/share/classes/sun/security/ec/NativeECDHKeyAgreement.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/*
2727
* ===========================================================================
28-
* (c) Copyright IBM Corp. 2022, 2024 All Rights Reserved
28+
* (c) Copyright IBM Corp. 2022, 2026 All Rights Reserved
2929
* ===========================================================================
3030
*/
3131

@@ -43,6 +43,7 @@
4343
import java.security.interfaces.ECPublicKey;
4444
import java.security.spec.AlgorithmParameterSpec;
4545
import java.security.spec.ECParameterSpec;
46+
import java.util.Arrays;
4647
import java.util.Map;
4748
import java.util.concurrent.ConcurrentHashMap;
4849

@@ -261,7 +262,12 @@ protected SecretKey engineGenerateSecret(String algorithm)
261262
throw new NoSuchAlgorithmException
262263
("Only supported for algorithm TlsPremasterSecret");
263264
}
264-
return new SecretKeySpec(engineGenerateSecret(), "TlsPremasterSecret");
265+
byte[] bytes = engineGenerateSecret();
266+
try {
267+
return new SecretKeySpec(bytes, algorithm);
268+
} finally {
269+
Arrays.fill(bytes, (byte)0);
270+
}
265271
}
266272

267273
/**

0 commit comments

Comments
 (0)