Skip to content

Commit fb2a634

Browse files
author
Bryan C. Mills
committed
Revert "crypto/rsa,crypto/ecdsa,crypto/ed25519: implement PublicKey.Equal"
This reverts CL 223754. Reason for revert: new tests are failing on all longtest builders. Change-Id: I2257d106c132f3a02c0af6b20061d4f9a8093c4f Reviewed-on: https://go-review.googlesource.com/c/go/+/225077 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 5b897ec commit fb2a634

File tree

6 files changed

+0
-171
lines changed

6 files changed

+0
-171
lines changed

src/crypto/ecdsa/ecdsa.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,6 @@ type PublicKey struct {
6262
X, Y *big.Int
6363
}
6464

65-
// Equal reports whether pub and x have the same value.
66-
//
67-
// Two keys are only considered to have the same value if they have the same Curve value.
68-
// Note that for example elliptic.P256() and elliptic.P256().Params() are different
69-
// values, as the latter is a generic not constant time implementation.
70-
func (pub *PublicKey) Equal(x crypto.PublicKey) bool {
71-
xx, ok := x.(*PublicKey)
72-
if !ok {
73-
return false
74-
}
75-
return pub.X.Cmp(xx.X) == 0 && pub.Y.Cmp(xx.Y) == 0 &&
76-
// Standard library Curve implementations are singletons, so this check
77-
// will work for those. Other Curves might be equivalent even if not
78-
// singletons, but there is no definitive way to check for that, and
79-
// better to err on the side of safety.
80-
pub.Curve == xx.Curve
81-
}
82-
8365
// PrivateKey represents an ECDSA private key.
8466
type PrivateKey struct {
8567
PublicKey

src/crypto/ecdsa/equal_test.go

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/crypto/ed25519/ed25519.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ const (
4040
// PublicKey is the type of Ed25519 public keys.
4141
type PublicKey []byte
4242

43-
// Equal reports whether pub and x have the same value.
44-
func (pub PublicKey) Equal(x crypto.PublicKey) bool {
45-
xx, ok := x.(PublicKey)
46-
if !ok {
47-
return false
48-
}
49-
return bytes.Equal(pub, xx)
50-
}
51-
5243
// PrivateKey is the type of Ed25519 private keys. It implements crypto.Signer.
5344
type PrivateKey []byte
5445

src/crypto/ed25519/ed25519_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,6 @@ func TestCryptoSigner(t *testing.T) {
8888
}
8989
}
9090

91-
func TestEqual(t *testing.T) {
92-
public, private, _ := GenerateKey(rand.Reader)
93-
94-
if !public.Equal(public) {
95-
t.Errorf("public key is not equal to itself: %q", public)
96-
}
97-
if !public.Equal(crypto.Signer(private).Public().(PublicKey)) {
98-
t.Errorf("private.Public() is not Equal to public: %q", public)
99-
}
100-
101-
other, _, _ := GenerateKey(rand.Reader)
102-
if public.Equal(other) {
103-
t.Errorf("different public keys are Equal")
104-
}
105-
}
106-
10791
func TestGolden(t *testing.T) {
10892
// sign.input.gz is a selection of test cases from
10993
// https://ed25519.cr.yp.to/python/sign.input

src/crypto/rsa/equal_test.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/crypto/rsa/rsa.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ func (pub *PublicKey) Size() int {
5050
return (pub.N.BitLen() + 7) / 8
5151
}
5252

53-
// Equal reports whether pub and x have the same value.
54-
func (pub *PublicKey) Equal(x crypto.PublicKey) bool {
55-
xx, ok := x.(*PublicKey)
56-
if !ok {
57-
return false
58-
}
59-
return pub.N.Cmp(xx.N) == 0 && pub.E == xx.E
60-
}
61-
6253
// OAEPOptions is an interface for passing options to OAEP decryption using the
6354
// crypto.Decrypter interface.
6455
type OAEPOptions struct {

0 commit comments

Comments
 (0)