@ttsc/darwin-x64 0.14.0-dev.20260529.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/go/VERSION +2 -2
- package/bin/go/bin/go +0 -0
- package/bin/go/bin/gofmt +0 -0
- package/bin/go/pkg/tool/darwin_amd64/asm +0 -0
- package/bin/go/pkg/tool/darwin_amd64/cgo +0 -0
- package/bin/go/pkg/tool/darwin_amd64/compile +0 -0
- package/bin/go/pkg/tool/darwin_amd64/cover +0 -0
- package/bin/go/pkg/tool/darwin_amd64/fix +0 -0
- package/bin/go/pkg/tool/darwin_amd64/link +0 -0
- package/bin/go/pkg/tool/darwin_amd64/preprofile +0 -0
- package/bin/go/pkg/tool/darwin_amd64/vet +0 -0
- package/bin/go/src/archive/tar/format.go +6 -0
- package/bin/go/src/archive/tar/reader.go +24 -4
- package/bin/go/src/builtin/builtin.go +13 -4
- package/bin/go/src/crypto/fips140/fips140.go +6 -0
- package/bin/go/src/crypto/internal/fips140/drbg/entropy_fips140.go +97 -0
- package/bin/go/src/crypto/internal/fips140/drbg/entropy_wasm.go +11 -0
- package/bin/go/src/crypto/internal/fips140/drbg/rand.go +1 -75
- package/bin/go/src/crypto/tls/conn.go +7 -3
- package/bin/go/src/crypto/tls/handshake_client_tls13.go +2 -2
- package/bin/go/src/crypto/tls/handshake_server_tls13.go +2 -2
- package/bin/go/src/crypto/tls/key_schedule.go +24 -3
- package/bin/go/src/crypto/x509/constraints.go +33 -33
- package/bin/go/src/crypto/x509/verify.go +28 -13
- package/bin/go/src/go/types/builtins.go +2 -2
- package/bin/go/src/go/types/signature.go +3 -0
- package/bin/go/src/go/types/under.go +3 -3
- package/bin/go/src/go.mod +1 -1
- package/bin/go/src/go.sum +2 -2
- package/bin/go/src/html/template/attr_string.go +3 -2
- package/bin/go/src/html/template/context.go +21 -1
- package/bin/go/src/html/template/element_string.go +3 -2
- package/bin/go/src/html/template/escape.go +16 -2
- package/bin/go/src/html/template/js.go +1 -0
- package/bin/go/src/html/template/state_string.go +5 -3
- package/bin/go/src/html/template/transition.go +43 -6
- package/bin/go/src/internal/buildcfg/zbootstrap.go +1 -1
- package/bin/go/src/internal/godebugs/table.go +1 -0
- package/bin/go/src/internal/poll/fd_windows.go +64 -38
- package/bin/go/src/internal/poll/fstatat_unix.go +22 -0
- package/bin/go/src/internal/poll/sendfile_windows.go +3 -1
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_386.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_amd64.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_arm.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_arm64.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_loong64.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_mips64x.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_mipsx.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_ppc64x.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_riscv64.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/defs_linux_s390x.go +1 -0
- package/bin/go/src/internal/runtime/syscall/linux/syscall_linux.go +14 -0
- package/bin/go/src/internal/syscall/unix/at.go +0 -17
- package/bin/go/src/internal/syscall/unix/at_sysnum_linux.go +2 -1
- package/bin/go/src/internal/syscall/unix/fchmodat_linux.go +51 -0
- package/bin/go/src/internal/syscall/unix/fchmodat_other.go +29 -0
- package/bin/go/src/internal/syscall/windows/at_windows.go +20 -3
- package/bin/go/src/internal/syscall/windows/registry/key.go +10 -2
- package/bin/go/src/internal/syscall/windows/registry/value.go +5 -1
- package/bin/go/src/internal/syscall/windows/syscall_windows.go +4 -0
- package/bin/go/src/internal/syscall/windows/types_windows.go +82 -0
- package/bin/go/src/internal/syscall/windows/zsyscall_windows.go +27 -0
- package/bin/go/src/net/cgo_unix.go +4 -1
- package/bin/go/src/net/http/doc.go +0 -1
- package/bin/go/src/net/http/h2_bundle.go +3 -3
- package/bin/go/src/net/http/httputil/reverseproxy.go +14 -0
- package/bin/go/src/net/lookup_windows.go +16 -3
- package/bin/go/src/net/mail/message.go +20 -9
- package/bin/go/src/net/sendfile.go +2 -0
- package/bin/go/src/net/sendfile_stub.go +2 -0
- package/bin/go/src/net/sendfile_windows.go +3 -0
- package/bin/go/src/net/url/url.go +22 -16
- package/bin/go/src/os/dir_darwin.go +2 -2
- package/bin/go/src/os/dir_unix.go +2 -2
- package/bin/go/src/os/file.go +0 -3
- package/bin/go/src/os/file_unix.go +9 -5
- package/bin/go/src/os/removeall_at.go +6 -2
- package/bin/go/src/os/removeall_unix.go +0 -8
- package/bin/go/src/os/removeall_windows.go +0 -4
- package/bin/go/src/os/root_unix.go +1 -0
- package/bin/go/src/os/stat.go +3 -0
- package/bin/go/src/os/statat.go +24 -0
- package/bin/go/src/os/statat_other.go +12 -0
- package/bin/go/src/os/statat_unix.go +20 -0
- package/bin/go/src/reflect/value.go +3 -2
- package/bin/go/src/runtime/defs_linux_386.go +4 -3
- package/bin/go/src/runtime/defs_linux_arm.go +4 -3
- package/bin/go/src/runtime/defs_linux_mips64x.go +1 -1
- package/bin/go/src/runtime/defs_linux_mipsx.go +5 -4
- package/bin/go/src/runtime/malloc.go +1 -53
- package/bin/go/src/runtime/mem.go +104 -9
- package/bin/go/src/runtime/metrics/doc.go +5 -0
- package/bin/go/src/runtime/os_linux.go +62 -0
- package/bin/go/src/runtime/os_linux32.go +14 -24
- package/bin/go/src/runtime/os_linux64.go +2 -0
- package/bin/go/src/runtime/print.go +16 -4
- package/bin/go/src/runtime/race/README +9 -9
- package/bin/go/src/runtime/race/internal/amd64v1/race_darwin.patch +63 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_darwin.syso +0 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_freebsd.patch +63 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_freebsd.syso +0 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_linux.patch +63 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_linux.syso +0 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_windows.patch +63 -0
- package/bin/go/src/runtime/race/internal/amd64v1/race_windows.syso +0 -0
- package/bin/go/src/runtime/race/internal/amd64v3/race_linux.patch +63 -0
- package/bin/go/src/runtime/race/internal/amd64v3/race_linux.syso +0 -0
- package/bin/go/src/runtime/race/race_darwin_arm64.patch +63 -0
- package/bin/go/src/runtime/race/race_darwin_arm64.syso +0 -0
- package/bin/go/src/runtime/race/race_linux_arm64.patch +63 -0
- package/bin/go/src/runtime/race/race_linux_arm64.syso +0 -0
- package/bin/go/src/runtime/race/race_linux_loong64.patch +63 -0
- package/bin/go/src/runtime/race/race_linux_loong64.syso +0 -0
- package/bin/go/src/runtime/race/race_linux_s390x.patch +63 -0
- package/bin/go/src/runtime/race/race_linux_s390x.syso +0 -0
- package/bin/go/src/syscall/syscall_windows.go +5 -1
- package/bin/go/src/vendor/modules.txt +1 -1
- package/bin/ttsc +0 -0
- package/bin/ttscserver +0 -0
- package/package.json +1 -1
package/bin/go/VERSION
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
go1.26.
|
|
2
|
-
time 2026-
|
|
1
|
+
go1.26.3
|
|
2
|
+
time 2026-05-04T20:36:18Z
|
package/bin/go/bin/go
CHANGED
|
Binary file
|
package/bin/go/bin/gofmt
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -147,6 +147,12 @@ const (
|
|
|
147
147
|
// Max length of a special file (PAX header, GNU long name or link).
|
|
148
148
|
// This matches the limit used by libarchive.
|
|
149
149
|
maxSpecialFileSize = 1 << 20
|
|
150
|
+
|
|
151
|
+
// Maximum number of sparse file entries.
|
|
152
|
+
// We should never actually hit this limit
|
|
153
|
+
// (every sparse encoding will first be limited by maxSpecialFileSize),
|
|
154
|
+
// but this adds an additional layer of defense.
|
|
155
|
+
maxSparseFileEntries = 1 << 20
|
|
150
156
|
)
|
|
151
157
|
|
|
152
158
|
// blockPadding computes the number of bytes needed to pad offset up to the
|
|
@@ -490,7 +490,8 @@ func (tr *Reader) readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, err
|
|
|
490
490
|
}
|
|
491
491
|
s := blk.toGNU().sparse()
|
|
492
492
|
spd := make(sparseDatas, 0, s.maxEntries())
|
|
493
|
-
|
|
493
|
+
totalSize := len(s)
|
|
494
|
+
for totalSize < maxSpecialFileSize {
|
|
494
495
|
for i := 0; i < s.maxEntries(); i++ {
|
|
495
496
|
// This termination condition is identical to GNU and BSD tar.
|
|
496
497
|
if s.entry(i).offset()[0] == 0x00 {
|
|
@@ -501,7 +502,11 @@ func (tr *Reader) readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, err
|
|
|
501
502
|
if p.err != nil {
|
|
502
503
|
return nil, p.err
|
|
503
504
|
}
|
|
504
|
-
|
|
505
|
+
var err error
|
|
506
|
+
spd, err = appendSparseEntry(spd, sparseEntry{Offset: offset, Length: length})
|
|
507
|
+
if err != nil {
|
|
508
|
+
return nil, err
|
|
509
|
+
}
|
|
505
510
|
}
|
|
506
511
|
|
|
507
512
|
if s.isExtended()[0] > 0 {
|
|
@@ -510,10 +515,12 @@ func (tr *Reader) readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, err
|
|
|
510
515
|
return nil, err
|
|
511
516
|
}
|
|
512
517
|
s = blk.toSparse()
|
|
518
|
+
totalSize += len(s)
|
|
513
519
|
continue
|
|
514
520
|
}
|
|
515
521
|
return spd, nil // Done
|
|
516
522
|
}
|
|
523
|
+
return nil, errSparseTooLong
|
|
517
524
|
}
|
|
518
525
|
|
|
519
526
|
// readGNUSparseMap1x0 reads the sparse map as stored in GNU's PAX sparse format
|
|
@@ -586,7 +593,10 @@ func readGNUSparseMap1x0(r io.Reader) (sparseDatas, error) {
|
|
|
586
593
|
if err1 != nil || err2 != nil {
|
|
587
594
|
return nil, ErrHeader
|
|
588
595
|
}
|
|
589
|
-
spd =
|
|
596
|
+
spd, err = appendSparseEntry(spd, sparseEntry{Offset: offset, Length: length})
|
|
597
|
+
if err != nil {
|
|
598
|
+
return nil, err
|
|
599
|
+
}
|
|
590
600
|
}
|
|
591
601
|
return spd, nil
|
|
592
602
|
}
|
|
@@ -620,12 +630,22 @@ func readGNUSparseMap0x1(paxHdrs map[string]string) (sparseDatas, error) {
|
|
|
620
630
|
if err1 != nil || err2 != nil {
|
|
621
631
|
return nil, ErrHeader
|
|
622
632
|
}
|
|
623
|
-
spd =
|
|
633
|
+
spd, err = appendSparseEntry(spd, sparseEntry{Offset: offset, Length: length})
|
|
634
|
+
if err != nil {
|
|
635
|
+
return nil, err
|
|
636
|
+
}
|
|
624
637
|
sparseMap = sparseMap[2:]
|
|
625
638
|
}
|
|
626
639
|
return spd, nil
|
|
627
640
|
}
|
|
628
641
|
|
|
642
|
+
func appendSparseEntry(spd sparseDatas, ent sparseEntry) (sparseDatas, error) {
|
|
643
|
+
if len(spd) >= maxSparseFileEntries {
|
|
644
|
+
return nil, errSparseTooLong
|
|
645
|
+
}
|
|
646
|
+
return append(spd, ent), nil
|
|
647
|
+
}
|
|
648
|
+
|
|
629
649
|
// Read reads from the current file in the tar archive.
|
|
630
650
|
// It returns (0, io.EOF) when it reaches the end of that file,
|
|
631
651
|
// until [Next] is called to advance to the next file.
|
|
@@ -122,6 +122,10 @@ type Type int
|
|
|
122
122
|
// invocation.
|
|
123
123
|
type Type1 int
|
|
124
124
|
|
|
125
|
+
// TypeOrExpr is here for the purposes of documentation only. It is a stand-in
|
|
126
|
+
// for either a Go type or an expression.
|
|
127
|
+
type TypeOrExpr int
|
|
128
|
+
|
|
125
129
|
// IntegerType is here for the purposes of documentation only. It is a stand-in
|
|
126
130
|
// for any integer type: int, uint, int8 etc.
|
|
127
131
|
type IntegerType int
|
|
@@ -220,10 +224,15 @@ func max[T cmp.Ordered](x T, y ...T) T
|
|
|
220
224
|
// min will return NaN.
|
|
221
225
|
func min[T cmp.Ordered](x T, y ...T) T
|
|
222
226
|
|
|
223
|
-
// The
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
+
// The built-in function new allocates a new, initialized variable and returns
|
|
228
|
+
// a pointer to it. It accepts a single argument, which may be either a type
|
|
229
|
+
// or an expression.
|
|
230
|
+
// If the argument is a type T, then new(T) allocates a variable of type T
|
|
231
|
+
// initialized to its zero value.
|
|
232
|
+
// Otherwise, the argument is an expression x and new(x) allocates a variable
|
|
233
|
+
// of the type of x initialized to the value of x. If that value is an untyped
|
|
234
|
+
// constant, it is first implicitly converted to its default type.
|
|
235
|
+
func new(TypeOrExpr) *Type
|
|
227
236
|
|
|
228
237
|
// The complex built-in function constructs a complex value from two
|
|
229
238
|
// floating-point values. The real and imaginary parts must be of the same
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
4
|
|
|
5
|
+
// Package fips140 provides information about the FIPS 140-3 Go Cryptographic
|
|
6
|
+
// Module and FIPS 140-3 mode.
|
|
7
|
+
//
|
|
8
|
+
// For more details, see the [FIPS 140-3 documentation].
|
|
9
|
+
//
|
|
10
|
+
// [FIPS 140-3 documentation]: https://go.dev/doc/security/fips140
|
|
5
11
|
package fips140
|
|
6
12
|
|
|
7
13
|
import (
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright 2026 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
//go:build !wasm
|
|
6
|
+
|
|
7
|
+
// This file contains reading from from entropy sources in FIPS-140
|
|
8
|
+
// mode. It uses a scratch buffer in the BSS section (see below),
|
|
9
|
+
// which usually doesn't cost much, except on Wasm, due to the way
|
|
10
|
+
// the linear memory works. FIPS-140 mode is not supported on Wasm,
|
|
11
|
+
// so we just use a build tag to exclude it. (Could also exclude other
|
|
12
|
+
// platforms that does not support FIPS-140 mode, but as the BSS
|
|
13
|
+
// variable doesn't cost much, don't bother.)
|
|
14
|
+
|
|
15
|
+
package drbg
|
|
16
|
+
|
|
17
|
+
import (
|
|
18
|
+
entropy "crypto/internal/entropy/v1.0.0"
|
|
19
|
+
"crypto/internal/sysrand"
|
|
20
|
+
"sync"
|
|
21
|
+
"sync/atomic"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// memory is a scratch buffer that is accessed between samples by the entropy
|
|
25
|
+
// source to expose it to memory access timings.
|
|
26
|
+
//
|
|
27
|
+
// We reuse it and share it between Seed calls to avoid the significant (~500µs)
|
|
28
|
+
// cost of zeroing a new allocation every time. The entropy source accesses it
|
|
29
|
+
// using atomics (and doesn't care about its contents).
|
|
30
|
+
//
|
|
31
|
+
// It should end up in the .noptrbss section, and become backed by physical pages
|
|
32
|
+
// at first use. This ensures that programs that do not use the FIPS 140-3 module
|
|
33
|
+
// do not incur any memory use or initialization penalties.
|
|
34
|
+
var memory entropy.ScratchBuffer
|
|
35
|
+
|
|
36
|
+
func getEntropy() *[SeedSize]byte {
|
|
37
|
+
var retries int
|
|
38
|
+
seed, err := entropy.Seed(&memory)
|
|
39
|
+
for err != nil {
|
|
40
|
+
// The CPU jitter-based SP 800-90B entropy source has a non-negligible
|
|
41
|
+
// chance of failing the startup health tests.
|
|
42
|
+
//
|
|
43
|
+
// Each time it does, it enters a permanent failure state, and we
|
|
44
|
+
// restart it anew. This is not expected to happen more than a few times
|
|
45
|
+
// in a row.
|
|
46
|
+
if retries++; retries > 100 {
|
|
47
|
+
panic("fips140/drbg: failed to obtain initial entropy")
|
|
48
|
+
}
|
|
49
|
+
seed, err = entropy.Seed(&memory)
|
|
50
|
+
}
|
|
51
|
+
return &seed
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// getEntropy is very slow (~500µs), so we don't want it on the hot path.
|
|
55
|
+
// We keep both a persistent DRBG instance and a pool of additional instances.
|
|
56
|
+
// Occasional uses will use drbgInstance, even if the pool was emptied since the
|
|
57
|
+
// last use. Frequent concurrent uses will fill the pool and use it.
|
|
58
|
+
var drbgInstance atomic.Pointer[Counter]
|
|
59
|
+
var drbgPool = sync.Pool{
|
|
60
|
+
New: func() any {
|
|
61
|
+
return NewCounter(getEntropy())
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func readFromEntropy(b []byte) {
|
|
66
|
+
// At every read, 128 random bits from the operating system are mixed as
|
|
67
|
+
// additional input, to make the output as strong as non-FIPS randomness.
|
|
68
|
+
// This is not credited as entropy for FIPS purposes, as allowed by Section
|
|
69
|
+
// 8.7.2: "Note that a DRBG does not rely on additional input to provide
|
|
70
|
+
// entropy, even though entropy could be provided in the additional input".
|
|
71
|
+
additionalInput := new([SeedSize]byte)
|
|
72
|
+
sysrand.Read(additionalInput[:16])
|
|
73
|
+
|
|
74
|
+
drbg := drbgInstance.Swap(nil)
|
|
75
|
+
if drbg == nil {
|
|
76
|
+
drbg = drbgPool.Get().(*Counter)
|
|
77
|
+
}
|
|
78
|
+
defer func() {
|
|
79
|
+
if !drbgInstance.CompareAndSwap(nil, drbg) {
|
|
80
|
+
drbgPool.Put(drbg)
|
|
81
|
+
}
|
|
82
|
+
}()
|
|
83
|
+
|
|
84
|
+
for len(b) > 0 {
|
|
85
|
+
size := min(len(b), maxRequestSize)
|
|
86
|
+
if reseedRequired := drbg.Generate(b[:size], additionalInput); reseedRequired {
|
|
87
|
+
// See SP 800-90A Rev. 1, Section 9.3.1, Steps 6-8, as explained in
|
|
88
|
+
// Section 9.3.2: if Generate reports a reseed is required, the
|
|
89
|
+
// additional input is passed to Reseed along with the entropy and
|
|
90
|
+
// then nulled before the next Generate call.
|
|
91
|
+
drbg.Reseed(getEntropy(), additionalInput)
|
|
92
|
+
additionalInput = nil
|
|
93
|
+
continue
|
|
94
|
+
}
|
|
95
|
+
b = b[size:]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2026 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
//go:build wasm
|
|
6
|
+
|
|
7
|
+
package drbg
|
|
8
|
+
|
|
9
|
+
func readFromEntropy(b []byte) {
|
|
10
|
+
panic("FIPS-140 entropy generation is not supported on Wasm")
|
|
11
|
+
}
|
|
@@ -9,55 +9,11 @@
|
|
|
9
9
|
package drbg
|
|
10
10
|
|
|
11
11
|
import (
|
|
12
|
-
entropy "crypto/internal/entropy/v1.0.0"
|
|
13
12
|
"crypto/internal/fips140"
|
|
14
13
|
"crypto/internal/sysrand"
|
|
15
14
|
"io"
|
|
16
|
-
"sync"
|
|
17
|
-
"sync/atomic"
|
|
18
15
|
)
|
|
19
16
|
|
|
20
|
-
// memory is a scratch buffer that is accessed between samples by the entropy
|
|
21
|
-
// source to expose it to memory access timings.
|
|
22
|
-
//
|
|
23
|
-
// We reuse it and share it between Seed calls to avoid the significant (~500µs)
|
|
24
|
-
// cost of zeroing a new allocation every time. The entropy source accesses it
|
|
25
|
-
// using atomics (and doesn't care about its contents).
|
|
26
|
-
//
|
|
27
|
-
// It should end up in the .noptrbss section, and become backed by physical pages
|
|
28
|
-
// at first use. This ensures that programs that do not use the FIPS 140-3 module
|
|
29
|
-
// do not incur any memory use or initialization penalties.
|
|
30
|
-
var memory entropy.ScratchBuffer
|
|
31
|
-
|
|
32
|
-
func getEntropy() *[SeedSize]byte {
|
|
33
|
-
var retries int
|
|
34
|
-
seed, err := entropy.Seed(&memory)
|
|
35
|
-
for err != nil {
|
|
36
|
-
// The CPU jitter-based SP 800-90B entropy source has a non-negligible
|
|
37
|
-
// chance of failing the startup health tests.
|
|
38
|
-
//
|
|
39
|
-
// Each time it does, it enters a permanent failure state, and we
|
|
40
|
-
// restart it anew. This is not expected to happen more than a few times
|
|
41
|
-
// in a row.
|
|
42
|
-
if retries++; retries > 100 {
|
|
43
|
-
panic("fips140/drbg: failed to obtain initial entropy")
|
|
44
|
-
}
|
|
45
|
-
seed, err = entropy.Seed(&memory)
|
|
46
|
-
}
|
|
47
|
-
return &seed
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// getEntropy is very slow (~500µs), so we don't want it on the hot path.
|
|
51
|
-
// We keep both a persistent DRBG instance and a pool of additional instances.
|
|
52
|
-
// Occasional uses will use drbgInstance, even if the pool was emptied since the
|
|
53
|
-
// last use. Frequent concurrent uses will fill the pool and use it.
|
|
54
|
-
var drbgInstance atomic.Pointer[Counter]
|
|
55
|
-
var drbgPool = sync.Pool{
|
|
56
|
-
New: func() any {
|
|
57
|
-
return NewCounter(getEntropy())
|
|
58
|
-
},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
17
|
// Read fills b with cryptographically secure random bytes. In FIPS mode, it
|
|
62
18
|
// uses an SP 800-90A Rev. 1 Deterministic Random Bit Generator (DRBG).
|
|
63
19
|
// Otherwise, it uses the operating system's random number generator.
|
|
@@ -76,37 +32,7 @@ func Read(b []byte) {
|
|
|
76
32
|
return
|
|
77
33
|
}
|
|
78
34
|
|
|
79
|
-
|
|
80
|
-
// additional input, to make the output as strong as non-FIPS randomness.
|
|
81
|
-
// This is not credited as entropy for FIPS purposes, as allowed by Section
|
|
82
|
-
// 8.7.2: "Note that a DRBG does not rely on additional input to provide
|
|
83
|
-
// entropy, even though entropy could be provided in the additional input".
|
|
84
|
-
additionalInput := new([SeedSize]byte)
|
|
85
|
-
sysrand.Read(additionalInput[:16])
|
|
86
|
-
|
|
87
|
-
drbg := drbgInstance.Swap(nil)
|
|
88
|
-
if drbg == nil {
|
|
89
|
-
drbg = drbgPool.Get().(*Counter)
|
|
90
|
-
}
|
|
91
|
-
defer func() {
|
|
92
|
-
if !drbgInstance.CompareAndSwap(nil, drbg) {
|
|
93
|
-
drbgPool.Put(drbg)
|
|
94
|
-
}
|
|
95
|
-
}()
|
|
96
|
-
|
|
97
|
-
for len(b) > 0 {
|
|
98
|
-
size := min(len(b), maxRequestSize)
|
|
99
|
-
if reseedRequired := drbg.Generate(b[:size], additionalInput); reseedRequired {
|
|
100
|
-
// See SP 800-90A Rev. 1, Section 9.3.1, Steps 6-8, as explained in
|
|
101
|
-
// Section 9.3.2: if Generate reports a reseed is required, the
|
|
102
|
-
// additional input is passed to Reseed along with the entropy and
|
|
103
|
-
// then nulled before the next Generate call.
|
|
104
|
-
drbg.Reseed(getEntropy(), additionalInput)
|
|
105
|
-
additionalInput = nil
|
|
106
|
-
continue
|
|
107
|
-
}
|
|
108
|
-
b = b[size:]
|
|
109
|
-
}
|
|
35
|
+
readFromEntropy(b)
|
|
110
36
|
}
|
|
111
37
|
|
|
112
38
|
var testingReader io.Reader
|
|
@@ -1363,7 +1363,7 @@ func (c *Conn) handleKeyUpdate(keyUpdate *keyUpdateMsg) error {
|
|
|
1363
1363
|
}
|
|
1364
1364
|
|
|
1365
1365
|
newSecret := cipherSuite.nextTrafficSecret(c.in.trafficSecret)
|
|
1366
|
-
if err := c.setReadTrafficSecret(cipherSuite, QUICEncryptionLevelInitial, newSecret); err != nil {
|
|
1366
|
+
if err := c.setReadTrafficSecret(cipherSuite, QUICEncryptionLevelInitial, newSecret, keyUpdate.updateRequested); err != nil {
|
|
1367
1367
|
return err
|
|
1368
1368
|
}
|
|
1369
1369
|
|
|
@@ -1683,12 +1683,16 @@ func (c *Conn) VerifyHostname(host string) error {
|
|
|
1683
1683
|
// setReadTrafficSecret sets the read traffic secret for the given encryption level. If
|
|
1684
1684
|
// being called at the same time as setWriteTrafficSecret, the caller must ensure the call
|
|
1685
1685
|
// to setWriteTrafficSecret happens first so any alerts are sent at the write level.
|
|
1686
|
-
func (c *Conn) setReadTrafficSecret(suite *cipherSuiteTLS13, level QUICEncryptionLevel, secret []byte) error {
|
|
1686
|
+
func (c *Conn) setReadTrafficSecret(suite *cipherSuiteTLS13, level QUICEncryptionLevel, secret []byte, locked bool) error {
|
|
1687
1687
|
// Ensure that there are no buffered handshake messages before changing the
|
|
1688
1688
|
// read keys, since that can cause messages to be parsed that were encrypted
|
|
1689
1689
|
// using old keys which are no longer appropriate.
|
|
1690
1690
|
if c.hand.Len() != 0 {
|
|
1691
|
-
|
|
1691
|
+
if locked {
|
|
1692
|
+
c.sendAlertLocked(alertUnexpectedMessage)
|
|
1693
|
+
} else {
|
|
1694
|
+
c.sendAlert(alertUnexpectedMessage)
|
|
1695
|
+
}
|
|
1692
1696
|
return errors.New("tls: handshake buffer not empty before setting read traffic secret")
|
|
1693
1697
|
}
|
|
1694
1698
|
c.in.setTrafficSecret(suite, level, secret)
|
|
@@ -492,7 +492,7 @@ func (hs *clientHandshakeStateTLS13) establishHandshakeKeys() error {
|
|
|
492
492
|
clientSecret := handshakeSecret.ClientHandshakeTrafficSecret(hs.transcript)
|
|
493
493
|
c.setWriteTrafficSecret(hs.suite, QUICEncryptionLevelHandshake, clientSecret)
|
|
494
494
|
serverSecret := handshakeSecret.ServerHandshakeTrafficSecret(hs.transcript)
|
|
495
|
-
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelHandshake, serverSecret); err != nil {
|
|
495
|
+
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelHandshake, serverSecret, false); err != nil {
|
|
496
496
|
return err
|
|
497
497
|
}
|
|
498
498
|
|
|
@@ -711,7 +711,7 @@ func (hs *clientHandshakeStateTLS13) readServerFinished() error {
|
|
|
711
711
|
|
|
712
712
|
hs.trafficSecret = hs.masterSecret.ClientApplicationTrafficSecret(hs.transcript)
|
|
713
713
|
serverSecret := hs.masterSecret.ServerApplicationTrafficSecret(hs.transcript)
|
|
714
|
-
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelApplication, serverSecret); err != nil {
|
|
714
|
+
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelApplication, serverSecret, false); err != nil {
|
|
715
715
|
return err
|
|
716
716
|
}
|
|
717
717
|
|
|
@@ -752,7 +752,7 @@ func (hs *serverHandshakeStateTLS13) sendServerParameters() error {
|
|
|
752
752
|
serverSecret := hs.handshakeSecret.ServerHandshakeTrafficSecret(hs.transcript)
|
|
753
753
|
c.setWriteTrafficSecret(hs.suite, QUICEncryptionLevelHandshake, serverSecret)
|
|
754
754
|
clientSecret := hs.handshakeSecret.ClientHandshakeTrafficSecret(hs.transcript)
|
|
755
|
-
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelHandshake, clientSecret); err != nil {
|
|
755
|
+
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelHandshake, clientSecret, false); err != nil {
|
|
756
756
|
return err
|
|
757
757
|
}
|
|
758
758
|
|
|
@@ -1136,7 +1136,7 @@ func (hs *serverHandshakeStateTLS13) readClientFinished() error {
|
|
|
1136
1136
|
return errors.New("tls: invalid client finished hash")
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
|
-
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelApplication, hs.trafficSecret); err != nil {
|
|
1139
|
+
if err := c.setReadTrafficSecret(hs.suite, QUICEncryptionLevelApplication, hs.trafficSecret, false); err != nil {
|
|
1140
1140
|
return err
|
|
1141
1141
|
}
|
|
1142
1142
|
|
|
@@ -7,6 +7,7 @@ package tls
|
|
|
7
7
|
import (
|
|
8
8
|
"crypto"
|
|
9
9
|
"crypto/ecdh"
|
|
10
|
+
"crypto/fips140"
|
|
10
11
|
"crypto/hmac"
|
|
11
12
|
"crypto/internal/fips140/tls13"
|
|
12
13
|
"crypto/mlkem"
|
|
@@ -165,7 +166,14 @@ type hybridKeyExchange struct {
|
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
func (ke *hybridKeyExchange) keyShares(rand io.Reader) (*keySharePrivateKeys, []keyShare, error) {
|
|
168
|
-
|
|
169
|
+
var (
|
|
170
|
+
priv *keySharePrivateKeys
|
|
171
|
+
ecdhShares []keyShare
|
|
172
|
+
err error
|
|
173
|
+
)
|
|
174
|
+
fips140.WithoutEnforcement(func() { // Hybrid of ML-KEM, which is Approved.
|
|
175
|
+
priv, ecdhShares, err = ke.ecdh.keyShares(rand)
|
|
176
|
+
})
|
|
169
177
|
if err != nil {
|
|
170
178
|
return nil, nil, err
|
|
171
179
|
}
|
|
@@ -201,7 +209,14 @@ func (ke *hybridKeyExchange) serverSharedSecret(rand io.Reader, clientKeyShare [
|
|
|
201
209
|
ecdhShareData = clientKeyShare[:ke.ecdhElementSize]
|
|
202
210
|
mlkemShareData = clientKeyShare[ke.ecdhElementSize:]
|
|
203
211
|
}
|
|
204
|
-
|
|
212
|
+
var (
|
|
213
|
+
ecdhSharedSecret []byte
|
|
214
|
+
ks keyShare
|
|
215
|
+
err error
|
|
216
|
+
)
|
|
217
|
+
fips140.WithoutEnforcement(func() { // Hybrid of ML-KEM, which is Approved.
|
|
218
|
+
ecdhSharedSecret, ks, err = ke.ecdh.serverSharedSecret(rand, ecdhShareData)
|
|
219
|
+
})
|
|
205
220
|
if err != nil {
|
|
206
221
|
return nil, keyShare{}, err
|
|
207
222
|
}
|
|
@@ -234,7 +249,13 @@ func (ke *hybridKeyExchange) clientSharedSecret(priv *keySharePrivateKeys, serve
|
|
|
234
249
|
ecdhShareData = serverKeyShare[:ke.ecdhElementSize]
|
|
235
250
|
mlkemShareData = serverKeyShare[ke.ecdhElementSize:]
|
|
236
251
|
}
|
|
237
|
-
|
|
252
|
+
var (
|
|
253
|
+
ecdhSharedSecret []byte
|
|
254
|
+
err error
|
|
255
|
+
)
|
|
256
|
+
fips140.WithoutEnforcement(func() { // Hybrid of ML-KEM, which is Approved.
|
|
257
|
+
ecdhSharedSecret, err = ke.ecdh.clientSharedSecret(priv, ecdhShareData)
|
|
258
|
+
})
|
|
238
259
|
if err != nil {
|
|
239
260
|
return nil, err
|
|
240
261
|
}
|
|
@@ -58,11 +58,11 @@ import (
|
|
|
58
58
|
// of nameConstraintsSet, to handle constraints which define full email
|
|
59
59
|
// addresses (i.e. 'test@example.com'). For bare domain constraints, we use the
|
|
60
60
|
// dnsConstraints type described above, querying the domain portion of the email
|
|
61
|
-
// address. For full email addresses, we also hold a map of email addresses
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// map, and if
|
|
65
|
-
// email.
|
|
61
|
+
// address. For full email addresses, we also hold a map of email addresses with
|
|
62
|
+
// the domain portion of the email lowercased, since it is case insensitive. When
|
|
63
|
+
// looking up an email address in the constraint set, we first check the full
|
|
64
|
+
// email address map, and if we don't find anything, we check the domain portion
|
|
65
|
+
// of the email address against the dnsConstraints.
|
|
66
66
|
|
|
67
67
|
type nameConstraintsSet[T *net.IPNet | string, V net.IP | string] struct {
|
|
68
68
|
set []T
|
|
@@ -351,6 +351,7 @@ func newDNSConstraints(l []string, permitted bool) interface{ query(string) (str
|
|
|
351
351
|
if !permitted {
|
|
352
352
|
parentConstraints := map[string]string{}
|
|
353
353
|
for _, name := range nc.constraints.set {
|
|
354
|
+
name = strings.ToLower(name)
|
|
354
355
|
trimmedName := trimFirstLabel(name)
|
|
355
356
|
if trimmedName == "" {
|
|
356
357
|
continue
|
|
@@ -375,7 +376,8 @@ func (dnc *dnsConstraints) query(s string) (string, bool) {
|
|
|
375
376
|
return constraint, true
|
|
376
377
|
}
|
|
377
378
|
|
|
378
|
-
if !dnc.permitted && s[0] == '*' {
|
|
379
|
+
if !dnc.permitted && len(s) > 0 && s[0] == '*' {
|
|
380
|
+
s = strings.ToLower(s)
|
|
379
381
|
trimmed := trimFirstLabel(s)
|
|
380
382
|
if constraint, found := dnc.parentConstraints[trimmed]; found {
|
|
381
383
|
return constraint, true
|
|
@@ -387,16 +389,22 @@ func (dnc *dnsConstraints) query(s string) (string, bool) {
|
|
|
387
389
|
type emailConstraints struct {
|
|
388
390
|
dnsConstraints interface{ query(string) (string, bool) }
|
|
389
391
|
|
|
390
|
-
fullEmails map
|
|
392
|
+
// fullEmails is map of rfc2821Mailboxs that are fully specified in the
|
|
393
|
+
// constraints, which we need to check for separately since they don't
|
|
394
|
+
// follow the same matching rules as the domain-based constraints. The
|
|
395
|
+
// domain portion of the rfc2821Mailbox has been lowercased, since the
|
|
396
|
+
// domain portion is case insensitive. When checking the map for an email,
|
|
397
|
+
// the domain portion of the query should also be lowercased.
|
|
398
|
+
fullEmails map[rfc2821Mailbox]struct{}
|
|
391
399
|
}
|
|
392
400
|
|
|
393
401
|
func newEmailConstraints(l []string, permitted bool) interface {
|
|
394
|
-
query(
|
|
402
|
+
query(rfc2821Mailbox) (string, bool)
|
|
395
403
|
} {
|
|
396
404
|
if len(l) == 0 {
|
|
397
405
|
return nil
|
|
398
406
|
}
|
|
399
|
-
exactMap := map[
|
|
407
|
+
exactMap := map[rfc2821Mailbox]struct{}{}
|
|
400
408
|
var domains []string
|
|
401
409
|
for _, c := range l {
|
|
402
410
|
if !strings.ContainsRune(c, '@') {
|
|
@@ -411,7 +419,8 @@ func newEmailConstraints(l []string, permitted bool) interface {
|
|
|
411
419
|
// certificate since parsing.
|
|
412
420
|
continue
|
|
413
421
|
}
|
|
414
|
-
|
|
422
|
+
parsed.domain = strings.ToLower(parsed.domain)
|
|
423
|
+
exactMap[parsed] = struct{}{}
|
|
415
424
|
}
|
|
416
425
|
ec := &emailConstraints{
|
|
417
426
|
fullEmails: exactMap,
|
|
@@ -422,16 +431,16 @@ func newEmailConstraints(l []string, permitted bool) interface {
|
|
|
422
431
|
return ec
|
|
423
432
|
}
|
|
424
433
|
|
|
425
|
-
func (ec *emailConstraints) query(s
|
|
426
|
-
if len(ec.fullEmails) > 0
|
|
427
|
-
if
|
|
428
|
-
return
|
|
434
|
+
func (ec *emailConstraints) query(s rfc2821Mailbox) (string, bool) {
|
|
435
|
+
if len(ec.fullEmails) > 0 {
|
|
436
|
+
if _, ok := ec.fullEmails[s]; ok {
|
|
437
|
+
return fmt.Sprintf("%s@%s", s.local, s.domain), true
|
|
429
438
|
}
|
|
430
439
|
}
|
|
431
440
|
if ec.dnsConstraints == nil {
|
|
432
441
|
return "", false
|
|
433
442
|
}
|
|
434
|
-
constraint, found := ec.dnsConstraints.query(s.
|
|
443
|
+
constraint, found := ec.dnsConstraints.query(s.domain)
|
|
435
444
|
return constraint, found
|
|
436
445
|
}
|
|
437
446
|
|
|
@@ -441,7 +450,7 @@ type constraints[T any, V any] struct {
|
|
|
441
450
|
excluded interface{ query(V) (T, bool) }
|
|
442
451
|
}
|
|
443
452
|
|
|
444
|
-
func checkConstraints[T string | *net.IPNet, V any, P string | net.IP | parsedURI |
|
|
453
|
+
func checkConstraints[T string | *net.IPNet, V any, P string | net.IP | parsedURI | rfc2821Mailbox](c constraints[T, V], s V, p P) error {
|
|
445
454
|
if c.permitted != nil {
|
|
446
455
|
if _, found := c.permitted.query(s); !found {
|
|
447
456
|
return fmt.Errorf("%s %q is not permitted by any constraint", c.constraintType, p)
|
|
@@ -459,13 +468,13 @@ type chainConstraints struct {
|
|
|
459
468
|
ip constraints[*net.IPNet, net.IP]
|
|
460
469
|
dns constraints[string, string]
|
|
461
470
|
uri constraints[string, string]
|
|
462
|
-
email constraints[string,
|
|
471
|
+
email constraints[string, rfc2821Mailbox]
|
|
463
472
|
|
|
464
473
|
index int
|
|
465
474
|
next *chainConstraints
|
|
466
475
|
}
|
|
467
476
|
|
|
468
|
-
func (cc *chainConstraints) check(dns []string, uris []parsedURI, emails []
|
|
477
|
+
func (cc *chainConstraints) check(dns []string, uris []parsedURI, emails []rfc2821Mailbox, ips []net.IP) error {
|
|
469
478
|
for _, ip := range ips {
|
|
470
479
|
if err := checkConstraints(cc.ip, ip, ip); err != nil {
|
|
471
480
|
return err
|
|
@@ -488,8 +497,8 @@ func (cc *chainConstraints) check(dns []string, uris []parsedURI, emails []parse
|
|
|
488
497
|
}
|
|
489
498
|
}
|
|
490
499
|
for _, e := range emails {
|
|
491
|
-
if !domainNameValid(e.
|
|
492
|
-
return fmt.Errorf("x509: cannot parse rfc822Name %q", e
|
|
500
|
+
if !domainNameValid(e.domain, false) {
|
|
501
|
+
return fmt.Errorf("x509: cannot parse rfc822Name %q", e)
|
|
493
502
|
}
|
|
494
503
|
if err := checkConstraints(cc.email, e, e); err != nil {
|
|
495
504
|
return err
|
|
@@ -509,7 +518,7 @@ func checkChainConstraints(chain []*Certificate) error {
|
|
|
509
518
|
ip: constraints[*net.IPNet, net.IP]{"IP address", newIPNetConstraints(c.PermittedIPRanges), newIPNetConstraints(c.ExcludedIPRanges)},
|
|
510
519
|
dns: constraints[string, string]{"DNS name", newDNSConstraints(c.PermittedDNSDomains, true), newDNSConstraints(c.ExcludedDNSDomains, false)},
|
|
511
520
|
uri: constraints[string, string]{"URI", newDNSConstraints(c.PermittedURIDomains, true), newDNSConstraints(c.ExcludedURIDomains, false)},
|
|
512
|
-
email: constraints[string,
|
|
521
|
+
email: constraints[string, rfc2821Mailbox]{"email address", newEmailConstraints(c.PermittedEmailAddresses, true), newEmailConstraints(c.ExcludedEmailAddresses, false)},
|
|
513
522
|
index: i,
|
|
514
523
|
}
|
|
515
524
|
if currentConstraints == nil {
|
|
@@ -592,24 +601,15 @@ func parseURIs(uris []*url.URL) ([]parsedURI, error) {
|
|
|
592
601
|
return parsed, nil
|
|
593
602
|
}
|
|
594
603
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
mailbox *rfc2821Mailbox
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
func (e parsedEmail) String() string {
|
|
601
|
-
return e.mailbox.local + "@" + e.mailbox.domain
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
func parseMailboxes(emails []string) ([]parsedEmail, error) {
|
|
605
|
-
parsed := make([]parsedEmail, 0, len(emails))
|
|
604
|
+
func parseMailboxes(emails []string) ([]rfc2821Mailbox, error) {
|
|
605
|
+
parsed := make([]rfc2821Mailbox, 0, len(emails))
|
|
606
606
|
for _, email := range emails {
|
|
607
607
|
mailbox, ok := parseRFC2821Mailbox(email)
|
|
608
608
|
if !ok {
|
|
609
609
|
return nil, fmt.Errorf("cannot parse rfc822Name %q", email)
|
|
610
610
|
}
|
|
611
611
|
mailbox.domain = strings.ToLower(mailbox.domain)
|
|
612
|
-
parsed = append(parsed,
|
|
612
|
+
parsed = append(parsed, mailbox)
|
|
613
613
|
}
|
|
614
614
|
return parsed, nil
|
|
615
615
|
}
|