Skip to content

Commit 40517c7

Browse files
committed
ssh: add (*Client).DialContext method
This change adds DialContext to ssh.Client, which opens a TCP-IP connection tunneled over the SSH connection. This is useful for proxying network connections, e.g. setting (net/http.Transport).DialContext. Fixes golang/go#20288. Change-Id: I110494c00962424ea803065535ebe2209364ac27 GitHub-Last-Rev: 3176984 GitHub-Pull-Request: golang#260 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/504735 Run-TryBot: Nicola Murino <[email protected]> Run-TryBot: Han-Wen Nienhuys <[email protected]> Auto-Submit: Nicola Murino <[email protected]> Reviewed-by: Han-Wen Nienhuys <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Nicola Murino <[email protected]> Commit-Queue: Nicola Murino <[email protected]>
2 parents 127a3e6 + 152cdb1 commit 40517c7

36 files changed

+947
-179
lines changed

argon2/blamka_amd64.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ TEXT ·mixBlocksSSE2(SB), 4, $0-32
199199
MOVQ out+0(FP), DX
200200
MOVQ a+8(FP), AX
201201
MOVQ b+16(FP), BX
202-
MOVQ a+24(FP), CX
203-
MOVQ $128, BP
202+
MOVQ c+24(FP), CX
203+
MOVQ $128, DI
204204

205205
loop:
206206
MOVOU 0(AX), X0
@@ -213,7 +213,7 @@ loop:
213213
ADDQ $16, BX
214214
ADDQ $16, CX
215215
ADDQ $16, DX
216-
SUBQ $2, BP
216+
SUBQ $2, DI
217217
JA loop
218218
RET
219219

@@ -222,8 +222,8 @@ TEXT ·xorBlocksSSE2(SB), 4, $0-32
222222
MOVQ out+0(FP), DX
223223
MOVQ a+8(FP), AX
224224
MOVQ b+16(FP), BX
225-
MOVQ a+24(FP), CX
226-
MOVQ $128, BP
225+
MOVQ c+24(FP), CX
226+
MOVQ $128, DI
227227

228228
loop:
229229
MOVOU 0(AX), X0
@@ -238,6 +238,6 @@ loop:
238238
ADDQ $16, BX
239239
ADDQ $16, CX
240240
ADDQ $16, DX
241-
SUBQ $2, BP
241+
SUBQ $2, DI
242242
JA loop
243243
RET

blake2b/blake2bAVX2_amd64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build go1.7 && amd64 && gc && !purego
5+
//go:build amd64 && gc && !purego
66

77
package blake2b
88

blake2b/blake2bAVX2_amd64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build go1.7 && amd64 && gc && !purego
5+
//go:build amd64 && gc && !purego
66

77
#include "textflag.h"
88

blake2b/blake2b_amd64.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

blake2b/register.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build go1.9
6-
75
package blake2b
86

