Skip to content

Commit f50e003

Browse files
committed
all: replace bytes.Compare with bytes.Equal
Signed-off-by: cui fliter <[email protected]>
1 parent eccd636 commit f50e003

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pkcs12/crypto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func pbDecrypt(info decryptable, password []byte) (decrypted []byte, err error)
117117
}
118118
ps := decrypted[len(decrypted)-psLen:]
119119
decrypted = decrypted[:len(decrypted)-psLen]
120-
if bytes.Compare(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) != 0 {
120+
if !bytes.Equal(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) {
121121
return nil, ErrDecryption
122122
}
123123

ssh/agent/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string
731731
if err != nil {
732732
return err
733733
}
734-
if bytes.Compare(cert.Key.Marshal(), signer.PublicKey().Marshal()) != 0 {
734+
if !bytes.Equal(cert.Key.Marshal(), signer.PublicKey().Marshal()) {
735735
return errors.New("agent: signer and cert have different public key")
736736
}
737737

ssh/certs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ type algorithmOpenSSHCertSigner struct {
251251
// private key is held by signer. It returns an error if the public key in cert
252252
// doesn't match the key used by signer.
253253
func NewCertSigner(cert *Certificate, signer Signer) (Signer, error) {
254-
if bytes.Compare(cert.Key.Marshal(), signer.PublicKey().Marshal()) != 0 {
254+
if !bytes.Equal(cert.Key.Marshal(), signer.PublicKey().Marshal()) {
255255
return nil, errors.New("ssh: signer and cert have different public key")
256256
}
257257

0 commit comments

Comments
 (0)