From 2180046329fd5c7299a583ba4bae2c353f6ecb60 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Mon, 14 Nov 2022 12:13:46 +0100 Subject: [PATCH] crypto/ecdh: move ECDH method to PrivateKey Fixes #56052 Change-Id: Icacba0ed0f77519bca2140c8af68407af97f9734 Reviewed-on: https://go-review.googlesource.com/c/go/+/450335 Run-TryBot: Filippo Valsorda Reviewed-by: Roland Shoemaker TryBot-Result: Gopher Robot Reviewed-by: Joedian Reid Auto-Submit: Filippo Valsorda --- handshake_client_tls13.go | 2 +- handshake_server_tls13.go | 2 +- key_agreement.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/handshake_client_tls13.go b/handshake_client_tls13.go index 12ff3a4..3bdd937 100644 --- a/handshake_client_tls13.go +++ b/handshake_client_tls13.go @@ -353,7 +353,7 @@ func (hs *clientHandshakeStateTLS13) establishHandshakeKeys() error { c.sendAlert(alertIllegalParameter) return errors.New("tls: invalid server key share") } - sharedKey, err := hs.ecdheKey.Curve().ECDH(hs.ecdheKey, peerKey) + sharedKey, err := hs.ecdheKey.ECDH(peerKey) if err != nil { c.sendAlert(alertIllegalParameter) return errors.New("tls: invalid server key share") diff --git a/handshake_server_tls13.go b/handshake_server_tls13.go index 9b7356a..80d4dce 100644 --- a/handshake_server_tls13.go +++ b/handshake_server_tls13.go @@ -220,7 +220,7 @@ GroupSelection: c.sendAlert(alertIllegalParameter) return errors.New("tls: invalid client key share") } - hs.sharedKey, err = key.Curve().ECDH(key, peerKey) + hs.sharedKey, err = key.ECDH(peerKey) if err != nil { c.sendAlert(alertIllegalParameter) return errors.New("tls: invalid client key share") diff --git a/key_agreement.go b/key_agreement.go index 027060d..2c8c5b8 100644 --- a/key_agreement.go +++ b/key_agreement.go @@ -264,7 +264,7 @@ func (ka *ecdheKeyAgreement) processClientKeyExchange(config *Config, cert *Cert if err != nil { return nil, errClientKeyExchange } - preMasterSecret, err := ka.key.Curve().ECDH(ka.key, peerKey) + preMasterSecret, err := ka.key.ECDH(peerKey) if err != nil { return nil, errClientKeyExchange } @@ -307,7 +307,7 @@ func (ka *ecdheKeyAgreement) processServerKeyExchange(config *Config, clientHell if err != nil { return errServerKeyExchange } - ka.preMasterSecret, err = key.Curve().ECDH(key, peerKey) + ka.preMasterSecret, err = key.ECDH(peerKey) if err != nil { return errServerKeyExchange }