Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maraino committed Mar 24, 2023
1 parent 1738d9b commit 6574a3c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/bcrypt_pbkdf/bcrypt_pbkdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ func BenchmarkKey(b *testing.B) {
pass := []byte("password")
salt := []byte("salt")
for i := 0; i < b.N; i++ {
Key(pass, salt, 10, 32)
_, _ = Key(pass, salt, 10, 32)
}
}
2 changes: 1 addition & 1 deletion kms/pkcs11/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func benchmarkSign(b *testing.B, signer crypto.Signer, opts crypto.SignerOpts) {
digest := h.Sum(nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
signer.Sign(rand.Reader, digest, opts)
_, _ = signer.Sign(rand.Reader, digest, opts)
}
b.StopTimer()
}
Expand Down
8 changes: 6 additions & 2 deletions kms/pkcs11/pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ func (k *PKCS11) StoreCertificate(req *apiv1.StoreCertificateRequest) error {
return errors.Wrap(err, "storeCertificate failed")
}
if req.Extractable {
template.Set(crypto11.CkaExtractable, true)
if err := template.Set(crypto11.CkaExtractable, true); err != nil {
return errors.Wrap(err, "storeCertificate failed")
}
}
if err := k.p11.ImportCertificateWithAttributes(template, req.Certificate); err != nil {
return errors.Wrap(err, "storeCertificate failed")
Expand Down Expand Up @@ -326,7 +328,9 @@ func generateKey(ctx P11, req *apiv1.CreateKeyRequest) (crypto11.Signer, error)
}
private := public.Copy()
if req.Extractable {
private.Set(crypto11.CkaExtractable, true)
if err := private.Set(crypto11.CkaExtractable, true); err != nil {
return nil, err
}
}

bits := req.Bits
Expand Down
10 changes: 5 additions & 5 deletions kms/pkcs11/pkcs11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestPKCS11_CreateKey(t *testing.T) {
k := setupPKCS11(t)

// Make sure to delete the created key
k.DeleteKey(testObject)
_ = k.DeleteKey(testObject)

type args struct {
req *apiv1.CreateKeyRequest
Expand Down Expand Up @@ -553,13 +553,13 @@ func TestPKCS11_CreateDecrypter(t *testing.T) {
}

// RSA-OAEP
enc, err = rsa.EncryptOAEP(crypto.SHA256.New(), rand.Reader, pub, data, []byte("label"))
enc, err = rsa.EncryptOAEP(crypto.SHA1.New(), rand.Reader, pub, data, []byte("label"))
if err != nil {
t.Errorf("rsa.EncryptOAEP() error = %v", err)
return
}
dec, err = got.Decrypt(rand.Reader, enc, &rsa.OAEPOptions{
Hash: crypto.SHA256,
Hash: crypto.SHA1,
Label: []byte("label"),
})
if err != nil {
Expand Down Expand Up @@ -653,8 +653,8 @@ func TestPKCS11_StoreCertificate(t *testing.T) {

// Make sure to delete the created certificate
t.Cleanup(func() {
k.DeleteCertificate(testObject)
k.DeleteCertificate(testObjectAlt)
_ = k.DeleteCertificate(testObject)
_ = k.DeleteCertificate(testObjectAlt)
})

type args struct {
Expand Down
2 changes: 1 addition & 1 deletion kms/sshagentkms/sshagentkms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func startOpenSSHAgent(t *testing.T) (client agent.Agent, socket string, cleanup
return ac, socket, func() {
proc, _ := os.FindProcess(pid)
if proc != nil {
proc.Kill()
_ = proc.Kill()
}
conn.Close()
os.RemoveAll(filepath.Dir(socket))
Expand Down
10 changes: 7 additions & 3 deletions x509util/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ func TestKeyUsage_MarshalJSON(t *testing.T) {
t.Errorf("KeyUsage.MarshalJSON() = %q, want %q", string(got), tt.want)
}
var unmarshaled KeyUsage
unmarshaled.UnmarshalJSON(got)
if err := unmarshaled.UnmarshalJSON(got); err != nil {
t.Errorf("KeyUsage.UnmarshalJSON() error = %v", err)
}
if unmarshaled != tt.k {
t.Errorf("KeyUsage.UnmarshalJSON(keyUsage.MarshalJSON) = %v, want %v", unmarshaled, tt.k)
}
Expand Down Expand Up @@ -582,7 +584,7 @@ func TestExtKeyUsage_MarshalJSON(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.eku.MarshalJSON()
if (err != nil) != tt.wantErr {
t.Fatalf("ExtKeyUsage.MarshalJSON() = error = %v, wantErr %v", err, tt.wantErr)
t.Fatalf("ExtKeyUsage.MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
if tt.wantErr {
return
Expand All @@ -591,7 +593,9 @@ func TestExtKeyUsage_MarshalJSON(t *testing.T) {
t.Errorf("ExtKeyUsage.MarshalJSON() = %q, want %q", string(got), tt.want)
}
var unmarshaled ExtKeyUsage
unmarshaled.UnmarshalJSON(got)
if err := unmarshaled.UnmarshalJSON(got); err != nil {
t.Errorf("ExtKeyUsage.UnmarshalJSON() error = %v", err)
}
if !reflect.DeepEqual(unmarshaled, tt.eku) {
t.Errorf("ExtKeyUsage.UnmarshalJSON(ExtKeyUsage.MarshalJSON) = %v, want %v", unmarshaled, tt.eku)
}
Expand Down

0 comments on commit 6574a3c

Please sign in to comment.