diff options
author | Dmitri Shuralyov <dmitshur@golang.org> | 2020-05-07 23:27:25 -0400 |
---|---|---|
committer | Dmitri Shuralyov <dmitshur@golang.org> | 2020-05-07 23:31:52 -0400 |
commit | dd98c0ca3f19a8de7a8422c92839ff985f9827e4 (patch) | |
tree | 6f13317816f13a9cdddf2561a70c6757ab6331b2 /src/crypto/ecdsa/ecdsa.go | |
parent | a9d2e3abf772ee2c49394430545df1fa83699f04 (diff) | |
parent | 7d232ab276fe81c1c8552d4a809af7a593bb294b (diff) | |
download | go-dd98c0ca3f19a8de7a8422c92839ff985f9827e4.tar.gz go-dd98c0ca3f19a8de7a8422c92839ff985f9827e4.zip |
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: I083d1e4e997b30d9fab10940401eaf160e36f6c1
Diffstat (limited to 'src/crypto/ecdsa/ecdsa.go')
-rw-r--r-- | src/crypto/ecdsa/ecdsa.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go index 08a0533aa7..04738cdbd7 100644 --- a/src/crypto/ecdsa/ecdsa.go +++ b/src/crypto/ecdsa/ecdsa.go @@ -69,6 +69,9 @@ type PublicKey struct { boring unsafe.Pointer } +// Any methods implemented on PublicKey might need to also be implemented on +// PrivateKey, as the latter embeds the former and will expose its methods. + // 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. @@ -100,6 +103,17 @@ func (priv *PrivateKey) Public() crypto.PublicKey { return &priv.PublicKey } +// Equal reports whether priv and x have the same value. +// +// See PublicKey.Equal for details on how Curve is compared. +func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool { + xx, ok := x.(*PrivateKey) + if !ok { + return false + } + return priv.PublicKey.Equal(&xx.PublicKey) && priv.D.Cmp(xx.D) == 0 +} + // Sign signs digest with priv, reading randomness from rand. The opts argument // is not currently used but, in keeping with the crypto.Signer interface, // should be the hash function used to digest the message. |