Skip to content

Commit

Permalink
fix(client): keep Go 1.18 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
puzpuzpuz committed Mar 22, 2024
1 parent a1d913f commit 4411b04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.20.x]
go-version: [1.18.x, 1.19.x, 1.20.x]
name: Build with Go ${{ matrix.go-version }}
steps:
- name: Checkout repository
Expand Down
20 changes: 4 additions & 16 deletions tcp_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"bufio"
"context"
"crypto"
"crypto/ecdh"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
Expand Down Expand Up @@ -67,21 +66,10 @@ func newTcpLineSender(ctx context.Context, conf *lineSenderConfig) (*tcpLineSend
if err != nil {
return nil, fmt.Errorf("failed to decode auth key: %v", err)
}
// elliptic.P256().ScalarBaseMult is deprecated, so we use ecdh key
// and convert it to the ecdsa one.
ecdhKey, err := ecdh.P256().NewPrivateKey(rawKey)
if err != nil {
return nil, fmt.Errorf("invalid auth key: %v", err)
}
ecdhPubKey := ecdhKey.PublicKey().Bytes()
key = &ecdsa.PrivateKey{
PublicKey: ecdsa.PublicKey{
Curve: elliptic.P256(),
X: big.NewInt(0).SetBytes(ecdhPubKey[1:33]),
Y: big.NewInt(0).SetBytes(ecdhPubKey[33:]),
},
D: big.NewInt(0).SetBytes(ecdhKey.Bytes()),
}
key = new(ecdsa.PrivateKey)
key.PublicKey.Curve = elliptic.P256()
key.PublicKey.X, key.PublicKey.Y = key.PublicKey.Curve.ScalarBaseMult(rawKey)
key.D = new(big.Int).SetBytes(rawKey)
}

if conf.tlsMode == tlsDisabled {
Expand Down

0 comments on commit 4411b04

Please sign in to comment.