mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: I61d6a6d4959fdea8339b9d666385bf6b4ed49d03
This commit is contained in:
commit
d85ef2b979
20 changed files with 155 additions and 52 deletions
1
AUTHORS
1
AUTHORS
|
|
@ -563,6 +563,7 @@ Hitoshi Mitake <mitake.hitoshi@gmail.com>
|
||||||
Holden Huang <ttyh061@gmail.com>
|
Holden Huang <ttyh061@gmail.com>
|
||||||
Hong Ruiqi <hongruiqi@gmail.com>
|
Hong Ruiqi <hongruiqi@gmail.com>
|
||||||
Hongfei Tan <feilengcui008@gmail.com>
|
Hongfei Tan <feilengcui008@gmail.com>
|
||||||
|
Hootsuite Inc.
|
||||||
Hsin-Ho Yeh <yhh92u@gmail.com>
|
Hsin-Ho Yeh <yhh92u@gmail.com>
|
||||||
Hu Keping <hukeping@huawei.com>
|
Hu Keping <hukeping@huawei.com>
|
||||||
Hugues Bruant <hugues.bruant@gmail.com>
|
Hugues Bruant <hugues.bruant@gmail.com>
|
||||||
|
|
|
||||||
|
|
@ -1303,6 +1303,7 @@ Kshitij Saraogi <kshitijsaraogi@gmail.com>
|
||||||
Kun Li <likunarmstrong@gmail.com>
|
Kun Li <likunarmstrong@gmail.com>
|
||||||
Kunpei Sakai <namusyaka@gmail.com>
|
Kunpei Sakai <namusyaka@gmail.com>
|
||||||
Kuntal Majumder <hellozee@disroot.org>
|
Kuntal Majumder <hellozee@disroot.org>
|
||||||
|
Kush Patel <kush.patel@hootsuite.com>
|
||||||
Kyle Consalus <consalus@gmail.com>
|
Kyle Consalus <consalus@gmail.com>
|
||||||
Kyle Isom <kyle@gokyle.net>
|
Kyle Isom <kyle@gokyle.net>
|
||||||
Kyle Jones <kyle@kyledj.com>
|
Kyle Jones <kyle@kyledj.com>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ editing, navigation, testing, and debugging experience.
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://github.com/fatih/vim-go">vim</a>: vim-go plugin provides Go programming language support</li>
|
<li><a href="https://github.com/fatih/vim-go">vim</a>: vim-go plugin provides Go programming language support</li>
|
||||||
<li><a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go">Visual Studio Code</a>:
|
<li><a href="https://marketplace.visualstudio.com/items?itemName=golang.go">Visual Studio Code</a>:
|
||||||
Go extension provides support for the Go programming language</li>
|
Go extension provides support for the Go programming language</li>
|
||||||
<li><a href="https://www.jetbrains.com/go">GoLand</a>: GoLand is distributed either as a standalone IDE
|
<li><a href="https://www.jetbrains.com/go">GoLand</a>: GoLand is distributed either as a standalone IDE
|
||||||
or as a plugin for IntelliJ IDEA Ultimate</li>
|
or as a plugin for IntelliJ IDEA Ultimate</li>
|
||||||
|
|
|
||||||
|
|
@ -553,11 +553,11 @@ Do not send CLs removing the interior tags from such phrases.
|
||||||
|
|
||||||
<dl id="crypto/x509/pkix"><dt><a href="/pkg/crypto/x509/pkix/">crypto/x509/pkix</a></dt>
|
<dl id="crypto/x509/pkix"><dt><a href="/pkg/crypto/x509/pkix/">crypto/x509/pkix</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><!-- CL 229864 -->
|
<p><!-- CL 229864, CL 240543 -->
|
||||||
<a href="/pkg/crypto/x509/pkix/#Name.String"><code>Name.String</code></a>
|
<a href="/pkg/crypto/x509/pkix/#Name.String"><code>Name.String</code></a>
|
||||||
now prints non-standard attributes from
|
now prints non-standard attributes from
|
||||||
<a href="/pkg/crypto/x509/pkix/#Name.Names"><code>Names</code></a> if
|
<a href="/pkg/crypto/x509/pkix/#Name.Names"><code>Names</code></a> if
|
||||||
<a href="/pkg/crypto/x509/pkix/#Name.ExtraNames"><code>ExtraNames</code></a> is empty.
|
<a href="/pkg/crypto/x509/pkix/#Name.ExtraNames"><code>ExtraNames</code></a> is nil.
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl><!-- crypto/x509/pkix -->
|
</dl><!-- crypto/x509/pkix -->
|
||||||
|
|
@ -666,6 +666,17 @@ Do not send CLs removing the interior tags from such phrases.
|
||||||
</dd>
|
</dd>
|
||||||
</dl><!-- go/printer -->
|
</dl><!-- go/printer -->
|
||||||
|
|
||||||
|
<dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
|
||||||
|
<dd>
|
||||||
|
<p><!-- CL 226097 -->
|
||||||
|
The package now uses Unicode escapes (<code>\uNNNN</code>) in all
|
||||||
|
JavaScript and JSON contexts. This fixes escaping errors in
|
||||||
|
<code>application/ld+json</code> and <code>application/json</code>
|
||||||
|
contexts.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl><!-- html/template -->
|
||||||
|
|
||||||
<dl id="io/ioutil"><dt><a href="/pkg/io/ioutil/">io/ioutil</a></dt>
|
<dl id="io/ioutil"><dt><a href="/pkg/io/ioutil/">io/ioutil</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><!-- CL 212597 -->
|
<p><!-- CL 212597 -->
|
||||||
|
|
@ -950,6 +961,16 @@ Do not send CLs removing the interior tags from such phrases.
|
||||||
</dd>
|
</dd>
|
||||||
</dl><!-- testing -->
|
</dl><!-- testing -->
|
||||||
|
|
||||||
|
<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
|
||||||
|
<dd>
|
||||||
|
<p><!-- CL 226097 -->
|
||||||
|
<a href="/pkg/text/template/#JSEscape"><code>JSEscape</code></a> now
|
||||||
|
consistently uses Unicode escapes (<code>\u00XX</code>), which are
|
||||||
|
compatible with JSON.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl><!-- text/template -->
|
||||||
|
|
||||||
<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
|
<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><!-- CL 220424, CL 217362, golang.org/issue/33184 -->
|
<p><!-- CL 220424, CL 217362, golang.org/issue/33184 -->
|
||||||
|
|
|
||||||
|
|
@ -600,12 +600,12 @@ type Config struct {
|
||||||
// by the policy in ClientAuth.
|
// by the policy in ClientAuth.
|
||||||
ClientCAs *x509.CertPool
|
ClientCAs *x509.CertPool
|
||||||
|
|
||||||
// InsecureSkipVerify controls whether a client verifies the
|
// InsecureSkipVerify controls whether a client verifies the server's
|
||||||
// server's certificate chain and host name.
|
// certificate chain and host name. If InsecureSkipVerify is true, crypto/tls
|
||||||
// If InsecureSkipVerify is true, TLS accepts any certificate
|
// accepts any certificate presented by the server and any host name in that
|
||||||
// presented by the server and any host name in that certificate.
|
// certificate. In this mode, TLS is susceptible to machine-in-the-middle
|
||||||
// In this mode, TLS is susceptible to machine-in-the-middle attacks.
|
// attacks unless custom verification is used. This should be used only for
|
||||||
// This should be used only for testing.
|
// testing or in combination with VerifyConnection or VerifyPeerCertificate.
|
||||||
InsecureSkipVerify bool
|
InsecureSkipVerify bool
|
||||||
|
|
||||||
// CipherSuites is a list of supported cipher suites for TLS versions up to
|
// CipherSuites is a list of supported cipher suites for TLS versions up to
|
||||||
|
|
|
||||||
|
|
@ -247,20 +247,26 @@ func (n Name) ToRDNSequence() (ret RDNSequence) {
|
||||||
// String returns the string form of n, roughly following
|
// String returns the string form of n, roughly following
|
||||||
// the RFC 2253 Distinguished Names syntax.
|
// the RFC 2253 Distinguished Names syntax.
|
||||||
func (n Name) String() string {
|
func (n Name) String() string {
|
||||||
if len(n.ExtraNames) == 0 {
|
var rdns RDNSequence
|
||||||
|
// If there are no ExtraNames, surface the parsed value (all entries in
|
||||||
|
// Names) instead.
|
||||||
|
if n.ExtraNames == nil {
|
||||||
for _, atv := range n.Names {
|
for _, atv := range n.Names {
|
||||||
t := atv.Type
|
t := atv.Type
|
||||||
if len(t) == 4 && t[0] == 2 && t[1] == 5 && t[2] == 4 {
|
if len(t) == 4 && t[0] == 2 && t[1] == 5 && t[2] == 4 {
|
||||||
switch t[3] {
|
switch t[3] {
|
||||||
case 3, 5, 6, 7, 8, 9, 10, 11, 17:
|
case 3, 5, 6, 7, 8, 9, 10, 11, 17:
|
||||||
// These attributes are already parsed into named fields.
|
// These attributes were already parsed into named fields.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n.ExtraNames = append(n.ExtraNames, atv)
|
// Place non-standard parsed values at the beginning of the sequence
|
||||||
|
// so they will be at the end of the string. See Issue 39924.
|
||||||
|
rdns = append(rdns, []AttributeTypeAndValue{atv})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n.ToRDNSequence().String()
|
rdns = append(rdns, n.ToRDNSequence()...)
|
||||||
|
return rdns.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// oidInAttributeTypeAndValue reports whether a type with the given OID exists
|
// oidInAttributeTypeAndValue reports whether a type with the given OID exists
|
||||||
|
|
|
||||||
|
|
@ -2076,10 +2076,31 @@ func TestPKIXNameString(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that parsed non-standard attributes are printed.
|
||||||
|
rdns := pkix.Name{
|
||||||
|
Locality: []string{"Gophertown"},
|
||||||
|
ExtraNames: []pkix.AttributeTypeAndValue{
|
||||||
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "golang.org"}},
|
||||||
|
}.ToRDNSequence()
|
||||||
|
nn := pkix.Name{}
|
||||||
|
nn.FillFromRDNSequence(&rdns)
|
||||||
|
|
||||||
|
// Check that zero-length non-nil ExtraNames hide Names.
|
||||||
|
extra := []pkix.AttributeTypeAndValue{
|
||||||
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "backing array"}}
|
||||||
|
extraNotNil := pkix.Name{
|
||||||
|
Locality: []string{"Gophertown"},
|
||||||
|
ExtraNames: extra[:0],
|
||||||
|
Names: []pkix.AttributeTypeAndValue{
|
||||||
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "golang.org"}},
|
||||||
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
dn pkix.Name
|
dn pkix.Name
|
||||||
want string
|
want string
|
||||||
}{
|
}{
|
||||||
|
{nn, "L=Gophertown,1.2.3.4.5=#130a676f6c616e672e6f7267"},
|
||||||
|
{extraNotNil, "L=Gophertown"},
|
||||||
{pkix.Name{
|
{pkix.Name{
|
||||||
CommonName: "Steve Kille",
|
CommonName: "Steve Kille",
|
||||||
Organization: []string{"Isode Limited"},
|
Organization: []string{"Isode Limited"},
|
||||||
|
|
@ -2108,6 +2129,20 @@ func TestPKIXNameString(t *testing.T) {
|
||||||
ExtraNames: []pkix.AttributeTypeAndValue{
|
ExtraNames: []pkix.AttributeTypeAndValue{
|
||||||
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "golang.org"}},
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "golang.org"}},
|
||||||
}, "1.2.3.4.5=#130a676f6c616e672e6f7267,L=Gophertown"},
|
}, "1.2.3.4.5=#130a676f6c616e672e6f7267,L=Gophertown"},
|
||||||
|
// If there are no ExtraNames, the Names are printed instead.
|
||||||
|
{pkix.Name{
|
||||||
|
Locality: []string{"Gophertown"},
|
||||||
|
Names: []pkix.AttributeTypeAndValue{
|
||||||
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "golang.org"}},
|
||||||
|
}, "L=Gophertown,1.2.3.4.5=#130a676f6c616e672e6f7267"},
|
||||||
|
// If there are both, print only the ExtraNames.
|
||||||
|
{pkix.Name{
|
||||||
|
Locality: []string{"Gophertown"},
|
||||||
|
ExtraNames: []pkix.AttributeTypeAndValue{
|
||||||
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 5}), Value: "golang.org"}},
|
||||||
|
Names: []pkix.AttributeTypeAndValue{
|
||||||
|
{Type: asn1.ObjectIdentifier([]int{1, 2, 3, 4, 6}), Value: "example.com"}},
|
||||||
|
}, "1.2.3.4.5=#130a676f6c616e672e6f7267,L=Gophertown"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
|
@ -2115,6 +2150,10 @@ func TestPKIXNameString(t *testing.T) {
|
||||||
t.Errorf("#%d: String() = \n%s\n, want \n%s", i, got, test.want)
|
t.Errorf("#%d: String() = \n%s\n, want \n%s", i, got, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if extra[0].Value != "backing array" {
|
||||||
|
t.Errorf("the backing array of an empty ExtraNames got modified by String")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRDNSequenceString(t *testing.T) {
|
func TestRDNSequenceString(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func parsePlan9Addr(s string) (ip IP, iport int, err error) {
|
||||||
return addr, p, nil
|
return addr, p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readPlan9Addr(proto, filename string) (addr Addr, err error) {
|
func readPlan9Addr(net, filename string) (addr Addr, err error) {
|
||||||
var buf [128]byte
|
var buf [128]byte
|
||||||
|
|
||||||
f, err := os.Open(filename)
|
f, err := os.Open(filename)
|
||||||
|
|
@ -83,13 +83,19 @@ func readPlan9Addr(proto, filename string) (addr Addr, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch proto {
|
switch net {
|
||||||
case "tcp":
|
case "tcp4", "udp4":
|
||||||
|
if ip.Equal(IPv6zero) {
|
||||||
|
ip = ip[:IPv4len]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch net {
|
||||||
|
case "tcp", "tcp4", "tcp6":
|
||||||
addr = &TCPAddr{IP: ip, Port: port}
|
addr = &TCPAddr{IP: ip, Port: port}
|
||||||
case "udp":
|
case "udp", "udp4", "udp6":
|
||||||
addr = &UDPAddr{IP: ip, Port: port}
|
addr = &UDPAddr{IP: ip, Port: port}
|
||||||
default:
|
default:
|
||||||
return nil, UnknownNetworkError(proto)
|
return nil, UnknownNetworkError(net)
|
||||||
}
|
}
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +219,7 @@ func dialPlan9Blocking(ctx context.Context, net string, laddr, raddr Addr) (fd *
|
||||||
f.Close()
|
f.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
laddr, err = readPlan9Addr(proto, netdir+"/"+proto+"/"+name+"/local")
|
laddr, err = readPlan9Addr(net, netdir+"/"+proto+"/"+name+"/local")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
data.Close()
|
data.Close()
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
@ -233,7 +239,7 @@ func listenPlan9(ctx context.Context, net string, laddr Addr) (fd *netFD, err er
|
||||||
f.Close()
|
f.Close()
|
||||||
return nil, &OpError{Op: "announce", Net: net, Source: laddr, Addr: nil, Err: err}
|
return nil, &OpError{Op: "announce", Net: net, Source: laddr, Addr: nil, Err: err}
|
||||||
}
|
}
|
||||||
laddr, err = readPlan9Addr(proto, netdir+"/"+proto+"/"+name+"/local")
|
laddr, err = readPlan9Addr(net, netdir+"/"+proto+"/"+name+"/local")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.Close()
|
f.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
29
src/net/ipsock_plan9_test.go
Normal file
29
src/net/ipsock_plan9_test.go
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2020 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestTCP4ListenZero(t *testing.T) {
|
||||||
|
l, err := Listen("tcp4", "0.0.0.0:0")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer l.Close()
|
||||||
|
if a := l.Addr(); isNotIPv4(a) {
|
||||||
|
t.Errorf("address does not contain IPv4: %v", a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUDP4ListenZero(t *testing.T) {
|
||||||
|
c, err := ListenPacket("udp4", "0.0.0.0:0")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer c.Close()
|
||||||
|
if a := c.LocalAddr(); isNotIPv4(a) {
|
||||||
|
t.Errorf("address does not contain IPv4: %v", a)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue