Skip to content

Commit dddbb99

Browse files
committed
fix: golangci-lint
1 parent 3235056 commit dddbb99

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

keymanager/go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
module github.com/google/go-tpm-tools/keymanager
22

3-
go 1.22
3+
go 1.23
44

5-
require github.com/google/uuid v1.6.0
5+
toolchain go1.24.13
6+
7+
require (
8+
github.com/google/uuid v1.6.0
9+
google.golang.org/protobuf v1.36.11
10+
)

keymanager/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
13
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
24
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5+
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
6+
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=

keymanager/key_protection_service/service_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestServiceGenerateKEMKeypairSuccess(t *testing.T) {
1818
}
1919

2020
svc := NewService(
21-
func(algo *algorithms.HpkeAlgorithm, bindingPubKey []byte, lifespanSecs uint64) (uuid.UUID, []byte, error) {
21+
func(_ *algorithms.HpkeAlgorithm, bindingPubKey []byte, lifespanSecs uint64) (uuid.UUID, []byte, error) {
2222
if len(bindingPubKey) != 32 {
2323
t.Fatalf("expected 32-byte binding public key, got %d", len(bindingPubKey))
2424
}
@@ -27,7 +27,7 @@ func TestServiceGenerateKEMKeypairSuccess(t *testing.T) {
2727
}
2828
return expectedUUID, expectedPubKey, nil
2929
},
30-
func(limit, offset int) ([]kpskcc.KEMKeyInfo, bool, error) {
30+
func(_, _ int) ([]kpskcc.KEMKeyInfo, bool, error) {
3131
return nil, false, nil
3232
},
3333
)
@@ -46,10 +46,10 @@ func TestServiceGenerateKEMKeypairSuccess(t *testing.T) {
4646

4747
func TestServiceGenerateKEMKeypairError(t *testing.T) {
4848
svc := NewService(
49-
func(algo *algorithms.HpkeAlgorithm, bindingPubKey []byte, lifespanSecs uint64) (uuid.UUID, []byte, error) {
49+
func(_ *algorithms.HpkeAlgorithm, _ []byte, _ uint64) (uuid.UUID, []byte, error) {
5050
return uuid.Nil, nil, fmt.Errorf("FFI error")
5151
},
52-
func(limit, offset int) ([]kpskcc.KEMKeyInfo, bool, error) {
52+
func(_, _ int) ([]kpskcc.KEMKeyInfo, bool, error) {
5353
return nil, false, nil
5454
},
5555
)
@@ -75,7 +75,7 @@ func TestServiceEnumerateKEMKeysSuccess(t *testing.T) {
7575
}
7676

7777
svc := NewService(
78-
func(algo *algorithms.HpkeAlgorithm, bindingPubKey []byte, lifespanSecs uint64) (uuid.UUID, []byte, error) {
78+
func(_ *algorithms.HpkeAlgorithm, _ []byte, _ uint64) (uuid.UUID, []byte, error) {
7979
return uuid.Nil, nil, nil
8080
},
8181
func(limit, offset int) ([]kpskcc.KEMKeyInfo, bool, error) {
@@ -100,10 +100,10 @@ func TestServiceEnumerateKEMKeysSuccess(t *testing.T) {
100100

101101
func TestServiceEnumerateKEMKeysError(t *testing.T) {
102102
svc := NewService(
103-
func(algo *algorithms.HpkeAlgorithm, bindingPubKey []byte, lifespanSecs uint64) (uuid.UUID, []byte, error) {
103+
func(_ *algorithms.HpkeAlgorithm, _ []byte, _ uint64) (uuid.UUID, []byte, error) {
104104
return uuid.Nil, nil, nil
105105
},
106-
func(limit, offset int) ([]kpskcc.KEMKeyInfo, bool, error) {
106+
func(_, _ int) ([]kpskcc.KEMKeyInfo, bool, error) {
107107
return nil, false, fmt.Errorf("enumerate error")
108108
},
109109
)

keymanager/km_common/proto/algorithms.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

keymanager/workload_service/proto_enums.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import (
88
algorithms "github.com/google/go-tpm-tools/keymanager/km_common/proto"
99
)
1010

11-
// These enum values mirror the proto definitions in PROTOS.md and are used by
12-
// the WSD JSON API contract.
13-
1411
// KemAlgorithm represents the requested KEM algorithm.
1512
type KemAlgorithm int32
1613

@@ -102,8 +99,9 @@ func (k KemAlgorithm) ToHpkeAlgorithm() (*algorithms.HpkeAlgorithm, error) {
10299
type KdfAlgorithm int32
103100

104101
const (
102+
// KdfAlgorithmUnspecified indicates an unspecified KDF algorithm.
105103
KdfAlgorithmUnspecified KdfAlgorithm = 0
106-
// Corrected from HKDF_SHA384 to HKDF_SHA256 based on ToHpkeAlgorithm usage which maps to HKDF_SHA256 (val 1)
104+
// KdfAlgorithmHKDFSHA256 specifies the HKDF-SHA256 KDF algorithm.
107105
KdfAlgorithmHKDFSHA256 KdfAlgorithm = 1
108106
)
109107

@@ -125,10 +123,12 @@ func (k KdfAlgorithm) String() string {
125123
return fmt.Sprintf("KDF_ALGORITHM_UNKNOWN(%d)", k)
126124
}
127125

126+
// MarshalJSON converts a KdfAlgorithm enum value to its JSON string representation.
128127
func (k KdfAlgorithm) MarshalJSON() ([]byte, error) {
129128
return json.Marshal(k.String())
130129
}
131130

131+
// UnmarshalJSON converts a JSON string back into a KdfAlgorithm enum value.
132132
func (k *KdfAlgorithm) UnmarshalJSON(data []byte) error {
133133
var s string
134134
if err := json.Unmarshal(data, &s); err != nil {
@@ -145,8 +145,10 @@ func (k *KdfAlgorithm) UnmarshalJSON(data []byte) error {
145145
type AeadAlgorithm int32
146146

147147
const (
148+
// AeadAlgorithmUnspecified indicates an unspecified AEAD algorithm.
148149
AeadAlgorithmUnspecified AeadAlgorithm = 0
149-
AeadAlgorithmAES256GCM AeadAlgorithm = 1
150+
// AeadAlgorithmAES256GCM specifies the AES-256-GCM AEAD algorithm.
151+
AeadAlgorithmAES256GCM AeadAlgorithm = 1
150152
)
151153

152154
var (
@@ -167,10 +169,12 @@ func (k AeadAlgorithm) String() string {
167169
return fmt.Sprintf("AEAD_ALGORITHM_UNKNOWN(%d)", k)
168170
}
169171

172+
// MarshalJSON converts an AeadAlgorithm enum value to its JSON string representation.
170173
func (k AeadAlgorithm) MarshalJSON() ([]byte, error) {
171174
return json.Marshal(k.String())
172175
}
173176

177+
// UnmarshalJSON converts a JSON string back into an AeadAlgorithm enum value.
174178
func (k *AeadAlgorithm) UnmarshalJSON(data []byte) error {
175179
var s string
176180
if err := json.Unmarshal(data, &s); err != nil {

keymanager/workload_service/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (m *mockKeyProtectionService) GenerateKEMKeypair(_ *algorithms.HpkeAlgorith
5353
return m.uuid, m.pubKey, m.err
5454
}
5555

56-
func (m *mockKeyProtectionService) EnumerateKEMKeys(limit, offset int) ([]kpskcc.KEMKeyInfo, bool, error) {
56+
func (m *mockKeyProtectionService) EnumerateKEMKeys(_, _ int) ([]kpskcc.KEMKeyInfo, bool, error) {
5757
return m.enumeratedKeys, false, m.enumerateErr
5858
}
5959

0 commit comments

Comments
 (0)