From e845f572ec6163fd3bad0267b5bb4f24d369bd93 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Apr 2022 09:02:53 -0400 Subject: [dev.boringcrypto] crypto/ecdsa, crypto/rsa: use boring.Cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the original BoringCrypto port, ecdsa and rsa's public and private keys added a 'boring unsafe.Pointer' field to cache the BoringCrypto form of the key. This led to problems with code that “knew” the layout of those structs and in particular that they had no unexported fields. In response, as an awful kludge, I changed the compiler to pretend that field did not exist when laying out reflect data. Because we want to merge BoringCrypto in the main tree, we need a different solution. Using boring.Cache is that solution. For #51940. Change-Id: Ideb2b40b599a1dc223082eda35a5ea9abcc01e30 Reviewed-on: https://go-review.googlesource.com/c/go/+/395883 Run-TryBot: Russ Cox TryBot-Result: Gopher Robot Reviewed-by: Roland Shoemaker --- src/crypto/ecdsa/ecdsa.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/crypto/ecdsa/ecdsa.go') diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go index efc5dd5067..7ce7542872 100644 --- a/src/crypto/ecdsa/ecdsa.go +++ b/src/crypto/ecdsa/ecdsa.go @@ -31,15 +31,12 @@ import ( "io" "math/big" + "crypto/internal/boring" + "golang.org/x/crypto/cryptobyte" "golang.org/x/crypto/cryptobyte/asn1" ) -import ( - "crypto/internal/boring" - "unsafe" -) - // A invertible implements fast inverse in GF(N). type invertible interface { // Inverse returns the inverse of k mod Params().N. @@ -60,8 +57,6 @@ const ( type PublicKey struct { elliptic.Curve X, Y *big.Int - - boring unsafe.Pointer } // Any methods implemented on PublicKey might need to also be implemented on @@ -89,8 +84,6 @@ func (pub *PublicKey) Equal(x crypto.PublicKey) bool { type PrivateKey struct { PublicKey D *big.Int - - boring unsafe.Pointer } // Public returns the public key corresponding to priv. -- cgit v1.2.3-54-g00ecf