Skip to content

Commit

Permalink
Merge branch 'microsoft/main' into dev/qmuntal/azl3-clonehash
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal authored Nov 6, 2024
2 parents 1bdd67d + 9431c26 commit e61cc80
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 27 deletions.
45 changes: 44 additions & 1 deletion patches/0002-Add-crypto-backend-foundation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,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 +
53 files changed, 878 insertions(+), 106 deletions(-)
56 files changed, 893 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 @@ -67,6 +70,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 @@ -1961,6 +1966,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
45 changes: 22 additions & 23 deletions patches/0005-Add-CNG-crypto-backend.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ Subject: [PATCH] Add CNG crypto backend
src/go.sum | 2 +
src/go/build/deps_test.go | 5 +
src/go/build/vendor_test.go | 1 +
src/hash/boring_test.go | 2 +-
src/hash/example_test.go | 2 +
src/hash/marshal_test.go | 4 +
src/hash/notboring_test.go | 2 +-
.../goexperiment/exp_cngcrypto_off.go | 9 +
src/internal/goexperiment/exp_cngcrypto_on.go | 9 +
src/internal/goexperiment/flags.go | 1 +
35 files changed, 377 insertions(+), 25 deletions(-)
36 files changed, 375 insertions(+), 27 deletions(-)
create mode 100644 src/crypto/ecdsa/badlinkname.go
create mode 100644 src/crypto/internal/backend/bbig/big_cng.go
create mode 100644 src/crypto/internal/backend/cng_windows.go
Expand Down Expand Up @@ -748,6 +749,16 @@ index 7c821ae4bc5727..1d0b9b20e9b1d4 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 802c0f8b8987bf..99e1933f84b52c 100644
--- a/src/hash/boring_test.go
+++ b/src/hash/boring_test.go
@@ -1,4 +1,4 @@
-//go:build goexperiment.boringcrypto || goexperiment.opensslcrypto
+//go:build goexperiment.boringcrypto || goexperiment.opensslcrypto || goexperiment.cngcrypto

package hash_test

diff --git a/src/hash/example_test.go b/src/hash/example_test.go
index f07b9aaa2c4898..2ff6c4827391c0 100644
--- a/src/hash/example_test.go
Expand All @@ -761,28 +772,16 @@ index f07b9aaa2c4898..2ff6c4827391c0 100644
package hash_test

import (
diff --git a/src/hash/marshal_test.go b/src/hash/marshal_test.go
index 3091f7a67acede..824be4a90fd4db 100644
--- a/src/hash/marshal_test.go
+++ b/src/hash/marshal_test.go
@@ -21,6 +21,7 @@ import (
"hash/crc32"
"hash/crc64"
"hash/fnv"
+ "internal/goexperiment"
"testing"
)
diff --git a/src/hash/notboring_test.go b/src/hash/notboring_test.go
index f3e8ed3e1cbf20..a85fc430cfa655 100644
--- a/src/hash/notboring_test.go
+++ b/src/hash/notboring_test.go
@@ -1,4 +1,4 @@
-//go:build !goexperiment.boringcrypto && !goexperiment.opensslcrypto
+//go:build !goexperiment.boringcrypto && !goexperiment.opensslcrypto && !goexperiment.cngcrypto

package hash_test

@@ -76,6 +77,9 @@ func TestMarshalHash(t *testing.T) {
}
h2m, ok := h2.(encoding.BinaryMarshaler)
if !ok {
+ if goexperiment.CNGCrypto {
+ t.Skip("CNGCrypto does not hash marshaling")
+ }
t.Fatalf("Hash does not implement MarshalBinary")
}
enc, err := h2m.MarshalBinary()
diff --git a/src/internal/goexperiment/exp_cngcrypto_off.go b/src/internal/goexperiment/exp_cngcrypto_off.go
new file mode 100644
index 00000000000000..831460053281e2
Expand Down

0 comments on commit e61cc80

Please sign in to comment.