Skip to content

Commit

Permalink
Revert "crypto/rsa,crypto/ecdsa,crypto/ed25519: implement PublicKey.E…
Browse files Browse the repository at this point in the history
…qual"

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>
  • Loading branch information
Bryan C. Mills committed Mar 23, 2020
1 parent 5b897ec commit fb2a634
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 171 deletions.
18 changes: 0 additions & 18 deletions src/crypto/ecdsa/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,6 @@ type PublicKey struct {
X, Y *big.Int
}

// Equal reports whether pub and x have the same value.
//
// Two keys are only considered to have the same value if they have the same Curve value.
// Note that for example elliptic.P256() and elliptic.P256().Params() are different
// values, as the latter is a generic not constant time implementation.
func (pub *PublicKey) Equal(x crypto.PublicKey) bool {
xx, ok := x.(*PublicKey)
if !ok {
return false
}
return pub.X.Cmp(xx.X) == 0 && pub.Y.Cmp(xx.Y) == 0 &&
// Standard library Curve implementations are singletons, so this check
// will work for those. Other Curves might be equivalent even if not
// singletons, but there is no definitive way to check for that, and
// better to err on the side of safety.
pub.Curve == xx.Curve
}

// PrivateKey represents an ECDSA private key.
type PrivateKey struct {
PublicKey
Expand Down
77 changes: 0 additions & 77 deletions src/crypto/ecdsa/equal_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions src/crypto/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ const (
// PublicKey is the type of Ed25519 public keys.
type PublicKey []byte

// Equal reports whether pub and x have the same value.
func (pub PublicKey) Equal(x crypto.PublicKey) bool {
xx, ok := x.(PublicKey)
if !ok {
return false
}
return bytes.Equal(pub, xx)
}

// PrivateKey is the type of Ed25519 private keys. It implements crypto.Signer.
type PrivateKey []byte

Expand Down
16 changes: 0 additions & 16 deletions src/crypto/ed25519/ed25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,6 @@ func TestCryptoSigner(t *testing.T) {
}
}

func TestEqual(t *testing.T) {
public, private, _ := GenerateKey(rand.Reader)

if !public.Equal(public) {
t.Errorf("public key is not equal to itself: %q", public)
}
if !public.Equal(crypto.Signer(private).Public().(PublicKey)) {
t.Errorf("private.Public() is not Equal to public: %q", public)
}

other, _, _ := GenerateKey(rand.Reader)
if public.Equal(other) {
t.Errorf("different public keys are Equal")
}
}

func TestGolden(t *testing.T) {
// sign.input.gz is a selection of test cases from
// https://ed25519.cr.yp.to/python/sign.input
Expand Down
42 changes: 0 additions & 42 deletions src/crypto/rsa/equal_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions src/crypto/rsa/rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ func (pub *PublicKey) Size() int {
return (pub.N.BitLen() + 7) / 8
}

// Equal reports whether pub and x have the same value.
func (pub *PublicKey) Equal(x crypto.PublicKey) bool {
xx, ok := x.(*PublicKey)
if !ok {
return false
}
return pub.N.Cmp(xx.N) == 0 && pub.E == xx.E
}

// OAEPOptions is an interface for passing options to OAEP decryption using the
// crypto.Decrypter interface.
type OAEPOptions struct {
Expand Down

0 comments on commit fb2a634

Please sign in to comment.