Skip to content

Commit

Permalink
all: replace bytes.Compare with bytes.Equal
Browse files Browse the repository at this point in the history
Signed-off-by: cui fliter <imcusg@gmail.com>
  • Loading branch information
cuishuang committed Oct 4, 2022
1 parent eccd636 commit f50e003
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkcs12/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func pbDecrypt(info decryptable, password []byte) (decrypted []byte, err error)
}
ps := decrypted[len(decrypted)-psLen:]
decrypted = decrypted[:len(decrypted)-psLen]
if bytes.Compare(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) != 0 {
if !bytes.Equal(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) {
return nil, ErrDecryption
}

Expand Down
2 changes: 1 addition & 1 deletion ssh/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ func (c *client) insertCert(s interface{}, cert *ssh.Certificate, comment string
if err != nil {
return err
}
if bytes.Compare(cert.Key.Marshal(), signer.PublicKey().Marshal()) != 0 {
if !bytes.Equal(cert.Key.Marshal(), signer.PublicKey().Marshal()) {
return errors.New("agent: signer and cert have different public key")
}

Expand Down
2 changes: 1 addition & 1 deletion ssh/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ type algorithmOpenSSHCertSigner struct {
// private key is held by signer. It returns an error if the public key in cert
// doesn't match the key used by signer.
func NewCertSigner(cert *Certificate, signer Signer) (Signer, error) {
if bytes.Compare(cert.Key.Marshal(), signer.PublicKey().Marshal()) != 0 {
if !bytes.Equal(cert.Key.Marshal(), signer.PublicKey().Marshal()) {
return nil, errors.New("ssh: signer and cert have different public key")
}

Expand Down

0 comments on commit f50e003

Please sign in to comment.