Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip SHA test that require marshaling #1384

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 179 additions & 10 deletions patches/0002-Add-crypto-backend-foundation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Subject: [PATCH] Add crypto backend foundation
src/crypto/internal/backend/norequirefips.go | 9 +
src/crypto/internal/backend/stub.s | 10 +
src/crypto/md5/md5.go | 7 +
src/crypto/md5/md5_test.go | 4 +
src/crypto/md5/md5_test.go | 14 ++
src/crypto/purego_test.go | 2 +-
src/crypto/rand/rand.go | 2 +-
src/crypto/rand/rand_test.go | 2 +-
Expand All @@ -40,11 +40,11 @@ Subject: [PATCH] Add crypto backend foundation
src/crypto/rsa/rsa.go | 21 +-
src/crypto/rsa/rsa_test.go | 2 +-
src/crypto/sha1/sha1.go | 2 +-
src/crypto/sha1/sha1_test.go | 2 +-
src/crypto/sha1/sha1_test.go | 12 +-
src/crypto/sha256/sha256.go | 6 +-
src/crypto/sha256/sha256_test.go | 2 +-
src/crypto/sha256/sha256_test.go | 20 +-
src/crypto/sha512/sha512.go | 2 +-
src/crypto/sha512/sha512_test.go | 2 +-
src/crypto/sha512/sha512_test.go | 20 +-
src/crypto/tls/boring_test.go | 5 +
src/crypto/tls/cipher_suites.go | 2 +-
src/crypto/tls/handshake_client.go | 25 ++-
Expand All @@ -54,9 +54,12 @@ Subject: [PATCH] Add crypto backend foundation
src/crypto/tls/prf_test.go | 12 +-
src/crypto/x509/boring_test.go | 5 +
src/go/build/deps_test.go | 4 +
src/hash/boring_test.go | 5 +
src/hash/marshal_test.go | 5 +
src/hash/notboring_test.go | 5 +
src/net/smtp/smtp_test.go | 72 ++++---
src/runtime/runtime_boring.go | 5 +
52 files changed, 802 insertions(+), 106 deletions(-)
55 files changed, 873 insertions(+), 106 deletions(-)
create mode 100644 src/crypto/ed25519/boring.go
create mode 100644 src/crypto/ed25519/notboring.go
create mode 100644 src/crypto/internal/backend/backend_test.go
Expand All @@ -66,6 +69,8 @@ Subject: [PATCH] Add crypto backend foundation
create mode 100644 src/crypto/internal/backend/nobackend.go
create mode 100644 src/crypto/internal/backend/norequirefips.go
create mode 100644 src/crypto/internal/backend/stub.s
create mode 100644 src/hash/boring_test.go
create mode 100644 src/hash/notboring_test.go

