Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
use equal method from openssl
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jun 28, 2019
1 parent 96972fe commit ad52c7a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
44 changes: 28 additions & 16 deletions crypto/openssl_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,21 @@ func (pk *opensslPublicKey) Raw() ([]byte, error) {

// Equals checks whether this key is equal to another
func (pk *opensslPublicKey) Equals(k Key) bool {
a, err := pk.Raw()
if err != nil {
return false
}
b, err := k.Raw()
if err != nil {
return false
k0, ok := k.(*RsaPublicKey)
if !ok {
a, err := pk.Raw()
if err != nil {
return false
}
b, err := k.Raw()
if err != nil {
return false
}

return bytes.Equal(a, b)
}
return bytes.Equal(a, b)

return pk.key.Equal(k0.opensslPublicKey.key)
}

// Sign returns a signature of the input data
Expand Down Expand Up @@ -104,13 +110,19 @@ func (sk *opensslPrivateKey) Raw() ([]byte, error) {

// Equals checks whether this key is equal to another
func (sk *opensslPrivateKey) Equals(k Key) bool {
a, err := sk.Raw()
if err != nil {
return false
}
b, err := k.Raw()
if err != nil {
return false
k0, ok := k.(*RsaPrivateKey)
if !ok {
a, err := sk.Raw()
if err != nil {
return false
}
b, err := k.Raw()
if err != nil {
return false
}

return bytes.Equal(a, b)
}
return bytes.Equal(a, b)

return sk.key.Equal(k0.opensslPrivateKey.key)
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ require (
go.opencensus.io v0.21.0
golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443
)

replace github.com/spacemonkeygo/openssl => github.com/dignifiedquire/openssl v0.0.0-20190628113709-80f7894f8393
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dignifiedquire/openssl v0.0.0-20190628113709-80f7894f8393 h1:B92kIXsWHWxJF8o6rtFGipDDFHbL7Fq8u8o8wM4OWYk=
github.com/dignifiedquire/openssl v0.0.0-20190628113709-80f7894f8393/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
Expand Down

0 comments on commit ad52c7a

Please sign in to comment.