97
import (

chacha20poly1305/chacha20poly1305_amd64.s

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,31 @@ GLOBL ·andMask<>(SB), (NOPTR+RODATA), $240
183183
#define shiftD1Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xd2; BYTE $0x04 // PALIGNR $4, X10, X10
184184
#define shiftD2Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xdb; BYTE $0x04 // PALIGNR $4, X11, X11
185185
#define shiftD3Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xff; BYTE $0x04 // PALIGNR $4, X15, X15
186+
186187
// Some macros
188+
189+
// ROL rotates the uint32s in register R left by N bits, using temporary T.
190+
#define ROL(N, R, T) \
191+
MOVO R, T; PSLLL $(N), T; PSRLL $(32-(N)), R; PXOR T, R
192+
193+
// ROL16 rotates the uint32s in register R left by 16, using temporary T if needed.
194+
#ifdef GOAMD64_v2
195+
#define ROL16(R, T) PSHUFB ·rol16<>(SB), R
196+
#else
197+
#define ROL16(R, T) ROL(16, R, T)
198+
#endif
199+
200+
// ROL8 rotates the uint32s in register R left by 8, using temporary T if needed.
201+
#ifdef GOAMD64_v2
202+
#define ROL8(R, T) PSHUFB ·rol8<>(SB), R
203+
#else
204+
#define ROL8(R, T) ROL(8, R, T)
205+
#endif
206+
187207
#define chachaQR(A, B, C, D, T) \
188-
PADDD B, A; PXOR A, D; PSHUFB ·rol16<>(SB), D \
208+
PADDD B, A; PXOR A, D; ROL16(D, T) \
189209
PADDD D, C; PXOR C, B; MOVO B, T; PSLLL $12, T; PSRLL $20, B; PXOR T, B \
190-
PADDD B, A; PXOR A, D; PSHUFB ·rol8<>(SB), D \
210+
PADDD B, A; PXOR A, D; ROL8(D, T) \
191211
PADDD D, C; PXOR C, B; MOVO B, T; PSLLL $7, T; PSRLL $25, B; PXOR T, B
192212

193213
#define chachaQR_AVX2(A, B, C, D, T) \

cryptobyte/asn1.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,14 @@ func (s *String) ReadOptionalASN1OctetString(out *[]byte, outPresent *bool, tag
733733
return true
734734
}
735735

736-
// ReadOptionalASN1Boolean sets *out to the value of the next ASN.1 BOOLEAN or,
737-
// if the next bytes are not an ASN.1 BOOLEAN, to the value of defaultValue.
738-
// It reports whether the operation was successful.
739-
func (s *String) ReadOptionalASN1Boolean(out *bool, defaultValue bool) bool {
736+
// ReadOptionalASN1Boolean attempts to read an optional ASN.1 BOOLEAN
737+
// explicitly tagged with tag into out and advances. If no element with a
738+
// matching tag is present, it sets "out" to defaultValue instead. It reports
739+
// whether the read was successful.
740+
func (s *String) ReadOptionalASN1Boolean(out *bool, tag asn1.Tag, defaultValue bool) bool {
740741
var present bool
741742
var child String
742-
if !s.ReadOptionalASN1(&child, &present, asn1.BOOLEAN) {
743+
if !s.ReadOptionalASN1(&child, &present, tag) {
743744
return false
744745
}
745746

@@ -748,7 +749,7 @@ func (s *String) ReadOptionalASN1Boolean(out *bool, defaultValue bool) bool {
748749
return true
749750
}
750751

751-
return s.ReadASN1Boolean(out)
752+
return child.ReadASN1Boolean(out)
752753
}
753754

754755
func (s *String) readASN1(out *String, outTag *asn1.Tag, skipHeader bool) bool {

cryptobyte/asn1_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ func TestReadASN1OptionalInteger(t *testing.T) {
115115
}
116116
}
117117

118+
const defaultBool = false
119+
120+
var optionalBoolTestData = []readASN1Test{
121+
{"empty", []byte{}, 0xa0, true, false},
122+
{"invalid", []byte{0xa1, 0x3, 0x1, 0x2, 0x7f}, 0xa1, false, defaultBool},
123+
{"missing", []byte{0xa1, 0x3, 0x1, 0x1, 0x7f}, 0xa0, true, defaultBool},
124+
{"present", []byte{0xa1, 0x3, 0x1, 0x1, 0xff}, 0xa1, true, true},
125+
}
126+
127+
func TestReadASN1OptionalBoolean(t *testing.T) {
128+
for _, test := range optionalBoolTestData {
129+
t.Run(test.name, func(t *testing.T) {
130+
in := String(test.in)
131+
var out bool
132+
ok := in.ReadOptionalASN1Boolean(&out, test.tag, defaultBool)
133+
if ok != test.ok || ok && out != test.out.(bool) {
134+
t.Errorf("in.ReadOptionalASN1Boolean() = %v, want %v; out = %v, want %v", ok, test.ok, out, test.out)
135+
}
136+
})
137+
}
138+
}
139+
118140
func TestReadASN1IntegerSigned(t *testing.T) {
119141
testData64 := []struct {
120142
in []byte

curve25519/internal/field/_asm/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99

1010
require (
1111
golang.org/x/mod v0.8.0 // indirect
12-
golang.org/x/sys v0.13.0 // indirect
12+
golang.org/x/sys v0.14.0 // indirect
1313
golang.org/x/tools v0.6.0 // indirect
1414
)
1515

curve25519/internal/field/_asm/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
2626
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2727
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2828
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
30-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29+
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
30+
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3131
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
3232
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
3333
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
3434
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
3535
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
36-
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
36+
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
3737
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
3838
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
3939
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
4040
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
4141
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
4242
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
43-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
43+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
4444
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
4545
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
4646
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

0 commit comments

Comments
 (0)