File tree Expand file tree Collapse file tree 2 files changed +30
-18
lines changed Expand file tree Collapse file tree 2 files changed +30
-18
lines changed Original file line number Diff line number Diff line change 77
88 pb "github.com/libp2p/go-libp2p-core/crypto/pb"
99
10- openssl "github.com/spacemonkeygo/ openssl"
10+ openssl "github.com/libp2p/go- openssl"
1111)
1212
1313// define these as separate types so we can add more key types later and reuse
@@ -63,15 +63,21 @@ func (pk *opensslPublicKey) Raw() ([]byte, error) {
6363
6464// Equals checks whether this key is equal to another
6565func (pk * opensslPublicKey ) Equals (k Key ) bool {
66- a , err := pk .Raw ()
67- if err != nil {
68- return false
69- }
70- b , err := k .Raw ()
71- if err != nil {
72- return false
66+ k0 , ok := k .(* RsaPublicKey )
67+ if ! ok {
68+ a , err := pk .Raw ()
69+ if err != nil {
70+ return false
71+ }
72+ b , err := k .Raw ()
73+ if err != nil {
74+ return false
75+ }
76+
77+ return bytes .Equal (a , b )
7378 }
74- return bytes .Equal (a , b )
79+
80+ return pk .key .Equal (k0 .opensslPublicKey .key )
7581}
7682
7783// Sign returns a signature of the input data
@@ -104,13 +110,19 @@ func (sk *opensslPrivateKey) Raw() ([]byte, error) {
104110
105111// Equals checks whether this key is equal to another
106112func (sk * opensslPrivateKey ) Equals (k Key ) bool {
107- a , err := sk .Raw ()
108- if err != nil {
109- return false
110- }
111- b , err := k .Raw ()
112- if err != nil {
113- return false
113+ k0 , ok := k .(* RsaPrivateKey )
114+ if ! ok {
115+ a , err := sk .Raw ()
116+ if err != nil {
117+ return false
118+ }
119+ b , err := k .Raw ()
120+ if err != nil {
121+ return false
122+ }
123+
124+ return bytes .Equal (a , b )
114125 }
115- return bytes .Equal (a , b )
126+
127+ return sk .key .Equal (k0 .opensslPrivateKey .key )
116128}
Original file line number Diff line number Diff line change 66 "errors"
77 "io"
88
9- openssl "github.com/spacemonkeygo/ openssl"
9+ openssl "github.com/libp2p/go- openssl"
1010)
1111
1212// RsaPrivateKey is an rsa private key
You can’t perform that action at this time.
0 commit comments