diff --git a/src/crypto/aes/cipher.go b/src/crypto/aes/cipher.go
index cde2e45d2ca559..cf47a4fc57d8e2 100644
Expand Down Expand Up @@ -912,7 +917,7 @@ index c984c3f4968598..229dd457f8d53c 100644
d.Reset()
d.Write(data)
diff --git a/src/crypto/md5/md5_test.go b/src/crypto/md5/md5_test.go
index 6a8258a67e860c..3a973eebd284a4 100644
index 6a8258a67e860c..61ea6b5153f617 100644
--- a/src/crypto/md5/md5_test.go
+++ b/src/crypto/md5/md5_test.go
@@ -6,6 +6,7 @@ package md5
Expand All @@ -923,7 +928,19 @@ index 6a8258a67e860c..3a973eebd284a4 100644
"crypto/internal/cryptotest"
"crypto/rand"
"encoding"
@@ -157,6 +158,9 @@ func TestLarge(t *testing.T) {
@@ -88,6 +89,11 @@ func TestGolden(t *testing.T) {
}

func TestGoldenMarshal(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := New().(encoding.BinaryMarshaler); !ok {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
for _, g := range golden {
h := New()
h2 := New()
@@ -157,6 +163,9 @@ func TestLarge(t *testing.T) {

// Tests that blockGeneric (pure Go) and block (in assembly for amd64, 386, arm) match.
func TestBlockGeneric(t *testing.T) {
Expand All @@ -933,6 +950,18 @@ index 6a8258a67e860c..3a973eebd284a4 100644
gen, asm := New().(*digest), New().(*digest)
buf := make([]byte, BlockSize*20) // arbitrary factor
rand.Read(buf)
@@ -204,6 +213,11 @@ func safeSum(h hash.Hash) (sum []byte, err error) {
}

func TestLargeHashes(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := New().(encoding.BinaryUnmarshaler); !ok {
+ t.Skip("BinaryUnmarshaler not implemented")
+ }
+ }
for i, test := range largeUnmarshalTests {

h := New()
diff --git a/src/crypto/purego_test.go b/src/crypto/purego_test.go
index 62be347e0c6822..d284b5cf7814a6 100644
--- a/src/crypto/purego_test.go
Expand Down Expand Up @@ -1255,7 +1284,7 @@ index 8189d1946d8ea5..8f5f7f27f26fea 100644
"hash"
"internal/byteorder"
diff --git a/src/crypto/sha1/sha1_test.go b/src/crypto/sha1/sha1_test.go
index d03892c57d4e61..d44f70b92661b4 100644
index d03892c57d4e61..f848659c6e4aa3 100644
--- a/src/crypto/sha1/sha1_test.go
+++ b/src/crypto/sha1/sha1_test.go
@@ -8,7 +8,7 @@ package sha1
Expand All @@ -1267,6 +1296,30 @@ index d03892c57d4e61..d44f70b92661b4 100644
"crypto/internal/cryptotest"
"crypto/rand"
"encoding"
@@ -97,6 +97,11 @@ func TestGolden(t *testing.T) {
}

func TestGoldenMarshal(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := New().(encoding.BinaryMarshaler); !ok {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
h := New()
h2 := New()
for _, g := range golden {
@@ -210,6 +215,11 @@ func safeSum(h hash.Hash) (sum []byte, err error) {
}

func TestLargeHashes(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := New().(encoding.BinaryMarshaler); !ok {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
for i, test := range largeUnmarshalTests {

h := New()
diff --git a/src/crypto/sha256/sha256.go b/src/crypto/sha256/sha256.go
index d87c689c9001ad..7584c380af0cec 100644
--- a/src/crypto/sha256/sha256.go
Expand Down Expand Up @@ -1299,7 +1352,7 @@ index d87c689c9001ad..7584c380af0cec 100644
}
h := New224()
diff --git a/src/crypto/sha256/sha256_test.go b/src/crypto/sha256/sha256_test.go
index ffd16386515830..d2fa4369d068bf 100644
index ffd16386515830..58632c01dc6a7f 100644
--- a/src/crypto/sha256/sha256_test.go
+++ b/src/crypto/sha256/sha256_test.go
@@ -8,7 +8,7 @@ package sha256
Expand All @@ -1311,6 +1364,45 @@ index ffd16386515830..d2fa4369d068bf 100644
"crypto/internal/cryptotest"
"encoding"
"fmt"
@@ -157,6 +157,11 @@ func testGoldenMarshal(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := tt.newHash().(encoding.BinaryMarshaler); !ok {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
for _, g := range tt.gold {
h := tt.newHash()
h2 := tt.newHash()
@@ -206,6 +211,14 @@ func TestMarshalTypeMismatch(t *testing.T) {
h1 := New()
h2 := New224()

+ if boring.Enabled {
+ _, ok1 := h1.(encoding.BinaryMarshaler)
+ _, ok2 := h2.(encoding.BinaryUnmarshaler)
+ if !ok1 || !ok2 {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
+
state1, err := h1.(encoding.BinaryMarshaler).MarshalBinary()
if err != nil {
t.Errorf("could not marshal: %v", err)
@@ -277,6 +290,11 @@ func safeSum(h hash.Hash) (sum []byte, err error) {
return h.Sum(nil), nil
}
func TestLargeHashes(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := New().(encoding.BinaryUnmarshaler); !ok {
+ t.Skip("BinaryUnmarshaler not implemented")
+ }
+ }
for i, test := range largeUnmarshalTests {

h := New()
diff --git a/src/crypto/sha512/sha512.go b/src/crypto/sha512/sha512.go
index 0a12fde7bc060b..ca752598e4343a 100644
--- a/src/crypto/sha512/sha512.go
Expand All @@ -1325,7 +1417,7 @@ index 0a12fde7bc060b..ca752598e4343a 100644
"hash"
)
diff --git a/src/crypto/sha512/sha512_test.go b/src/crypto/sha512/sha512_test.go
index fdad37b1863ae8..736504b8fc85a5 100644
index fdad37b1863ae8..cf6e4c395cd4fb 100644
--- a/src/crypto/sha512/sha512_test.go
+++ b/src/crypto/sha512/sha512_test.go
@@ -8,7 +8,7 @@ package sha512
Expand All @@ -1337,6 +1429,45 @@ index fdad37b1863ae8..736504b8fc85a5 100644
"crypto/internal/cryptotest"
"encoding"
"encoding/hex"
@@ -746,6 +746,11 @@ func testGoldenMarshal(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, test := range tt.golden {
+ if boring.Enabled {
+ if _, ok := tt.newHash().(encoding.BinaryMarshaler); !ok {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
h := tt.newHash()
h2 := tt.newHash()

@@ -807,6 +812,14 @@ func TestMarshalMismatch(t *testing.T) {
h1 := fn1()
h2 := fn2()

+ if boring.Enabled {
+ _, ok1 := h1.(encoding.BinaryMarshaler)
+ _, ok2 := h2.(encoding.BinaryUnmarshaler)
+ if !ok1 || !ok2 {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
+
state, err := h1.(encoding.BinaryMarshaler).MarshalBinary()
if err != nil {
t.Errorf("i=%d: could not marshal: %v", i, err)
@@ -882,6 +895,11 @@ func safeSum(h hash.Hash) (sum []byte, err error) {
}

func TestLargeHashes(t *testing.T) {
+ if boring.Enabled {
+ if _, ok := New().(encoding.BinaryUnmarshaler); !ok {
+ t.Skip("BinaryUnmarshaler not implemented")
+ }
+ }
for i, test := range largeUnmarshalTests {

h := New()
diff --git a/src/crypto/tls/boring_test.go b/src/crypto/tls/boring_test.go
index 56050421985927..dcbd33167e4499 100644
--- a/src/crypto/tls/boring_test.go
Expand Down Expand Up @@ -1782,6 +1913,44 @@ index c6a2518f62ff3a..578b4d6f68504c 100644
< crypto/rand
< crypto/internal/mlkem768
< crypto/ed25519
diff --git a/src/hash/boring_test.go b/src/hash/boring_test.go
new file mode 100644
index 00000000000000..c90899062a9665
--- /dev/null
+++ b/src/hash/boring_test.go
@@ -0,0 +1,5 @@
+//go:build goexperiment.boringcrypto
+
+package hash_test
+
+const boringEnabled = true
diff --git a/src/hash/marshal_test.go b/src/hash/marshal_test.go
index 3091f7a67acede..fead8cc4bec73a 100644
--- a/src/hash/marshal_test.go
+++ b/src/hash/marshal_test.go
@@ -65,6 +65,11 @@ func TestMarshalHash(t *testing.T) {
}

h := tt.new()
+ if boringEnabled {
+ if _, ok := h.(encoding.BinaryMarshaler); !ok {
+ t.Skip("BinaryMarshaler not implemented")
+ }
+ }
h.Write(buf[:256])
sum := h.Sum(nil)

diff --git a/src/hash/notboring_test.go b/src/hash/notboring_test.go
new file mode 100644
index 00000000000000..79f8c22f2b7416
--- /dev/null
+++ b/src/hash/notboring_test.go
@@ -0,0 +1,5 @@
+//go:build !goexperiment.boringcrypto
+
+package hash_test
+
+const boringEnabled = false
diff --git a/src/net/smtp/smtp_test.go b/src/net/smtp/smtp_test.go
index 389eda9ad54b99..110d60beb0e70c 100644
--- a/src/net/smtp/smtp_test.go
Expand Down
28 changes: 25 additions & 3 deletions patches/0004-Add-OpenSSL-crypto-backend.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ Subject: [PATCH] Add OpenSSL crypto backend
src/go.sum | 2 +
src/go/build/deps_test.go | 7 +-
src/go/build/vendor_test.go | 1 +
src/hash/boring_test.go | 2 +-
src/hash/notboring_test.go | 2 +-
.../goexperiment/exp_opensslcrypto_off.go | 9 +
.../goexperiment/exp_opensslcrypto_on.go | 9 +
src/internal/goexperiment/flags.go | 1 +
src/os/exec/exec_test.go | 9 +
34 files changed, 406 insertions(+), 23 deletions(-)
36 files changed, 408 insertions(+), 25 deletions(-)
create mode 100644 src/crypto/internal/backend/bbig/big_openssl.go
create mode 100644 src/crypto/internal/backend/openssl_linux.go
create mode 100644 src/internal/goexperiment/exp_opensslcrypto_off.go
Expand Down Expand Up @@ -714,7 +716,7 @@ index c83a7272c9f01f..a0548a7f9179c5 100644
package x509

diff --git a/src/go.mod b/src/go.mod
index df27f25e789f05..3e9514234e7125 100644
index df27f25e789f05..12d8c8f4f97321 100644
--- a/src/go.mod
+++ b/src/go.mod
@@ -3,6 +3,7 @@ module std
Expand All @@ -726,7 +728,7 @@ index df27f25e789f05..3e9514234e7125 100644
golang.org/x/net v0.27.1-0.20240722181819-765c7e89b3bd
)
diff --git a/src/go.sum b/src/go.sum
index b4efd6d3c50c11..d159c7d47bac3b 100644
index b4efd6d3c50c11..4c3ca847c21cd2 100644
--- a/src/go.sum
+++ b/src/go.sum
@@ -1,3 +1,5 @@
Expand Down Expand Up @@ -786,6 +788,26 @@ index 7f6237ffd59c11..7c821ae4bc5727 100644
}

// Verify that the vendor directories contain only packages matching the list above.
diff --git a/src/hash/boring_test.go b/src/hash/boring_test.go
index c90899062a9665..802c0f8b8987bf 100644
--- a/src/hash/boring_test.go
+++ b/src/hash/boring_test.go
@@ -1,4 +1,4 @@
-//go:build goexperiment.boringcrypto
+//go:build goexperiment.boringcrypto || goexperiment.opensslcrypto

package hash_test

diff --git a/src/hash/notboring_test.go b/src/hash/notboring_test.go
index 79f8c22f2b7416..f3e8ed3e1cbf20 100644
--- a/src/hash/notboring_test.go
+++ b/src/hash/notboring_test.go
@@ -1,4 +1,4 @@
-//go:build !goexperiment.boringcrypto
+//go:build !goexperiment.boringcrypto && !goexperiment.opensslcrypto

package hash_test

diff --git a/src/internal/goexperiment/exp_opensslcrypto_off.go b/src/internal/goexperiment/exp_opensslcrypto_off.go
new file mode 100644
index 00000000000000..62033547c6143a
Expand Down
Loading
Loading