Skip to content

Commit e62fc43

Browse files
eliasnaurdeadprogram
authored andcommitted
crypto/x509/internal/macos: add package stub to build crypto/x509 on macOS
1 parent 158be02 commit e62fc43

File tree

3 files changed

+213
-24
lines changed

3 files changed

+213
-24
lines changed

GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ TEST_PACKAGES_FAST = \
310310
container/list \
311311
container/ring \
312312
crypto/des \
313+
crypto/ecdsa \
313314
crypto/elliptic \
314315
crypto/md5 \
315316
crypto/rc4 \

loader/goroot.go

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -229,30 +229,33 @@ func needsSyscallPackage(buildTags []string) bool {
229229
// means use the TinyGo version.
230230
func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
231231
paths := map[string]bool{
232-
"": true,
233-
"crypto/": true,
234-
"crypto/rand/": false,
235-
"crypto/tls/": false,
236-
"device/": false,
237-
"examples/": false,
238-
"internal/": true,
239-
"internal/abi/": false,
240-
"internal/binary/": false,
241-
"internal/bytealg/": false,
242-
"internal/cm/": false,
243-
"internal/fuzz/": false,
244-
"internal/reflectlite/": false,
245-
"internal/task/": false,
246-
"internal/wasi/": false,
247-
"machine/": false,
248-
"net/": true,
249-
"net/http/": false,
250-
"os/": true,
251-
"reflect/": false,
252-
"runtime/": false,
253-
"sync/": true,
254-
"testing/": true,
255-
"unique/": false,
232+
"": true,
233+
"crypto/": true,
234+
"crypto/rand/": false,
235+
"crypto/tls/": false,
236+
"crypto/x509/": true,
237+
"crypto/x509/internal/": true,
238+
"crypto/x509/internal/macos/": false,
239+
"device/": false,
240+
"examples/": false,
241+
"internal/": true,
242+
"internal/abi/": false,
243+
"internal/binary/": false,
244+
"internal/bytealg/": false,
245+
"internal/cm/": false,
246+
"internal/fuzz/": false,
247+
"internal/reflectlite/": false,
248+
"internal/task/": false,
249+
"internal/wasi/": false,
250+
"machine/": false,
251+
"net/": true,
252+
"net/http/": false,
253+
"os/": true,
254+
"reflect/": false,
255+
"runtime/": false,
256+
"sync/": true,
257+
"testing/": true,
258+
"unique/": false,
256259
}
257260

258261
if goMinor >= 19 {
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
package macos
2+
3+
import (
4+
"errors"
5+
"time"
6+
)
7+
8+
// Exported symbols copied from Big Go, but stripped of functionality.
9+
// Allows building of crypto/x509 on macOS.
10+
11+
const (
12+
ErrSecCertificateExpired = -67818
13+
ErrSecHostNameMismatch = -67602
14+
ErrSecNotTrusted = -67843
15+
)
16+
17+
var ErrNoTrustSettings = errors.New("no trust settings found")
18+
var SecPolicyAppleSSL = StringToCFString("1.2.840.113635.100.1.3") // defined by POLICYMACRO
19+
var SecPolicyOid = StringToCFString("SecPolicyOid")
20+
var SecTrustSettingsPolicy = StringToCFString("kSecTrustSettingsPolicy")
21+
var SecTrustSettingsPolicyString = StringToCFString("kSecTrustSettingsPolicyString")
22+
var SecTrustSettingsResultKey = StringToCFString("kSecTrustSettingsResult")
23+
24+
func CFArrayAppendValue(array CFRef, val CFRef) {}
25+
26+
func CFArrayGetCount(array CFRef) int {
27+
return 0
28+
}
29+
30+
func CFDataGetBytePtr(data CFRef) uintptr {
31+
return 0
32+
}
33+
34+
func CFDataGetLength(data CFRef) int {
35+
return 0
36+
}
37+
38+
func CFDataToSlice(data CFRef) []byte {
39+
return nil
40+
}
41+
42+
func CFEqual(a, b CFRef) bool {
43+
return false
44+
}
45+
46+
func CFErrorGetCode(errRef CFRef) int {
47+
return 0
48+
}
49+
50+
func CFNumberGetValue(num CFRef) (int32, error) {
51+
return 0, errors.New("not implemented")
52+
}
53+
54+
func CFRelease(ref CFRef) {}
55+
56+
func CFStringToString(ref CFRef) string {
57+
return ""
58+
}
59+
60+
func ReleaseCFArray(array CFRef) {}
61+
62+
func SecCertificateCopyData(cert CFRef) ([]byte, error) {
63+
return nil, errors.New("not implemented")
64+
}
65+
66+
func SecTrustEvaluateWithError(trustObj CFRef) (int, error) {
67+
return 0, errors.New("not implemented")
68+
}
69+
70+
func SecTrustGetCertificateCount(trustObj CFRef) int {
71+
return 0
72+
}
73+
74+
func SecTrustGetResult(trustObj CFRef, result CFRef) (CFRef, CFRef, error) {
75+
return 0, 0, errors.New("not implemented")
76+
}
77+
78+
func SecTrustSetVerifyDate(trustObj CFRef, dateRef CFRef) error {
79+
return errors.New("not implemented")
80+
}
81+
82+
type CFRef uintptr
83+
84+
func BytesToCFData(b []byte) CFRef {
85+
return 0
86+
}
87+
88+
func CFArrayCreateMutable() CFRef {
89+
return 0
90+
}
91+
92+
func CFArrayGetValueAtIndex(array CFRef, index int) CFRef {
93+
return 0
94+
}
95+
96+
func CFDateCreate(seconds float64) CFRef {
97+
return 0
98+
}
99+
100+
func CFDictionaryGetValueIfPresent(dict CFRef, key CFString) (value CFRef, ok bool) {
101+
return 0, false
102+
}
103+
104+
func CFErrorCopyDescription(errRef CFRef) CFRef {
105+
return 0
106+
}
107+
108+
func CFStringCreateExternalRepresentation(strRef CFRef) (CFRef, error) {
109+
return 0, errors.New("not implemented")
110+
}
111+
112+
func SecCertificateCreateWithData(b []byte) (CFRef, error) {
113+
return 0, errors.New("not implemented")
114+
}
115+
116+
func SecPolicyCreateSSL(name string) (CFRef, error) {
117+
return 0, errors.New("not implemented")
118+
}
119+
120+
func SecTrustCreateWithCertificates(certs CFRef, policies CFRef) (CFRef, error) {
121+
return 0, errors.New("not implemented")
122+
}
123+
124+
func SecTrustEvaluate(trustObj CFRef) (CFRef, error) {
125+
return 0, errors.New("not implemented")
126+
}
127+
128+
func SecTrustGetCertificateAtIndex(trustObj CFRef, i int) (CFRef, error) {
129+
return 0, errors.New("not implemented")
130+
}
131+
132+
func SecTrustSettingsCopyCertificates(domain SecTrustSettingsDomain) (certArray CFRef, err error) {
133+
return 0, errors.New("not implemented")
134+
}
135+
136+
func SecTrustSettingsCopyTrustSettings(cert CFRef, domain SecTrustSettingsDomain) (trustSettings CFRef, err error) {
137+
return 0, errors.New("not implemented")
138+
}
139+
140+
func TimeToCFDateRef(t time.Time) CFRef {
141+
return 0
142+
}
143+
144+
type CFString CFRef
145+
146+
func StringToCFString(s string) CFString {
147+
return 0
148+
}
149+
150+
type OSStatus struct {
151+
// Has unexported fields.
152+
}
153+
154+
func (s OSStatus) Error() string
155+
156+
type SecTrustResultType int32
157+
158+
const (
159+
SecTrustResultInvalid SecTrustResultType = iota
160+
SecTrustResultProceed
161+
SecTrustResultConfirm // deprecated
162+
SecTrustResultDeny
163+
SecTrustResultUnspecified
164+
SecTrustResultRecoverableTrustFailure
165+
SecTrustResultFatalTrustFailure
166+
SecTrustResultOtherError
167+
)
168+
169+
type SecTrustSettingsDomain int32
170+
171+
const (
172+
SecTrustSettingsDomainUser SecTrustSettingsDomain = iota
173+
SecTrustSettingsDomainAdmin
174+
SecTrustSettingsDomainSystem
175+
)
176+
177+
type SecTrustSettingsResult int32
178+
179+
const (
180+
SecTrustSettingsResultInvalid SecTrustSettingsResult = iota
181+
SecTrustSettingsResultTrustRoot
182+
SecTrustSettingsResultTrustAsRoot
183+
SecTrustSettingsResultDeny
184+
SecTrustSettingsResultUnspecified
185+
)

0 commit comments

Comments
 (0)