mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-10 15:08:43 +00:00
8377550: [REDO] Need to keep leading zeros in TlsPremasterSecret of TLS1.3 DHKeyAgreement
Reviewed-by: hchao, mullan
This commit is contained in:
parent
81b6fcc3e9
commit
06c9aebce3
@ -49,6 +49,9 @@ import sun.security.util.KeyUtil;
|
||||
*/
|
||||
public class KAKeyDerivation implements SSLKeyDerivation {
|
||||
|
||||
// Algorithm used to derive TLS 1.3 shared secrets
|
||||
private static final String t13KeyDerivationAlgorithm =
|
||||
System.getProperty("jdk.tls.t13KeyDerivationAlgorithm", "Generic");
|
||||
private final String algorithmName;
|
||||
private final HandshakeContext context;
|
||||
private final PrivateKey localPrivateKey;
|
||||
@ -234,7 +237,7 @@ public class KAKeyDerivation implements SSLKeyDerivation {
|
||||
var decapsulator = kem.newDecapsulator(localPrivateKey);
|
||||
sharedSecret = decapsulator.decapsulate(
|
||||
keyshare, 0, decapsulator.secretSize(),
|
||||
"TlsPremasterSecret");
|
||||
t13KeyDerivationAlgorithm);
|
||||
} catch (IllegalArgumentException | InvalidKeyException |
|
||||
DecapsulateException e) {
|
||||
// Peer validation failure
|
||||
@ -252,7 +255,7 @@ public class KAKeyDerivation implements SSLKeyDerivation {
|
||||
KeyAgreement ka = KeyAgreement.getInstance(algorithmName);
|
||||
ka.init(localPrivateKey);
|
||||
ka.doPhase(peerPublicKey, true);
|
||||
sharedSecret = ka.generateSecret("TlsPremasterSecret");
|
||||
sharedSecret = ka.generateSecret(t13KeyDerivationAlgorithm);
|
||||
}
|
||||
|
||||
return deriveHandshakeSecret(type, sharedSecret);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user