Skip to content

Commit

Permalink
fix patches
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Jan 9, 2025
1 parent f154f9f commit 2dfa2d3
Show file tree
Hide file tree
Showing 2 changed files with 1,150 additions and 950 deletions.
92 changes: 84 additions & 8 deletions patches/0006-Add-Darwin-crypto-backend.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Date: Tue, 17 Dec 2024 13:17:39 +0000
Subject: [PATCH] Add Darwin crypto backend

---
.gitignore | 2 +
src/cmd/go/go_boring_test.go | 9 +-
src/cmd/go/testdata/script/darwin_no_cgo.txt | 2 +
src/crypto/ecdsa/ecdsa.go | 6 +-
src/crypto/ed25519/ed25519_test.go | 3 +-
.../internal/backend/bbig/big_darwin.go | 12 +
Expand All @@ -21,19 +24,68 @@ Subject: [PATCH] Add Darwin crypto backend
.../goexperiment/exp_darwincrypto_off.go | 9 +
.../goexperiment/exp_darwincrypto_on.go | 9 +
src/internal/goexperiment/flags.go | 1 +
17 files changed, 502 insertions(+), 13 deletions(-)
src/runtime/pprof/vminfo_darwin_test.go | 6 +
21 files changed, 520 insertions(+), 14 deletions(-)
create mode 100644 src/crypto/internal/backend/bbig/big_darwin.go
create mode 100644 src/crypto/internal/backend/darwin_darwin.go
create mode 100644 src/crypto/internal/backend/fips140/darwin.go
create mode 100644 src/crypto/rsa/darwin.go
create mode 100644 src/internal/goexperiment/exp_darwincrypto_off.go
create mode 100644 src/internal/goexperiment/exp_darwincrypto_on.go

diff --git a/.gitignore b/.gitignore
index c6512e64a4ef39..b3b01db73b009d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,8 @@ _testmain.go
/test/run.out
/test/times.out

+!/src/vendor/github.com/microsoft/go-crypto-darwin/internal/cryptokit/CryptoKit.o
+
# This file includes artifacts of Go build that should not be checked in.
# For files created by specific development environment (e.g. editor),
# use alternative ways to exclude files from git.
diff --git a/src/cmd/go/go_boring_test.go b/src/cmd/go/go_boring_test.go
index 06478963f4be44..8111b143a1295b 100644
--- a/src/cmd/go/go_boring_test.go
+++ b/src/cmd/go/go_boring_test.go
@@ -6,9 +6,16 @@

package main_test

-import "testing"
+import (
+ "internal/goexperiment"
+ "testing"
+)

