Skip to content

Commit 85735d6

Browse files
committed
More linting; improve 'nCryptDeleteKey' error handling.
1 parent 496f219 commit 85735d6

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

internal/bcrypt_pbkdf/bcrypt_pbkdf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44
//
5-
//nolint:revive,stylecheck // ignore underscore in package
5+
//nolint:revive,staticcheck // ignore underscore in package
66
package bcrypt_pbkdf
77

88
import (

jose/encrypt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func rsaEqual(priv *rsa.PrivateKey, x crypto.PrivateKey) bool {
103103
if !ok {
104104
return false
105105
}
106-
if !(priv.PublicKey.N.Cmp(xx.N) == 0 && priv.PublicKey.E == xx.E) || priv.D.Cmp(xx.D) != 0 {
106+
if (priv.PublicKey.N.Cmp(xx.N) != 0 || priv.PublicKey.E != xx.E) || priv.D.Cmp(xx.D) != 0 {
107107
return false
108108
}
109109
if len(priv.Primes) != len(xx.Primes) {

kms/capi/ncrypt_windows.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ func nCryptOpenKey(provisionerHandle uintptr, containerName string, legacyKeySpe
292292
}
293293

294294
func nCryptDeleteKey(keyHandle uintptr) error {
295-
r, _, _ := procNCryptDeleteKey.Call(
295+
r, _, err := procNCryptDeleteKey.Call(
296296
keyHandle,
297297
0,
298298
)
299+
if !errors.Is(err, windows.Errno(0)) {
300+
return fmt.Errorf("NCryptDeleteKey returned %w", err)
301+
}
299302
if r != 0 {
300303
return fmt.Errorf("NCryptDeleteKey returned %v", errNoToStr(uint32(r)))
301304
}

x509util/certificate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (c *Certificate) GetCertificate() *x509.Certificate {
188188
// See also https://datatracker.ietf.org/doc/html/rfc5280.html#section-4.2.1.6
189189
func (c *Certificate) hasExtendedSANs() bool {
190190
for _, san := range c.SANs {
191-
if !(san.Type == DNSType || san.Type == EmailType || san.Type == IPType || san.Type == URIType || san.Type == AutoType || san.Type == "") {
191+
if !(san.Type == DNSType || san.Type == EmailType || san.Type == IPType || san.Type == URIType || san.Type == AutoType || san.Type == "") { //nolint:staticcheck // QF1001, this version is more semantically readable
192192
return true
193193
}
194194
}

x509util/certificate_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (c *CertificateRequest) GetLeafCertificate() *Certificate {
320320
// See also https://datatracker.ietf.org/doc/html/rfc5280.html#section-4.2.1.6
321321
func (c *CertificateRequest) hasExtendedSANs() bool {
322322
for _, san := range c.SANs {
323-
if !(san.Type == DNSType || san.Type == EmailType || san.Type == IPType || san.Type == URIType || san.Type == AutoType || san.Type == "") {
323+
if !(san.Type == DNSType || san.Type == EmailType || san.Type == IPType || san.Type == URIType || san.Type == AutoType || san.Type == "") { //nolint:staticcheck // QF1001, this version is more semantically readable
324324
return true
325325
}
326326
}

0 commit comments

Comments
 (0)