Skip to content

Commit 1dbb6ca

Browse files
committed
chore: Bump to golang 1.24
Bump to golang 1.24 and drop dependency on golang.org/x/crypto/pbkdf2. Signed-off-by: Felix Matouschek <[email protected]>
1 parent 3e611df commit 1dbb6ca

File tree

8 files changed

+18
-142
lines changed

8 files changed

+18
-142
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ clean:
99

1010
.PHONY: fmt
1111
fmt: gofumpt ## Run gofumt against code.
12-
go mod tidy -compat=1.23
12+
go mod tidy -compat=1.24
1313
$(GOFUMPT) -w -extra .
1414

1515
.PHONY: vendor

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module cga-led
22

3-
go 1.23
4-
5-
require golang.org/x/crypto v0.33.0
3+
go 1.24

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
2-
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=

main.go

+16-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"crypto/pbkdf2"
56
"crypto/sha256"
67
"encoding/hex"
78
"encoding/json"
@@ -14,8 +15,6 @@ import (
1415
"net/url"
1516
"strconv"
1617
"strings"
17-
18-
"golang.org/x/crypto/pbkdf2"
1918
)
2019

2120
type genericResponse struct {
@@ -104,7 +103,11 @@ func (c *cgaLed) login() error {
104103
return err
105104
}
106105

107-
if _, err := c.sendSessionLogin(deriveChallenge(res, c.password)); err != nil {
106+
challenge, err := deriveChallenge(res, c.password)
107+
if err != nil {
108+
return err
109+
}
110+
if _, err := c.sendSessionLogin(challenge); err != nil {
108111
return err
109112
}
110113

@@ -250,12 +253,18 @@ func sendRequest[T apiResponse](client *http.Client, method, u string, body io.R
250253
return &apiRes, nil
251254
}
252255

253-
func deriveChallenge(res *loginResponse, password string) string {
256+
func deriveChallenge(res *loginResponse, password string) (string, error) {
254257
const iterations = 1000
255258
const keyLen = 16
256-
a := pbkdf2.Key([]byte(password), []byte(res.Salt), iterations, keyLen, sha256.New)
257-
b := pbkdf2.Key([]byte(hex.EncodeToString(a)), []byte(res.SaltWebUI), iterations, keyLen, sha256.New)
258-
return hex.EncodeToString(b)
259+
a, err := pbkdf2.Key(sha256.New, password, []byte(res.Salt), iterations, keyLen)
260+
if err != nil {
261+
return "", err
262+
}
263+
b, err := pbkdf2.Key(sha256.New, hex.EncodeToString(a), []byte(res.SaltWebUI), iterations, keyLen)
264+
if err != nil {
265+
return "", err
266+
}
267+
return hex.EncodeToString(b), nil
259268
}
260269

261270
func main() {

vendor/golang.org/x/crypto/LICENSE

-27
This file was deleted.

vendor/golang.org/x/crypto/PATENTS

-22
This file was deleted.

vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go

-77
This file was deleted.

vendor/modules.txt

-3
This file was deleted.

0 commit comments

Comments
 (0)