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 7
7
8
8
pb "github.com/libp2p/go-libp2p-core/crypto/pb"
9
9
10
- openssl "github.com/spacemonkeygo/ openssl"
10
+ openssl "github.com/libp2p/go- openssl"
11
11
)
12
12
13
13
// 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) {
63
63
64
64
// Equals checks whether this key is equal to another
65
65
func (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 )
73
78
}
74
- return bytes .Equal (a , b )
79
+
80
+ return pk .key .Equal (k0 .opensslPublicKey .key )
75
81
}
76
82
77
83
// Sign returns a signature of the input data
@@ -104,13 +110,19 @@ func (sk *opensslPrivateKey) Raw() ([]byte, error) {
104
110
105
111
// Equals checks whether this key is equal to another
106
112
func (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 )
114
125
}
115
- return bytes .Equal (a , b )
126
+
127
+ return sk .key .Equal (k0 .opensslPrivateKey .key )
116
128
}
Original file line number Diff line number Diff line change 6
6
"errors"
7
7
"io"
8
8
9
- openssl "github.com/spacemonkeygo/ openssl"
9
+ openssl "github.com/libp2p/go- openssl"
10
10
)
11
11
12
12
// RsaPrivateKey is an rsa private key
You can’t perform that action at this time.
0 commit comments