func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error) {
randutil.MaybeReadByte(rand)
- // 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)
+ 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 256 bits of entropy from rand.
+ entropy := make([]byte, 32)
_, err = io.ReadFull(rand, entropy)
if err != nil {
return
}
}
+ 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)
}
}
+ 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)
}
}
+ 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)
< 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