From 2163a5802103ebe84cbf0d77cee7097185bd8e8d Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 17 Oct 2025 12:40:05 +0200 Subject: [PATCH] crypto/internal/fips140/entropy: increase AllocsPerRun iterations TestNISTECAllocations is flaky (~1% failure rate) on my local Windows machine since CL 710058, which touched TestEntropyRace. These tests are unrelated, but some allocations might be incorrectly accounted to TestNISTECAllocations, affecting the end result due to the low number of iterations done in that test. Change-Id: I01323c2a45b12665e86d940467f4f91c2e66696b Reviewed-on: https://go-review.googlesource.com/c/go/+/712620 Reviewed-by: David Chase Reviewed-by: Roland Shoemaker Auto-Submit: Quim Muntal LUCI-TryBot-Result: Go LUCI --- src/crypto/internal/fips140test/nistec_test.go | 8 ++++---- src/crypto/internal/fips140test/xaes_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/crypto/internal/fips140test/nistec_test.go b/src/crypto/internal/fips140test/nistec_test.go index 3b3de2bc2c..9b4b7cba7f 100644 --- a/src/crypto/internal/fips140test/nistec_test.go +++ b/src/crypto/internal/fips140test/nistec_test.go @@ -18,7 +18,7 @@ import ( func TestNISTECAllocations(t *testing.T) { cryptotest.SkipTestAllocations(t) t.Run("P224", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { + if allocs := testing.AllocsPerRun(100, func() { p := nistec.NewP224Point().SetGenerator() scalar := make([]byte, 28) rand.Read(scalar) @@ -37,7 +37,7 @@ func TestNISTECAllocations(t *testing.T) { } }) t.Run("P256", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { + if allocs := testing.AllocsPerRun(100, func() { p := nistec.NewP256Point().SetGenerator() scalar := make([]byte, 32) rand.Read(scalar) @@ -56,7 +56,7 @@ func TestNISTECAllocations(t *testing.T) { } }) t.Run("P384", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { + if allocs := testing.AllocsPerRun(100, func() { p := nistec.NewP384Point().SetGenerator() scalar := make([]byte, 48) rand.Read(scalar) @@ -75,7 +75,7 @@ func TestNISTECAllocations(t *testing.T) { } }) t.Run("P521", func(t *testing.T) { - if allocs := testing.AllocsPerRun(10, func() { + if allocs := testing.AllocsPerRun(100, func() { p := nistec.NewP521Point().SetGenerator() scalar := make([]byte, 66) rand.Read(scalar) diff --git a/src/crypto/internal/fips140test/xaes_test.go b/src/crypto/internal/fips140test/xaes_test.go index 9406bfab7b..c852832fce 100644 --- a/src/crypto/internal/fips140test/xaes_test.go +++ b/src/crypto/internal/fips140test/xaes_test.go @@ -21,7 +21,7 @@ func TestXAESAllocations(t *testing.T) { t.Skip("Test reports non-zero allocation count. See issue #70448") } cryptotest.SkipTestAllocations(t) - if allocs := testing.AllocsPerRun(10, func() { + if allocs := testing.AllocsPerRun(100, func() { key := make([]byte, 32) nonce := make([]byte, 24) plaintext := make([]byte, 16) -- 2.52.0