From: Roland Shoemaker Date: Fri, 5 Nov 2021 18:08:36 +0000 (-0700) Subject: [dev.boringcrypto] all: merge master into dev.boringcrypto X-Git-Tag: go1.19beta1~484^2~35 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ed07c49cb6198ac11e1cacd6b6602b813d75db9c;p=gostls13.git [dev.boringcrypto] all: merge master into dev.boringcrypto Change-Id: I1aa33cabd0c55fe64994b08f8a3f7b6bbfb3282c --- ed07c49cb6198ac11e1cacd6b6602b813d75db9c diff --cc src/crypto/ecdsa/ecdsa.go index 1a7635ec2b,282596d2d2..4be0026b9a --- a/src/crypto/ecdsa/ecdsa.go +++ b/src/crypto/ecdsa/ecdsa.go @@@ -227,21 -200,8 +227,17 @@@ var errZeroParam = errors.New("zero par func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error) { randutil.MaybeReadByte(rand) + if boring.Enabled && rand == boring.RandReader { + b, err := boringPrivateKey(priv) + if err != nil { + return nil, nil, err + } + return boring.SignECDSA(b, hash) + } + boring.UnreachableExceptTests() + - // Get min(log2(q) / 2, 256) bits of entropy from rand. - entropylen := (priv.Curve.Params().BitSize + 7) / 16 - if entropylen > 32 { - entropylen = 32 - } - entropy := make([]byte, entropylen) + // Get 256 bits of entropy from rand. + entropy := make([]byte, 32) _, err = io.ReadFull(rand, entropy) if err != nil { return diff --cc src/crypto/sha1/sha1_test.go index e369c3b7f4,ab43c7792d..f1a5448dd2 --- a/src/crypto/sha1/sha1_test.go +++ b/src/crypto/sha1/sha1_test.go @@@ -218,6 -210,20 +218,23 @@@ func TestLargeHashes(t *testing.T) } } + func TestAllocations(t *testing.T) { ++ if boring.Enabled { ++ t.Skip("BoringCrypto doesn't allocate the same way as stdlib") ++ } + in := []byte("hello, world!") + out := make([]byte, 0, Size) + h := New() + n := int(testing.AllocsPerRun(10, func() { + h.Reset() + h.Write(in) + out = h.Sum(out[:0]) + })) + if n > 0 { + t.Errorf("allocs = %d, want 0", n) + } + } + var bench = New() var buf = make([]byte, 8192) diff --cc src/crypto/sha256/sha256_test.go index 91a4edde04,702aa0b371..a762afc4d9 --- a/src/crypto/sha256/sha256_test.go +++ b/src/crypto/sha256/sha256_test.go @@@ -294,6 -289,20 +294,23 @@@ func TestLargeHashes(t *testing.T) } } + func TestAllocations(t *testing.T) { ++ if boring.Enabled { ++ t.Skip("BoringCrypto doesn't allocate the same way as stdlib") ++ } + in := []byte("hello, world!") + out := make([]byte, 0, Size) + h := New() + n := int(testing.AllocsPerRun(10, func() { + h.Reset() + h.Write(in) + out = h.Sum(out[:0]) + })) + if n > 0 { + t.Errorf("allocs = %d, want 0", n) + } + } + var bench = New() var buf = make([]byte, 8192) diff --cc src/crypto/sha512/sha512_test.go index 966cd51d15,aea772c7da..99d1423527 --- a/src/crypto/sha512/sha512_test.go +++ b/src/crypto/sha512/sha512_test.go @@@ -893,6 -888,20 +893,23 @@@ func TestLargeHashes(t *testing.T) } } + func TestAllocations(t *testing.T) { ++ if boring.Enabled { ++ t.Skip("BoringCrypto doesn't allocate the same way as stdlib") ++ } + in := []byte("hello, world!") + out := make([]byte, 0, Size) + h := New() + n := int(testing.AllocsPerRun(10, func() { + h.Reset() + h.Write(in) + out = h.Sum(out[:0]) + })) + if n > 0 { + t.Errorf("allocs = %d, want 0", n) + } + } + var bench = New() var buf = make([]byte, 8192) diff --cc src/go/build/deps_test.go index 7e43445a07,1dd65d60d9..9b5dabf6f1 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@@ -398,13 -407,18 +410,14 @@@ var depsRules = < crypto/subtle < crypto/internal/subtle < crypto/elliptic/internal/fiat - < crypto/ed25519/internal/edwards25519/field + < crypto/elliptic/internal/nistec + < crypto/ed25519/internal/edwards25519/field, golang.org/x/crypto/curve25519/internal/field < crypto/ed25519/internal/edwards25519 < crypto/cipher + < encoding/asn1 + < crypto/internal/boring < crypto/aes, crypto/des, crypto/hmac, crypto/md5, crypto/rc4, crypto/sha1, crypto/sha256, crypto/sha512 - < CRYPTO; - - CGO, fmt, net !< CRYPTO; - - # CRYPTO-MATH is core bignum-based crypto - no cgo, net; fmt now ok. - CRYPTO, FMT, math/big < crypto/rand < crypto/internal/randutil < crypto/ed25519