func TestBoringInternalLink(t *testing.T) {
+ if goexperiment.DarwinCrypto {
+ // https://github.com/microsoft/go-crypto-darwin/issues/33
+ t.Skip("skipping on Darwin")
+ }
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
diff --git a/src/cmd/go/testdata/script/darwin_no_cgo.txt b/src/cmd/go/testdata/script/darwin_no_cgo.txt
index fa445925b7c374..e36ac86fcaa58d 100644
--- a/src/cmd/go/testdata/script/darwin_no_cgo.txt
+++ b/src/cmd/go/testdata/script/darwin_no_cgo.txt
@@ -4,6 +4,8 @@
# of cmd/go, which imports approximately everything
# in std (certainly everything relevant).
[!GOOS:darwin] skip
+[GOEXPERIMENT:darwincrypto] skip
+[GOEXPERIMENT:systemcrypto] skip
go list -deps cmd/go
! stdout runtime/cgo

diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go
index 41ac17df22d7d7..84a7ba02c88620 100644
index 049da55bd70f2c..cd075f0efbc744 100644
--- a/src/crypto/ecdsa/ecdsa.go
+++ b/src/crypto/ecdsa/ecdsa.go
@@ -159,7 +159,7 @@ func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOp
@@ -161,7 +161,7 @@ func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOp
func GenerateKey(c elliptic.Curve, rand io.Reader) (*PrivateKey, error) {
randutil.MaybeReadByte(rand)

Expand All @@ -42,7 +94,7 @@ index 41ac17df22d7d7..84a7ba02c88620 100644
x, y, d, err := boring.GenerateKeyECDSA(c.Params().Name)
if err != nil {
return nil, err
@@ -208,7 +208,7 @@ var errNoAsm = errors.New("no assembly implementation available")
@@ -210,7 +210,7 @@ var errNoAsm = errors.New("no assembly implementation available")
func SignASN1(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) {
randutil.MaybeReadByte(rand)

Expand All @@ -51,7 +103,7 @@ index 41ac17df22d7d7..84a7ba02c88620 100644
b, err := boringPrivateKey(priv)
if err != nil {
return nil, err
@@ -319,7 +319,7 @@ func addASN1IntBytes(b *cryptobyte.Builder, bytes []byte) {
@@ -321,7 +321,7 @@ func addASN1IntBytes(b *cryptobyte.Builder, bytes []byte) {
// The inputs are not considered confidential, and may leak through timing side
// channels, or if an attacker has control of part of the inputs.
func VerifyASN1(pub *PublicKey, hash, sig []byte) bool {
Expand Down Expand Up @@ -688,7 +740,7 @@ index 7d7115cff81cea..d3ba67fe4d0611 100644
}
default:
diff --git a/src/go.mod b/src/go.mod
index 897c3802237b4e..0119f5ce8fe623 100644
index 96bdcd421e1129..f6d6bee65d0cd5 100644
--- a/src/go.mod
+++ b/src/go.mod
@@ -4,6 +4,7 @@ go 1.24
Expand All @@ -700,7 +752,7 @@ index 897c3802237b4e..0119f5ce8fe623 100644
golang.org/x/crypto v0.30.0
golang.org/x/net v0.32.1-0.20241206180132-552d8ac903a1
diff --git a/src/go.sum b/src/go.sum
index 7cece574a42291..6050c2fe0c5081 100644
index abebb59dcd7739..61b84a86e0e66c 100644
--- a/src/go.sum
+++ b/src/go.sum
@@ -1,5 +1,7 @@
Expand All @@ -712,7 +764,7 @@ index 7cece574a42291..6050c2fe0c5081 100644
github.com/microsoft/go-crypto-winnative v0.0.0-20250108090702-b49854c00e37/go.mod h1:JkxQeL8dGcyCuKjn1Etz4NmQrOMImMy4BA9hptEfVFA=
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index 1fcadbf6c19d79..b0da426bf18177 100644
index 997244c84e57c5..4b0585fe1bea25 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -519,6 +519,8 @@ var depsRules = `
Expand Down Expand Up @@ -795,3 +847,27 @@ index c6f64c18bdd13f..e6c9b7d5e62dc0 100644

// SystemCrypto enables the OpenSSL, CNG or Darwin crypto experiment depending on
// which one is appropriate on the target GOOS.
diff --git a/src/runtime/pprof/vminfo_darwin_test.go b/src/runtime/pprof/vminfo_darwin_test.go
index 6d375c5d53368a..39154b000ddc67 100644
--- a/src/runtime/pprof/vminfo_darwin_test.go
+++ b/src/runtime/pprof/vminfo_darwin_test.go
@@ -11,6 +11,7 @@ import (
"bytes"
"fmt"
"internal/abi"
+ "internal/goexperiment"
"internal/testenv"
"os"
"os/exec"
@@ -21,6 +22,11 @@ import (
)

func TestVMInfo(t *testing.T) {
+ if goexperiment.DarwinCrypto {
+ // Fails on macOS when using system crypto.
+ // https://github.com/microsoft/go/issues/1466
+ t.Skip("skipping on Darwin")
+ }
var begin, end, offset uint64
var filename string
first := true
Loading

0 comments on commit 2dfa2d3

Please sign in to comment.