summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-06-16 23:33:25 +0200
committerGitHub <noreply@github.com>2019-06-16 23:33:25 +0200
commitcb712ff37d3c20a21695e00c52fff213a6fd40b4 (patch)
tree0ba0ee4f55bf6ace2656562465cc82d807e741b9 /vendor/golang.org/x/crypto
parentf4ae61044888f591830e6c1be9a2bdb14f88943e (diff)
downloadmatterbridge-msglm-cb712ff37d3c20a21695e00c52fff213a6fd40b4.tar.gz
matterbridge-msglm-cb712ff37d3c20a21695e00c52fff213a6fd40b4.tar.bz2
matterbridge-msglm-cb712ff37d3c20a21695e00c52fff213a6fd40b4.zip
Update vendor (#852)
Diffstat (limited to 'vendor/golang.org/x/crypto')
-rw-r--r--vendor/golang.org/x/crypto/acme/autocert/autocert.go21
-rw-r--r--vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s90
-rw-r--r--vendor/golang.org/x/crypto/curve25519/mul_amd64.s10
-rw-r--r--vendor/golang.org/x/crypto/curve25519/square_amd64.s10
-rw-r--r--vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s668
-rw-r--r--vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go2
-rw-r--r--vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go51
-rw-r--r--vendor/golang.org/x/crypto/poly1305/mac_noasm.go2
-rw-r--r--vendor/golang.org/x/crypto/poly1305/sum_noasm.go2
-rw-r--r--vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go68
-rw-r--r--vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s247
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go3
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.s (renamed from vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s)8
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.go14
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go9
-rw-r--r--vendor/golang.org/x/crypto/ssh/cipher.go24
-rw-r--r--vendor/golang.org/x/crypto/ssh/client_auth.go114
-rw-r--r--vendor/golang.org/x/crypto/ssh/common.go20
-rw-r--r--vendor/golang.org/x/crypto/ssh/handshake.go5
-rw-r--r--vendor/golang.org/x/crypto/ssh/messages.go70
-rw-r--r--vendor/golang.org/x/crypto/ssh/server.go118
-rw-r--r--vendor/golang.org/x/crypto/ssh/ssh_gss.go139
-rw-r--r--vendor/golang.org/x/crypto/ssh/terminal/terminal.go67
-rw-r--r--vendor/golang.org/x/crypto/ssh/transport.go12
24 files changed, 1643 insertions, 131 deletions
diff --git a/vendor/golang.org/x/crypto/acme/autocert/autocert.go b/vendor/golang.org/x/crypto/acme/autocert/autocert.go
index a50d9bfc..e562609c 100644
--- a/vendor/golang.org/x/crypto/acme/autocert/autocert.go
+++ b/vendor/golang.org/x/crypto/acme/autocert/autocert.go
@@ -32,6 +32,7 @@ import (
"time"
"golang.org/x/crypto/acme"
+ "golang.org/x/net/idna"
)
// createCertRetryAfter is how much time to wait before removing a failed state
@@ -62,10 +63,16 @@ type HostPolicy func(ctx context.Context, host string) error
// HostWhitelist returns a policy where only the specified host names are allowed.
// Only exact matches are currently supported. Subdomains, regexp or wildcard
// will not match.
+//
+// Note that all hosts will be converted to Punycode via idna.Lookup.ToASCII so that
+// Manager.GetCertificate can handle the Unicode IDN and mixedcase hosts correctly.
+// Invalid hosts will be silently ignored.
func HostWhitelist(hosts ...string) HostPolicy {
whitelist := make(map[string]bool, len(hosts))
for _, h := range hosts {
- whitelist[h] = true
+ if h, err := idna.Lookup.ToASCII(h); err == nil {
+ whitelist[h] = true
+ }
}
return func(_ context.Context, host string) error {
if !whitelist[host] {
@@ -243,7 +250,17 @@ func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate,
if !strings.Contains(strings.Trim(name, "."), ".") {
return nil, errors.New("acme/autocert: server name component count invalid")
}
- if strings.ContainsAny(name, `+/\`) {
+
+ // Note that this conversion is necessary because some server names in the handshakes
+ // started by some clients (such as cURL) are not converted to Punycode, which will
+ // prevent us from obtaining certificates for them. In addition, we should also treat
+ // example.com and EXAMPLE.COM as equivalent and return the same certificate for them.
+ // Fortunately, this conversion also helped us deal with this kind of mixedcase problems.
+ //
+ // Due to the "σςΣ" problem (see https://unicode.org/faq/idn.html#22), we can't use
+ // idna.Punycode.ToASCII (or just idna.ToASCII) here.
+ name, err := idna.Lookup.ToASCII(name)
+ if err != nil {
return nil, errors.New("acme/autocert: server name contains invalid character")
}
diff --git a/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s b/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s
index 9e9040b2..e0ac30c7 100644
--- a/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s
+++ b/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s
@@ -121,18 +121,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -236,18 +236,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -441,18 +441,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -591,18 +591,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -731,18 +731,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -846,18 +846,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -996,18 +996,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -1146,18 +1146,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
@@ -1332,18 +1332,18 @@ TEXT ·ladderstep(SB),0,$296-8
ADDQ AX,R12
ADCQ DX,R13
MOVQ $REDMASK51,DX
- SHLQ $13,CX:SI
+ SHLQ $13,SI,CX
ANDQ DX,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ DX,R8
ADDQ CX,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ DX,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ DX,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ DX,R14
ADDQ R13,R14
IMUL3Q $19,R15,CX
diff --git a/vendor/golang.org/x/crypto/curve25519/mul_amd64.s b/vendor/golang.org/x/crypto/curve25519/mul_amd64.s
index 5ce80a2e..1f76d1a3 100644
--- a/vendor/golang.org/x/crypto/curve25519/mul_amd64.s
+++ b/vendor/golang.org/x/crypto/curve25519/mul_amd64.s
@@ -124,18 +124,18 @@ TEXT ·mul(SB),0,$16-24
ADDQ AX,R14
ADCQ DX,R15
MOVQ $REDMASK51,SI
- SHLQ $13,R9:R8
+ SHLQ $13,R8,R9
ANDQ SI,R8
- SHLQ $13,R11:R10
+ SHLQ $13,R10,R11
ANDQ SI,R10
ADDQ R9,R10
- SHLQ $13,R13:R12
+ SHLQ $13,R12,R13
ANDQ SI,R12
ADDQ R11,R12
- SHLQ $13,R15:R14
+ SHLQ $13,R14,R15
ANDQ SI,R14
ADDQ R13,R14
- SHLQ $13,BP:BX
+ SHLQ $13,BX,BP
ANDQ SI,BX
ADDQ R15,BX
IMUL3Q $19,BP,DX
diff --git a/vendor/golang.org/x/crypto/curve25519/square_amd64.s b/vendor/golang.org/x/crypto/curve25519/square_amd64.s
index 12f73734..07511a45 100644
--- a/vendor/golang.org/x/crypto/curve25519/square_amd64.s
+++ b/vendor/golang.org/x/crypto/curve25519/square_amd64.s
@@ -87,18 +87,18 @@ TEXT ·square(SB),7,$0-16
ADDQ AX,R13
ADCQ DX,R14
MOVQ $REDMASK51,SI
- SHLQ $13,R8:CX
+ SHLQ $13,CX,R8
ANDQ SI,CX
- SHLQ $13,R10:R9
+ SHLQ $13,R9,R10
ANDQ SI,R9
ADDQ R8,R9
- SHLQ $13,R12:R11
+ SHLQ $13,R11,R12
ANDQ SI,R11
ADDQ R10,R11
- SHLQ $13,R14:R13
+ SHLQ $13,R13,R14
ANDQ SI,R13
ADDQ R12,R13
- SHLQ $13,BX:R15
+ SHLQ $13,R15,BX
ANDQ SI,R15
ADDQ R14,R15
IMUL3Q $19,BX,DX
diff --git a/vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s b/vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s
new file mode 100644
index 00000000..8815cb00
--- /dev/null
+++ b/vendor/golang.org/x/crypto/internal/chacha20/asm_ppc64le.s
@@ -0,0 +1,668 @@
+// Copyright 2019 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.
+
+// Based on CRYPTOGAMS code with the following comment:
+// # ====================================================================
+// # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
+// # project. The module is, however, dual licensed under OpenSSL and
+// # CRYPTOGAMS licenses depending on where you obtain it. For further
+// # details see http://www.openssl.org/~appro/cryptogams/.
+// # ====================================================================
+
+// Original code can be found at the link below:
+// https://github.com/dot-asm/cryptogams/commit/a60f5b50ed908e91e5c39ca79126a4a876d5d8ff
+
+// There are some differences between CRYPTOGAMS code and this one. The round
+// loop for "_int" isn't the same as the original. Some adjustments were
+// necessary because there are less vector registers available. For example, some
+// X variables (r12, r13, r14, and r15) share the same register used by the
+// counter. The original code uses ctr to name the counter. Here we use CNT
+// because golang uses CTR as the counter register name.
+
+// +build ppc64le,!gccgo,!appengine
+
+#include "textflag.h"
+
+#define OUT R3
+#define INP R4
+#define LEN R5
+#define KEY R6
+#define CNT R7
+
+#define TEMP R8
+
+#define X0 R11
+#define X1 R12
+#define X2 R14
+#define X3 R15
+#define X4 R16
+#define X5 R17
+#define X6 R18
+#define X7 R19
+#define X8 R20
+#define X9 R21
+#define X10 R22
+#define X11 R23
+#define X12 R24
+#define X13 R25
+#define X14 R26
+#define X15 R27
+
+#define CON0 X0
+#define CON1 X1
+#define CON2 X2
+#define CON3 X3
+
+#define KEY0 X4
+#define KEY1 X5
+#define KEY2 X6
+#define KEY3 X7
+#define KEY4 X8
+#define KEY5 X9
+#define KEY6 X10
+#define KEY7 X11
+
+#define CNT0 X12
+#define CNT1 X13
+#define CNT2 X14
+#define CNT3 X15
+
+#define TMP0 R9
+#define TMP1 R10
+#define TMP2 R28
+#define TMP3 R29
+
+#define CONSTS R8
+
+#define A0 V0
+#define B0 V1
+#define C0 V2
+#define D0 V3
+#define A1 V4
+#define B1 V5
+#define C1 V6
+#define D1 V7
+#define A2 V8
+#define B2 V9
+#define C2 V10
+#define D2 V11
+#define T0 V12
+#define T1 V13
+#define T2 V14
+
+#define K0 V15
+#define K1 V16
+#define K2 V17
+#define K3 V18
+#define K4 V19
+#define K5 V20
+
+#define FOUR V21
+#define SIXTEEN V22
+#define TWENTY4 V23
+#define TWENTY V24
+#define TWELVE V25
+#define TWENTY5 V26
+#define SEVEN V27
+
+#define INPPERM V28
+#define OUTPERM V29
+#define OUTMASK V30
+
+#define DD0 V31
+#define DD1 SEVEN
+#define DD2 T0
+#define DD3 T1
+#define DD4 T2
+
+DATA ·consts+0x00(SB)/8, $0x3320646e61707865
+DATA ·consts+0x08(SB)/8, $0x6b20657479622d32
+DATA ·consts+0x10(SB)/8, $0x0000000000000001
+DATA ·consts+0x18(SB)/8, $0x0000000000000000
+DATA ·consts+0x20(SB)/8, $0x0000000000000004
+DATA ·consts+0x28(SB)/8, $0x0000000000000000
+DATA ·consts+0x30(SB)/8, $0x0a0b08090e0f0c0d
+DATA ·consts+0x38(SB)/8, $0x0203000106070405
+DATA ·consts+0x40(SB)/8, $0x090a0b080d0e0f0c
+DATA ·consts+0x48(SB)/8, $0x0102030005060704
+GLOBL ·consts(SB), RODATA, $80
+
+//func chaCha20_ctr32_vmx(out, inp *byte, len int, key *[32]byte, counter *[16]byte)
+TEXT ·chaCha20_ctr32_vmx(SB),NOSPLIT|NOFRAME,$0
+ // Load the arguments inside the registers
+ MOVD out+0(FP), OUT
+ MOVD inp+8(FP), INP
+ MOVD len+16(FP), LEN
+ MOVD key+24(FP), KEY
+ MOVD cnt+32(FP), CNT
+
+ MOVD $·consts(SB), CONSTS // point to consts addr
+
+ MOVD $16, X0
+ MOVD $32, X1
+ MOVD $48, X2
+ MOVD $64, X3
+ MOVD $31, X4
+ MOVD $15, X5
+
+ // Load key
+ LVX (KEY)(R0), K1
+ LVSR (KEY)(R0), T0
+ LVX (KEY)(X0), K2
+ LVX (KEY)(X4), DD0
+
+ // Load counter
+ LVX (CNT)(R0), K3
+ LVSR (CNT)(R0), T1
+ LVX (CNT)(X5), DD1
+
+ // Load constants
+ LVX (CONSTS)(R0), K0
+ LVX (CONSTS)(X0), K5
+ LVX (CONSTS)(X1), FOUR
+ LVX (CONSTS)(X2), SIXTEEN
+ LVX (CONSTS)(X3), TWENTY4
+
+ // Align key and counter
+ VPERM K2, K1, T0, K1
+ VPERM DD0, K2, T0, K2
+ VPERM DD1, K3, T1, K3
+
+ // Load counter to GPR
+ MOVWZ 0(CNT), CNT0
+ MOVWZ 4(CNT), CNT1
+ MOVWZ 8(CNT), CNT2
+ MOVWZ 12(CNT), CNT3
+
+ // Adjust vectors for the initial state
+ VADDUWM K3, K5, K3
+ VADDUWM K3, K5, K4
+ VADDUWM K4, K5, K5
+
+ // Synthesized constants
+ VSPLTISW $-12, TWENTY
+ VSPLTISW $12, TWELVE
+ VSPLTISW $-7, TWENTY5
+
+ VXOR T0, T0, T0
+ VSPLTISW $-1, OUTMASK
+ LVSR (INP)(R0), INPPERM
+ LVSL (OUT)(R0), OUTPERM
+ VPERM OUTMASK, T0, OUTPERM, OUTMASK
+
+loop_outer_vmx:
+ // Load constant
+ MOVD $0x61707865, CON0
+ MOVD $0x3320646e, CON1
+ MOVD $0x79622d32, CON2
+ MOVD $0x6b206574, CON3
+
+ VOR K0, K0, A0
+ VOR K0, K0, A1
+ VOR K0, K0, A2
+ VOR K1, K1, B0
+
+ MOVD $10, TEMP
+
+ // Load key to GPR
+ MOVWZ 0(KEY), X4
+ MOVWZ 4(KEY), X5
+ MOVWZ 8(KEY), X6
+ MOVWZ 12(KEY), X7
+ VOR K1, K1, B1
+ VOR K1, K1, B2
+ MOVWZ 16(KEY), X8
+ MOVWZ 0(CNT), X12
+ MOVWZ 20(KEY), X9
+ MOVWZ 4(CNT), X13
+ VOR K2, K2, C0
+ VOR K2, K2, C1
+ MOVWZ 24(KEY), X10
+ MOVWZ 8(CNT), X14
+ VOR K2, K2, C2
+ VOR K3, K3, D0
+ MOVWZ 28(KEY), X11
+ MOVWZ 12(CNT), X15
+ VOR K4, K4, D1
+ VOR K5, K5, D2
+
+ MOVD X4, TMP0
+ MOVD X5, TMP1
+ MOVD X6, TMP2
+ MOVD X7, TMP3
+ VSPLTISW $7, SEVEN
+
+ MOVD TEMP, CTR
+
+loop_vmx:
+ // CRYPTOGAMS uses a macro to create a loop using perl. This isn't possible
+ // using assembly macros. Therefore, the macro expansion result was used
+ // in order to maintain the algorithm efficiency.
+ // This loop generates three keystream blocks using VMX instructions and,
+ // in parallel, one keystream block using scalar instructions.
+ ADD X4, X0, X0
+ ADD X5, X1, X1
+ VADDUWM A0, B0, A0
+ VADDUWM A1, B1, A1
+ ADD X6, X2, X2
+ ADD X7, X3, X3
+ VADDUWM A2, B2, A2
+ VXOR D0, A0, D0
+ XOR X0, X12, X12
+ XOR X1, X13, X13
+ VXOR D1, A1, D1
+ VXOR D2, A2, D2
+ XOR X2, X14, X14
+ XOR X3, X15, X15
+ VPERM D0, D0, SIXTEEN, D0
+ VPERM D1, D1, SIXTEEN, D1
+ ROTLW $16, X12, X12
+ ROTLW $16, X13, X13
+ VPERM D2, D2, SIXTEEN, D2
+ VADDUWM C0, D0, C0
+ ROTLW $16, X14, X14
+ ROTLW $16, X15, X15
+ VADDUWM C1, D1, C1
+ VADDUWM C2, D2, C2
+ ADD X12, X8, X8
+ ADD X13, X9, X9
+ VXOR B0, C0, T0
+ VXOR B1, C1, T1
+ ADD X14, X10, X10
+ ADD X15, X11, X11
+ VXOR B2, C2, T2
+ VRLW T0, TWELVE, B0
+ XOR X8, X4, X4
+ XOR X9, X5, X5
+ VRLW T1, TWELVE, B1
+ VRLW T2, TWELVE, B2
+ XOR X10, X6, X6
+ XOR X11, X7, X7
+ VADDUWM A0, B0, A0
+ VADDUWM A1, B1, A1
+ ROTLW $12, X4, X4
+ ROTLW $12, X5, X5
+ VADDUWM A2, B2, A2
+ VXOR D0, A0, D0
+ ROTLW $12, X6, X6
+ ROTLW $12, X7, X7
+ VXOR D1, A1, D1
+ VXOR D2, A2, D2
+ ADD X4, X0, X0
+ ADD X5, X1, X1
+ VPERM D0, D0, TWENTY4, D0
+ VPERM D1, D1, TWENTY4, D1
+ ADD X6, X2, X2
+ ADD X7, X3, X3
+ VPERM D2, D2, TWENTY4, D2
+ VADDUWM C0, D0, C0
+ XOR X0, X12, X12
+ XOR X1, X13, X13
+ VADDUWM C1, D1, C1
+ VADDUWM C2, D2, C2
+ XOR X2, X14, X14
+ XOR X3, X15, X15
+ VXOR B0, C0, T0
+ VXOR B1, C1, T1
+ ROTLW $8, X12, X12
+ ROTLW $8, X13, X13
+ VXOR B2, C2, T2
+ VRLW T0, SEVEN, B0
+ ROTLW $8, X14, X14
+ ROTLW $8, X15, X15
+ VRLW T1, SEVEN, B1
+ VRLW T2, SEVEN, B2
+ ADD X12, X8, X8
+ ADD X13, X9, X9
+ VSLDOI $8, C0, C0, C0
+ VSLDOI $8, C1, C1, C1
+ ADD X14, X10, X10
+ ADD X15, X11, X11
+ VSLDOI $8, C2, C2, C2
+ VSLDOI $12, B0, B0, B0
+ XOR X8, X4, X4
+ XOR X9, X5, X5
+ VSLDOI $12, B1, B1, B1
+ VSLDOI $12, B2, B2, B2
+ XOR X10, X6, X6
+ XOR X11, X7, X7
+ VSLDOI $4, D0, D0, D0
+ VSLDOI $4, D1, D1, D1
+ ROTLW $7, X4, X4
+ ROTLW $7, X5, X5
+ VSLDOI $4, D2, D2, D2
+ VADDUWM A0, B0, A0
+ ROTLW $7, X6, X6
+ ROTLW $7, X7, X7
+ VADDUWM A1, B1, A1
+ VADDUWM A2, B2, A2
+ ADD X5, X0, X0
+ ADD X6, X1, X1
+ VXOR D0, A0, D0
+ VXOR D1, A1, D1
+ ADD X7, X2, X2
+ ADD X4, X3, X3
+ VXOR D2, A2, D2
+ VPERM D0, D0, SIXTEEN, D0
+ XOR X0, X15, X15
+ XOR X1, X12, X12
+ VPERM D1, D1, SIXTEEN, D1
+ VPERM D2, D2, SIXTEEN, D2
+ XOR X2, X13, X13
+ XOR X3, X14, X14
+ VADDUWM C0, D0, C0
+ VADDUWM C1, D1, C1
+ ROTLW $16, X15, X15
+ ROTLW $16, X12, X12
+ VADDUWM C2, D2, C2
+ VXOR B0, C0, T0
+ ROTLW $16, X13, X13
+ ROTLW $16, X14, X14
+ VXOR B1, C1, T1
+ VXOR B2, C2, T2
+ ADD X15, X10, X10
+ ADD X12, X11, X11
+ VRLW T0, TWELVE, B0
+ VRLW T1, TWELVE, B1
+ ADD X13, X8, X8
+ ADD X14, X9, X9
+ VRLW T2, TWELVE, B2
+ VADDUWM A0, B0, A0
+ XOR X10, X5, X5
+ XOR X11, X6, X6
+ VADDUWM A1, B1, A1
+ VADDUWM A2, B2, A2
+ XOR X8, X7, X7
+ XOR X9, X4, X4
+ VXOR D0, A0, D0
+ VXOR D1, A1, D1
+ ROTLW $12, X5, X5
+ ROTLW $12, X6, X6
+ VXOR D2, A2, D2
+ VPERM D0, D0, TWENTY4, D0
+ ROTLW $12, X7, X7
+ ROTLW $12, X4, X4
+ VPERM D1, D1, TWENTY4, D1
+ VPERM D2, D2, TWENTY4, D2
+ ADD X5, X0, X0
+ ADD X6, X1, X1
+ VADDUWM C0, D0, C0
+ VADDUWM C1, D1, C1
+ ADD X7, X2, X2
+ ADD X4, X3, X3
+ VADDUWM C2, D2, C2
+ VXOR B0, C0, T0
+ XOR X0, X15, X15
+ XOR X1, X12, X12
+ VXOR B1, C1, T1
+ VXOR B2, C2, T2
+ XOR X2, X13, X13
+ XOR X3, X14, X14
+ VRLW T0, SEVEN, B0
+ VRLW T1, SEVEN, B1
+ ROTLW $8, X15, X15
+ ROTLW $8, X12, X12
+ VRLW T2, SEVEN, B2
+ VSLDOI $8, C0, C0, C0
+ ROTLW $8, X13, X13
+ ROTLW $8, X14, X14
+ VSLDOI $8, C1, C1, C1
+ VSLDOI $8, C2, C2, C2
+ ADD X15, X10, X10
+ ADD X12, X11, X11
+ VSLDOI $4, B0, B0, B0
+ VSLDOI $4, B1, B1, B1
+ ADD X13, X8, X8
+ ADD X14, X9, X9
+ VSLDOI $4, B2, B2, B2
+ VSLDOI $12, D0, D0, D0
+ XOR X10, X5, X5
+ XOR X11, X6, X6
+ VSLDOI $12, D1, D1, D1
+ VSLDOI $12, D2, D2, D2
+ XOR X8, X7, X7
+ XOR X9, X4, X4
+ ROTLW $7, X5, X5
+ ROTLW $7, X6, X6
+ ROTLW $7, X7, X7
+ ROTLW $7, X4, X4
+ BC 0x10, 0, loop_vmx
+
+ SUB $256, LEN, LEN
+
+ // Accumulate key block
+ ADD $0x61707865, X0, X0
+ ADD $0x3320646e, X1, X1
+ ADD $0x79622d32, X2, X2
+ ADD $0x6b206574, X3, X3
+ ADD TMP0, X4, X4
+ ADD TMP1, X5, X5
+ ADD TMP2, X6, X6
+ ADD TMP3, X7, X7
+ MOVWZ 16(KEY), TMP0
+ MOVWZ 20(KEY), TMP1
+ MOVWZ 24(KEY), TMP2
+ MOVWZ 28(KEY), TMP3
+ ADD TMP0, X8, X8
+ ADD TMP1, X9, X9
+ ADD TMP2, X10, X10
+ ADD TMP3, X11, X11
+
+ MOVWZ 12(CNT), TMP0
+ MOVWZ 8(CNT), TMP1
+ MOVWZ 4(CNT), TMP2
+ MOVWZ 0(CNT), TEMP
+ ADD TMP0, X15, X15
+ ADD TMP1, X14, X14
+ ADD TMP2, X13, X13
+ ADD TEMP, X12, X12
+
+ // Accumulate key block
+ VADDUWM A0, K0, A0
+ VADDUWM A1, K0, A1
+ VADDUWM A2, K0, A2
+ VADDUWM B0, K1, B0
+ VADDUWM B1, K1, B1
+ VADDUWM B2, K1, B2
+ VADDUWM C0, K2, C0
+ VADDUWM C1, K2, C1
+ VADDUWM C2, K2, C2
+ VADDUWM D0, K3, D0
+ VADDUWM D1, K4, D1
+ VADDUWM D2, K5, D2
+
+ // Increment counter
+ ADD $4, TEMP, TEMP
+ MOVW TEMP, 0(CNT)
+
+ VADDUWM K3, FOUR, K3
+ VADDUWM K4, FOUR, K4
+ VADDUWM K5, FOUR, K5
+
+ // XOR the input slice (INP) with the keystream, which is stored in GPRs (X0-X3).
+
+ // Load input (aligned or not)
+ MOVWZ 0(INP), TMP0
+ MOVWZ 4(INP), TMP1
+ MOVWZ 8(INP), TMP2
+ MOVWZ 12(INP), TMP3
+
+ // XOR with input
+ XOR TMP0, X0, X0
+ XOR TMP1, X1, X1
+ XOR TMP2, X2, X2
+ XOR TMP3, X3, X3
+ MOVWZ 16(INP), TMP0
+ MOVWZ 20(INP), TMP1
+ MOVWZ 24(INP), TMP2
+ MOVWZ 28(INP), TMP3
+ XOR TMP0, X4, X4
+ XOR TMP1, X5, X5
+ XOR TMP2, X6, X6
+ XOR TMP3, X7, X7
+ MOVWZ 32(INP), TMP0
+ MOVWZ 36(INP), TMP1
+ MOVWZ 40(INP), TMP2
+ MOVWZ 44(INP), TMP3
+ XOR TMP0, X8, X8
+ XOR TMP1, X9, X9
+ XOR TMP2, X10, X10
+ XOR TMP3, X11, X11
+ MOVWZ 48(INP), TMP0
+ MOVWZ 52(INP), TMP1
+ MOVWZ 56(INP), TMP2
+ MOVWZ 60(INP), TMP3
+ XOR TMP0, X12, X12
+ XOR TMP1, X13, X13
+ XOR TMP2, X14, X14
+ XOR TMP3, X15, X15
+
+ // Store output (aligned or not)
+ MOVW X0, 0(OUT)
+ MOVW X1, 4(OUT)
+ MOVW X2, 8(OUT)
+ MOVW X3, 12(OUT)
+
+ ADD $64, INP, INP // INP points to the end of the slice for the alignment code below
+
+ MOVW X4, 16(OUT)
+ MOVD $16, TMP0
+ MOVW X5, 20(OUT)
+ MOVD $32, TMP1
+ MOVW X6, 24(OUT)
+ MOVD $48, TMP2
+ MOVW X7, 28(OUT)
+ MOVD $64, TMP3
+ MOVW X8, 32(OUT)
+ MOVW X9, 36(OUT)
+ MOVW X10, 40(OUT)
+ MOVW X11, 44(OUT)
+ MOVW X12, 48(OUT)
+ MOVW X13, 52(OUT)
+ MOVW X14, 56(OUT)
+ MOVW X15, 60(OUT)
+ ADD $64, OUT, OUT
+
+ // Load input
+ LVX (INP)(R0), DD0
+ LVX (INP)(TMP0), DD1
+ LVX (INP)(TMP1), DD2
+ LVX (INP)(TMP2), DD3
+ LVX (INP)(TMP3), DD4
+ ADD $64, INP, INP
+
+ VPERM DD1, DD0, INPPERM, DD0 // Align input
+ VPERM DD2, DD1, INPPERM, DD1
+ VPERM DD3, DD2, INPPERM, DD2
+ VPERM DD4, DD3, INPPERM, DD3
+ VXOR A0, DD0, A0 // XOR with input
+ VXOR B0, DD1, B0
+ LVX (INP)(TMP0), DD1 // Keep loading input
+ VXOR C0, DD2, C0
+ LVX (INP)(TMP1), DD2
+ VXOR D0, DD3, D0
+ LVX (INP)(TMP2), DD3
+ LVX (INP)(TMP3), DD0
+ ADD $64, INP, INP
+ MOVD $63, TMP3 // 63 is not a typo
+ VPERM A0, A0, OUTPERM, A0
+ VPERM B0, B0, OUTPERM, B0
+ VPERM C0, C0, OUTPERM, C0
+ VPERM D0, D0, OUTPERM, D0
+
+ VPERM DD1, DD4, INPPERM, DD4 // Align input
+ VPERM DD2, DD1, INPPERM, DD1
+ VPERM DD3, DD2, INPPERM, DD2
+ VPERM DD0, DD3, INPPERM, DD3
+ VXOR A1, DD4, A1
+ VXOR B1, DD1, B1
+ LVX (INP)(TMP0), DD1 // Keep loading
+ VXOR C1, DD2, C1
+ LVX (INP)(TMP1), DD2
+ VXOR D1, DD3, D1
+ LVX (INP)(TMP2), DD3
+
+ // Note that the LVX address is always rounded down to the nearest 16-byte
+ // boundary, and that it always points to at most 15 bytes beyond the end of
+ // the slice, so we cannot cross a page boundary.
+ LVX (INP)(TMP3), DD4 // Redundant in aligned case.
+ ADD $64, INP, INP
+ VPERM A1, A1, OUTPERM, A1 // Pre-misalign output
+ VPERM B1, B1, OUTPERM, B1
+ VPERM C1, C1, OUTPERM, C1
+ VPERM D1, D1, OUTPERM, D1
+
+ VPERM DD1, DD0, INPPERM, DD0 // Align Input
+ VPERM DD2, DD1, INPPERM, DD1
+ VPERM DD3, DD2, INPPERM, DD2
+ VPERM DD4, DD3, INPPERM, DD3
+ VXOR A2, DD0, A2
+ VXOR B2, DD1, B2
+ VXOR C2, DD2, C2
+ VXOR D2, DD3, D2
+ VPERM A2, A2, OUTPERM, A2
+ VPERM B2, B2, OUTPERM, B2
+ VPERM C2, C2, OUTPERM, C2
+ VPERM D2, D2, OUTPERM, D2
+
+ ANDCC $15, OUT, X1 // Is out aligned?
+ MOVD OUT, X0
+
+ VSEL A0, B0, OUTMASK, DD0 // Collect pre-misaligned output
+ VSEL B0, C0, OUTMASK, DD1
+ VSEL C0, D0, OUTMASK, DD2
+ VSEL D0, A1, OUTMASK, DD3
+ VSEL A1, B1, OUTMASK, B0
+ VSEL B1, C1, OUTMASK, C0
+ VSEL C1, D1, OUTMASK, D0
+ VSEL D1, A2, OUTMASK, A1
+ VSEL A2, B2, OUTMASK, B1
+ VSEL B2, C2, OUTMASK, C1
+ VSEL C2, D2, OUTMASK, D1
+
+ STVX DD0, (OUT+TMP0)
+ STVX DD1, (OUT+TMP1)
+ STVX DD2, (OUT+TMP2)
+ ADD $64, OUT, OUT
+ STVX DD3, (OUT+R0)
+ STVX B0, (OUT+TMP0)
+ STVX C0, (OUT+TMP1)
+ STVX D0, (OUT+TMP2)
+ ADD $64, OUT, OUT
+ STVX A1, (OUT+R0)
+ STVX B1, (OUT+TMP0)
+ STVX C1, (OUT+TMP1)
+ STVX D1, (OUT+TMP2)
+ ADD $64, OUT, OUT
+
+ BEQ aligned_vmx
+
+ SUB X1, OUT, X2 // in misaligned case edges
+ MOVD $0, X3 // are written byte-by-byte
+
+unaligned_tail_vmx:
+ STVEBX D2, (X2+X3)
+ ADD $1, X3, X3
+ CMPW X3, X1
+ BNE unaligned_tail_vmx
+ SUB X1, X0, X2
+
+unaligned_head_vmx:
+ STVEBX A0, (X2+X1)
+ CMPW X1, $15
+ ADD $1, X1, X1
+ BNE unaligned_head_vmx
+
+ CMPU LEN, $255 // done with 256-byte block yet?
+ BGT loop_outer_vmx
+
+ JMP done_vmx
+
+aligned_vmx:
+ STVX A0, (X0+R0)
+ CMPU LEN, $255 // done with 256-byte block yet?
+ BGT loop_outer_vmx
+
+done_vmx:
+ RET
diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go
index 47eac031..bf8beba6 100644
--- a/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go
+++ b/vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !arm64,!s390x arm64,!go1.11 gccgo appengine
+// +build !ppc64le,!arm64,!s390x arm64,!go1.11 gccgo appengine
package chacha20
diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go
new file mode 100644
index 00000000..9bd6df64
--- /dev/null
+++ b/vendor/golang.org/x/crypto/internal/chacha20/chacha_ppc64le.go
@@ -0,0 +1,51 @@
+// Copyright 2019 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.
+
+// +build ppc64le,!gccgo,!appengine
+
+package chacha20
+
+import "encoding/binary"
+
+var haveAsm = true
+
+const bufSize = 256
+
+//go:noescape
+func chaCha20_ctr32_vmx(out, inp *byte, len int, key *[8]uint32, counter *uint32)
+
+func (c *Cipher) xorKeyStreamAsm(dst, src []byte) {
+ if len(src) >= bufSize {
+ chaCha20_ctr32_vmx(&dst[0], &src[0], len(src)-len(src)%bufSize, &c.key, &c.counter)
+ }
+ if len(src)%bufSize != 0 {
+ chaCha20_ctr32_vmx(&c.buf[0], &c.buf[0], bufSize, &c.key, &c.counter)
+ start := len(src) - len(src)%bufSize
+ ts, td, tb := src[start:], dst[start:], c.buf[:]
+ // Unroll loop to XOR 32 bytes per iteration.
+ for i := 0; i < len(ts)-32; i += 32 {
+ td, tb = td[:len(ts)], tb[:len(ts)] // bounds check elimination
+ s0 := binary.LittleEndian.Uint64(ts[0:8])
+ s1 := binary.LittleEndian.Uint64(ts[8:16])
+ s2 := binary.LittleEndian.Uint64(ts[16:24])
+ s3 := binary.LittleEndian.Uint64(ts[24:32])
+ b0 := binary.LittleEndian.Uint64(tb[0:8])
+ b1 := binary.LittleEndian.Uint64(tb[8:16])
+ b2 := binary.LittleEndian.Uint64(tb[16:24])
+ b3 := binary.LittleEndian.Uint64(tb[24:32])
+ binary.LittleEndian.PutUint64(td[0:8], s0^b0)
+ binary.LittleEndian.PutUint64(td[8:16], s1^b1)
+ binary.LittleEndian.PutUint64(td[16:24], s2^b2)
+ binary.LittleEndian.PutUint64(td[24:32], s3^b3)
+ ts, td, tb = ts[32:], td[32:], tb[32:]
+ }
+ td, tb = td[:len(ts)], tb[:len(ts)] // bounds check elimination
+ for i, v := range ts {
+ td[i] = tb[i] ^ v
+ }
+ c.len = bufSize - (len(src) % bufSize)
+
+ }
+
+}
diff --git a/vendor/golang.org/x/crypto/poly1305/mac_noasm.go b/vendor/golang.org/x/crypto/poly1305/mac_noasm.go
index 8387d299..a8dd589a 100644
--- a/vendor/golang.org/x/crypto/poly1305/mac_noasm.go
+++ b/vendor/golang.org/x/crypto/poly1305/mac_noasm.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !amd64 gccgo appengine
+// +build !amd64,!ppc64le gccgo appengine
package poly1305
diff --git a/vendor/golang.org/x/crypto/poly1305/sum_noasm.go b/vendor/golang.org/x/crypto/poly1305/sum_noasm.go
index fcdef46a..8a9c2070 100644
--- a/vendor/golang.org/x/crypto/poly1305/sum_noasm.go
+++ b/vendor/golang.org/x/crypto/poly1305/sum_noasm.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build s390x,!go1.11 !arm,!amd64,!s390x gccgo appengine nacl
+// +build s390x,!go1.11 !arm,!amd64,!s390x,!ppc64le gccgo appengine nacl
package poly1305
diff --git a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go
new file mode 100644
index 00000000..2402b637
--- /dev/null
+++ b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.go
@@ -0,0 +1,68 @@
+// Copyright 2019 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.
+
+// +build ppc64le,!gccgo,!appengine
+
+package poly1305
+
+//go:noescape
+func initialize(state *[7]uint64, key *[32]byte)
+
+//go:noescape
+func update(state *[7]uint64, msg []byte)
+
+//go:noescape
+func finalize(tag *[TagSize]byte, state *[7]uint64)
+
+// Sum generates an authenticator for m using a one-time key and puts the
+// 16-byte result into out. Authenticating two different messages with the same
+// key allows an attacker to forge messages at will.
+func Sum(out *[16]byte, m []byte, key *[32]byte) {
+ h := newMAC(key)
+ h.Write(m)
+ h.Sum(out)
+}
+
+func newMAC(key *[32]byte) (h mac) {
+ initialize(&h.state, key)
+ return
+}
+
+type mac struct {
+ state [7]uint64 // := uint64{ h0, h1, h2, r0, r1, pad0, pad1 }
+
+ buffer [TagSize]byte
+ offset int
+}
+
+func (h *mac) Write(p []byte) (n int, err error) {
+ n = len(p)
+ if h.offset > 0 {
+ remaining := TagSize - h.offset
+ if n < remaining {
+ h.offset += copy(h.buffer[h.offset:], p)
+ return n, nil
+ }
+ copy(h.buffer[h.offset:], p[:remaining])
+ p = p[remaining:]
+ h.offset = 0
+ update(&h.state, h.buffer[:])
+ }
+ if nn := len(p) - (len(p) % TagSize); nn > 0 {
+ update(&h.state, p[:nn])
+ p = p[nn:]
+ }
+ if len(p) > 0 {
+ h.offset += copy(h.buffer[h.offset:], p)
+ }
+ return n, nil
+}
+
+func (h *mac) Sum(out *[16]byte) {
+ state := h.state
+ if h.offset > 0 {
+ update(&state, h.buffer[:h.offset])
+ }
+ finalize(out, &state)
+}
diff --git a/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s
new file mode 100644
index 00000000..55c7167e
--- /dev/null
+++ b/vendor/golang.org/x/crypto/poly1305/sum_ppc64le.s
@@ -0,0 +1,247 @@
+// Copyright 2019 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.
+
+// +build ppc64le,!gccgo,!appengine
+
+#include "textflag.h"
+
+// This was ported from the amd64 implementation.
+
+#define POLY1305_ADD(msg, h0, h1, h2, t0, t1, t2) \
+ MOVD (msg), t0; \
+ MOVD 8(msg), t1; \
+ MOVD $1, t2; \
+ ADDC t0, h0, h0; \
+ ADDE t1, h1, h1; \
+ ADDE t2, h2; \
+ ADD $16, msg
+
+#define POLY1305_MUL(h0, h1, h2, r0, r1, t0, t1, t2, t3, t4, t5) \
+ MULLD r0, h0, t0; \
+ MULLD r0, h1, t4; \
+ MULHDU r0, h0, t1; \
+ MULHDU r0, h1, t5; \
+ ADDC t4, t1, t1; \
+ MULLD r0, h2, t2; \
+ ADDZE t5; \
+ MULHDU r1, h0, t4; \
+ MULLD r1, h0, h0; \
+ ADD t5, t2, t2; \
+ ADDC h0, t1, t1; \
+ MULLD h2, r1, t3; \
+ ADDZE t4, h0; \
+ MULHDU r1, h1, t5; \
+ MULLD r1, h1, t4; \
+ ADDC t4, t2, t2; \
+ ADDE t5, t3, t3; \
+ ADDC h0, t2, t2; \
+ MOVD $-4, t4; \
+ MOVD t0, h0; \
+ MOVD t1, h1; \
+ ADDZE t3; \
+ ANDCC $3, t2, h2; \
+ AND t2, t4, t0; \
+ ADDC t0, h0, h0; \
+ ADDE t3, h1, h1; \
+ SLD $62, t3, t4; \
+ SRD $2, t2; \
+ ADDZE h2; \
+ OR t4, t2, t2; \
+ SRD $2, t3; \
+ ADDC t2, h0, h0; \
+ ADDE t3, h1, h1; \
+ ADDZE h2
+
+DATA ·poly1305Mask<>+0x00(SB)/8, $0x0FFFFFFC0FFFFFFF
+DATA ·poly1305Mask<>+0x08(SB)/8, $0x0FFFFFFC0FFFFFFC
+GLOBL ·poly1305Mask<>(SB), RODATA, $16
+
+// func update(state *[7]uint64, msg []byte)
+
+TEXT ·update(SB), $0-32
+ MOVD state+0(FP), R3
+ MOVD msg_base+8(FP), R4
+ MOVD msg_len+16(FP), R5
+
+ MOVD 0(R3), R8 // h0
+ MOVD 8(R3), R9 // h1
+ MOVD 16(R3), R10 // h2
+ MOVD 24(R3), R11 // r0
+ MOVD 32(R3), R12 // r1
+
+ CMP R5, $16
+ BLT bytes_between_0_and_15
+
+loop:
+ POLY1305_ADD(R4, R8, R9, R10, R20, R21, R22)
+
+multiply:
+ POLY1305_MUL(R8, R9, R10, R11, R12, R16, R17, R18, R14, R20, R21)
+ ADD $-16, R5
+ CMP R5, $16
+ BGE loop
+
+bytes_between_0_and_15:
+ CMP $0, R5
+ BEQ done
+ MOVD $0, R16 // h0
+ MOVD $0, R17 // h1
+
+flush_buffer:
+ CMP R5, $8
+ BLE just1
+
+ MOVD $8, R21
+ SUB R21, R5, R21
+
+ // Greater than 8 -- load the rightmost remaining bytes in msg
+ // and put into R17 (h1)
+ MOVD (R4)(R21), R17
+ MOVD $16, R22
+
+ // Find the offset to those bytes
+ SUB R5, R22, R22
+ SLD $3, R22
+
+ // Shift to get only the bytes in msg
+ SRD R22, R17, R17
+
+ // Put 1 at high end
+ MOVD $1, R23
+ SLD $3, R21
+ SLD R21, R23, R23
+ OR R23, R17, R17
+
+ // Remainder is 8
+ MOVD $8, R5
+
+just1:
+ CMP R5, $8
+ BLT less8
+
+ // Exactly 8
+ MOVD (R4), R16
+
+ CMP $0, R17
+
+ // Check if we've already set R17; if not
+ // set 1 to indicate end of msg.
+ BNE carry
+ MOVD $1, R17
+ BR carry
+
+less8:
+ MOVD $0, R16 // h0
+ MOVD $0, R22 // shift count
+ CMP R5, $4
+ BLT less4
+ MOVWZ (R4), R16
+ ADD $4, R4
+ ADD $-4, R5
+ MOVD $32, R22
+
+less4:
+ CMP R5, $2
+ BLT less2
+ MOVHZ (R4), R21
+ SLD R22, R21, R21
+ OR R16, R21, R16
+ ADD $16, R22
+ ADD $-2, R5
+ ADD $2, R4
+
+less2:
+ CMP $0, R5
+ BEQ insert1
+ MOVBZ (R4), R21
+ SLD R22, R21, R21
+ OR R16, R21, R16
+ ADD $8, R22
+
+insert1:
+ // Insert 1 at end of msg
+ MOVD $1, R21
+ SLD R22, R21, R21
+ OR R16, R21, R16
+
+carry:
+ // Add new values to h0, h1, h2
+ ADDC R16, R8
+ ADDE R17, R9
+ ADDE $0, R10
+ MOVD $16, R5
+ ADD R5, R4
+ BR multiply
+
+done:
+ // Save h0, h1, h2 in state
+ MOVD R8, 0(R3)
+ MOVD R9, 8(R3)
+ MOVD R10, 16(R3)
+ RET
+
+// func initialize(state *[7]uint64, key *[32]byte)
+TEXT ·initialize(SB), $0-16
+ MOVD state+0(FP), R3
+ MOVD key+8(FP), R4
+
+ // state[0...7] is initialized with zero
+ // Load key
+ MOVD 0(R4), R5
+ MOVD 8(R4), R6
+ MOVD 16(R4), R7
+ MOVD 24(R4), R8
+
+ // Address of key mask
+ MOVD $·poly1305Mask<>(SB), R9
+
+ // Save original key in state
+ MOVD R7, 40(R3)
+ MOVD R8, 48(R3)
+
+ // Get mask
+ MOVD (R9), R7
+ MOVD 8(R9), R8
+
+ // And with key
+ AND R5, R7, R5
+ AND R6, R8, R6
+
+ // Save masked key in state
+ MOVD R5, 24(R3)
+ MOVD R6, 32(R3)
+ RET
+
+// func finalize(tag *[TagSize]byte, state *[7]uint64)
+TEXT ·finalize(SB), $0-16
+ MOVD tag+0(FP), R3
+ MOVD state+8(FP), R4
+
+ // Get h0, h1, h2 from state
+ MOVD 0(R4), R5
+ MOVD 8(R4), R6
+ MOVD 16(R4), R7
+
+ // Save h0, h1
+ MOVD R5, R8
+ MOVD R6, R9
+ MOVD $3, R20
+ MOVD $-1, R21
+ SUBC $-5, R5
+ SUBE R21, R6
+ SUBE R20, R7
+ MOVD $0, R21
+ SUBZE R21
+
+ // Check for carry
+ CMP $0, R21
+ ISEL $2, R5, R8, R5
+ ISEL $2, R6, R9, R6
+ MOVD 40(R4), R8
+ MOVD 48(R4), R9
+ ADDC R8, R5
+ ADDE R9, R6
+ MOVD R5, 0(R3)
+ MOVD R6, 8(R3)
+ RET
diff --git a/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go
index f9269c38..656e8df9 100644
--- a/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go
@@ -6,10 +6,9 @@
package salsa
-// This function is implemented in salsa2020_amd64.s.
-
//go:noescape
+// salsa2020XORKeyStream is implemented in salsa20_amd64.s.
func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte)
// XORKeyStream crypts bytes from in to out using the given key and counters.
diff --git a/vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.s
index 22afbdca..18085d2e 100644
--- a/vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.s
@@ -99,30 +99,24 @@ TEXT ·salsa2020XORKeyStream(SB),0,$456-40 // frame = 424 + 32 byte alignment
MOVL 36 (SP),CX
MOVL DX,288(SP)
MOVL CX,304(SP)
- ADDQ $1,DX
SHLQ $32,CX
ADDQ CX,DX
+ ADDQ $1,DX
MOVQ DX,CX
SHRQ $32,CX
MOVL DX, 292 (SP)
MOVL CX, 308 (SP)
ADDQ $1,DX
- SHLQ $32,CX
- ADDQ CX,DX
MOVQ DX,CX
SHRQ $32,CX
MOVL DX, 296 (SP)
MOVL CX, 312 (SP)
ADDQ $1,DX
- SHLQ $32,CX
- ADDQ CX,DX
MOVQ DX,CX
SHRQ $32,CX
MOVL DX, 300 (SP)
MOVL CX, 316 (SP)
ADDQ $1,DX
- SHLQ $32,CX
- ADDQ CX,DX
MOVQ DX,CX
SHRQ $32,CX
MOVL DX,16(SP)
diff --git a/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.go b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.go
new file mode 100644
index 00000000..8a46bd2b
--- /dev/null
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.go
@@ -0,0 +1,14 @@
+// Copyright 2019 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.
+
+// +build !amd64 appengine gccgo
+
+package salsa
+
+// XORKeyStream crypts bytes from in to out using the given key and counters.
+// In and out must overlap entirely or not at all. Counter
+// contains the raw salsa20 counter bytes (both nonce and block counter).
+func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
+ genericXORKeyStream(out, in, counter, key)
+}
diff --git a/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
index 22126d17..68169c6d 100644
--- a/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !amd64 appengine gccgo
-
package salsa
const rounds = 20
@@ -202,10 +200,9 @@ func core(out *[64]byte, in *[16]byte, k *[32]byte, c *[16]byte) {
out[63] = byte(x15 >> 24)
}
-// XORKeyStream crypts bytes from in to out using the given key and counters.
-// In and out must overlap entirely or not at all. Counter
-// contains the raw salsa20 counter bytes (both nonce and block counter).
-func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
+// genericXORKeyStream is the generic implementation of XORKeyStream to be used
+// when no assembly implementation is available.
+func genericXORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) {
var block [64]byte
var counterCopy [16]byte
copy(counterCopy[:], counter[:])
diff --git a/vendor/golang.org/x/crypto/ssh/cipher.go b/vendor/golang.org/x/crypto/ssh/cipher.go
index 67b01261..a65a923b 100644
--- a/vendor/golang.org/x/crypto/ssh/cipher.go
+++ b/vendor/golang.org/x/crypto/ssh/cipher.go
@@ -149,8 +149,8 @@ type streamPacketCipher struct {
macResult []byte
}
-// readPacket reads and decrypt a single packet from the reader argument.
-func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+// readCipherPacket reads and decrypt a single packet from the reader argument.
+func (s *streamPacketCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
if _, err := io.ReadFull(r, s.prefix[:]); err != nil {
return nil, err
}
@@ -221,8 +221,8 @@ func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, err
return s.packetData[:length-paddingLength-1], nil
}
-// writePacket encrypts and sends a packet of data to the writer argument
-func (s *streamPacketCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
+// writeCipherPacket encrypts and sends a packet of data to the writer argument
+func (s *streamPacketCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
if len(packet) > maxPacket {
return errors.New("ssh: packet too large")
}
@@ -327,7 +327,7 @@ func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs directionAlgorithms)
const gcmTagSize = 16
-func (c *gcmCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
+func (c *gcmCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
// Pad out to multiple of 16 bytes. This is different from the
// stream cipher because that encrypts the length too.
padding := byte(packetSizeMultiple - (1+len(packet))%packetSizeMultiple)
@@ -370,7 +370,7 @@ func (c *gcmCipher) incIV() {
}
}
-func (c *gcmCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+func (c *gcmCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
if _, err := io.ReadFull(r, c.prefix[:]); err != nil {
return nil, err
}
@@ -486,8 +486,8 @@ type cbcError string
func (e cbcError) Error() string { return string(e) }
-func (c *cbcCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
- p, err := c.readPacketLeaky(seqNum, r)
+func (c *cbcCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+ p, err := c.readCipherPacketLeaky(seqNum, r)
if err != nil {
if _, ok := err.(cbcError); ok {
// Verification error: read a fixed amount of
@@ -500,7 +500,7 @@ func (c *cbcCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
return p, err
}
-func (c *cbcCipher) readPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error) {
+func (c *cbcCipher) readCipherPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error) {
blockSize := c.decrypter.BlockSize()
// Read the header, which will include some of the subsequent data in the
@@ -576,7 +576,7 @@ func (c *cbcCipher) readPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error)
return c.packetData[prefixLen:paddingStart], nil
}
-func (c *cbcCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
+func (c *cbcCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
effectiveBlockSize := maxUInt32(cbcMinPacketSizeMultiple, c.encrypter.BlockSize())
// Length of encrypted portion of the packet (header, payload, padding).
@@ -665,7 +665,7 @@ func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs directionA
return c, nil
}
-func (c *chacha20Poly1305Cipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+func (c *chacha20Poly1305Cipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
nonce := [3]uint32{0, 0, bits.ReverseBytes32(seqNum)}
s := chacha20.New(c.contentKey, nonce)
var polyKey [32]byte
@@ -723,7 +723,7 @@ func (c *chacha20Poly1305Cipher) readPacket(seqNum uint32, r io.Reader) ([]byte,
return plain, nil
}
-func (c *chacha20Poly1305Cipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, payload []byte) error {
+func (c *chacha20Poly1305Cipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, payload []byte) error {
nonce := [3]uint32{0, 0, bits.ReverseBytes32(seqNum)}
s := chacha20.New(c.contentKey, nonce)
var polyKey [32]byte
diff --git a/vendor/golang.org/x/crypto/ssh/client_auth.go b/vendor/golang.org/x/crypto/ssh/client_auth.go
index 5f44b774..0590070e 100644
--- a/vendor/golang.org/x/crypto/ssh/client_auth.go
+++ b/vendor/golang.org/x/crypto/ssh/client_auth.go
@@ -523,3 +523,117 @@ func (r *retryableAuthMethod) method() string {
func RetryableAuthMethod(auth AuthMethod, maxTries int) AuthMethod {
return &retryableAuthMethod{authMethod: auth, maxTries: maxTries}
}
+
+// GSSAPIWithMICAuthMethod is an AuthMethod with "gssapi-with-mic" authentication.
+// See RFC 4462 section 3
+// gssAPIClient is implementation of the GSSAPIClient interface, see the definition of the interface for details.
+// target is the server host you want to log in to.
+func GSSAPIWithMICAuthMethod(gssAPIClient GSSAPIClient, target string) AuthMethod {
+ if gssAPIClient == nil {
+ panic("gss-api client must be not nil with enable gssapi-with-mic")
+ }
+ return &gssAPIWithMICCallback{gssAPIClient: gssAPIClient, target: target}
+}
+
+type gssAPIWithMICCallback struct {
+ gssAPIClient GSSAPIClient
+ target string
+}
+
+func (g *gssAPIWithMICCallback) auth(session []byte, user string, c packetConn, rand io.Reader) (authResult, []string, error) {
+ m := &userAuthRequestMsg{
+ User: user,
+ Service: serviceSSH,
+ Method: g.method(),
+ }
+ // The GSS-API authentication method is initiated when the client sends an SSH_MSG_USERAUTH_REQUEST.
+ // See RFC 4462 section 3.2.
+ m.Payload = appendU32(m.Payload, 1)
+ m.Payload = appendString(m.Payload, string(krb5OID))
+ if err := c.writePacket(Marshal(m)); err != nil {
+ return authFailure, nil, err
+ }
+ // The server responds to the SSH_MSG_USERAUTH_REQUEST with either an
+ // SSH_MSG_USERAUTH_FAILURE if none of the mechanisms are supported or
+ // with an SSH_MSG_USERAUTH_GSSAPI_RESPONSE.
+ // See RFC 4462 section 3.3.
+ // OpenSSH supports Kerberos V5 mechanism only for GSS-API authentication,so I don't want to check
+ // selected mech if it is valid.
+ packet, err := c.readPacket()
+ if err != nil {
+ return authFailure, nil, err
+ }
+ userAuthGSSAPIResp := &userAuthGSSAPIResponse{}
+ if err := Unmarshal(packet, userAuthGSSAPIResp); err != nil {
+ return authFailure, nil, err
+ }
+ // Start the loop into the exchange token.
+ // See RFC 4462 section 3.4.
+ var token []byte
+ defer g.gssAPIClient.DeleteSecContext()
+ for {
+ // Initiates the establishment of a security context between the application and a remote peer.
+ nextToken, needContinue, err := g.gssAPIClient.InitSecContext("host@"+g.target, token, false)
+ if err != nil {
+ return authFailure, nil, err
+ }
+ if len(nextToken) > 0 {
+ if err := c.writePacket(Marshal(&userAuthGSSAPIToken{
+ Token: nextToken,
+ })); err != nil {
+ return authFailure, nil, err
+ }
+ }
+ if !needContinue {
+ break
+ }
+ packet, err = c.readPacket()
+ if err != nil {
+ return authFailure, nil, err
+ }
+ switch packet[0] {
+ case msgUserAuthFailure:
+ var msg userAuthFailureMsg
+ if err := Unmarshal(packet, &msg); err != nil {
+ return authFailure, nil, err
+ }
+ if msg.PartialSuccess {
+ return authPartialSuccess, msg.Methods, nil
+ }
+ return authFailure, msg.Methods, nil
+ case msgUserAuthGSSAPIError:
+ userAuthGSSAPIErrorResp := &userAuthGSSAPIError{}
+ if err := Unmarshal(packet, userAuthGSSAPIErrorResp); err != nil {
+ return authFailure, nil, err
+ }
+ return authFailure, nil, fmt.Errorf("GSS-API Error:\n"+
+ "Major Status: %d\n"+
+ "Minor Status: %d\n"+
+ "Error Message: %s\n", userAuthGSSAPIErrorResp.MajorStatus, userAuthGSSAPIErrorResp.MinorStatus,
+ userAuthGSSAPIErrorResp.Message)
+ case msgUserAuthGSSAPIToken:
+ userAuthGSSAPITokenReq := &userAuthGSSAPIToken{}
+ if err := Unmarshal(packet, userAuthGSSAPITokenReq); err != nil {
+ return authFailure, nil, err
+ }
+ token = userAuthGSSAPITokenReq.Token
+ }
+ }
+ // Binding Encryption Keys.
+ // See RFC 4462 section 3.5.
+ micField := buildMIC(string(session), user, "ssh-connection", "gssapi-with-mic")
+ micToken, err := g.gssAPIClient.GetMIC(micField)
+ if err != nil {
+ return authFailure, nil, err
+ }
+ if err := c.writePacket(Marshal(&userAuthGSSAPIMIC{
+ MIC: micToken,
+ })); err != nil {
+ return authFailure, nil, err
+ }
+ return handleAuthResponse(c)
+}
+
+func (g *gssAPIWithMICCallback) method() string {
+ return "gssapi-with-mic"
+}
diff --git a/vendor/golang.org/x/crypto/ssh/common.go b/vendor/golang.org/x/crypto/ssh/common.go
index 04f3620b..d97415d2 100644
--- a/vendor/golang.org/x/crypto/ssh/common.go
+++ b/vendor/golang.org/x/crypto/ssh/common.go
@@ -109,6 +109,7 @@ func findCommon(what string, client []string, server []string) (common string, e
return "", fmt.Errorf("ssh: no common algorithm for %s; client offered: %v, server offered: %v", what, client, server)
}
+// directionAlgorithms records algorithm choices in one direction (either read or write)
type directionAlgorithms struct {
Cipher string
MAC string
@@ -137,7 +138,7 @@ type algorithms struct {
r directionAlgorithms
}
-func findAgreedAlgorithms(clientKexInit, serverKexInit *kexInitMsg) (algs *algorithms, err error) {
+func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMsg) (algs *algorithms, err error) {
result := &algorithms{}
result.kex, err = findCommon("key exchange", clientKexInit.KexAlgos, serverKexInit.KexAlgos)
@@ -150,32 +151,37 @@ func findAgreedAlgorithms(clientKexInit, serverKexInit *kexInitMsg) (algs *algor
return
}
- result.w.Cipher, err = findCommon("client to server cipher", clientKexInit.CiphersClientServer, serverKexInit.CiphersClientServer)
+ stoc, ctos := &result.w, &result.r
+ if isClient {
+ ctos, stoc = stoc, ctos
+ }
+
+ ctos.Cipher, err = findCommon("client to server cipher", clientKexInit.CiphersClientServer, serverKexInit.CiphersClientServer)
if err != nil {
return
}
- result.r.Cipher, err = findCommon("server to client cipher", clientKexInit.CiphersServerClient, serverKexInit.CiphersServerClient)
+ stoc.Cipher, err = findCommon("server to client cipher", clientKexInit.CiphersServerClient, serverKexInit.CiphersServerClient)
if err != nil {
return
}
- result.w.MAC, err = findCommon("client to server MAC", clientKexInit.MACsClientServer, serverKexInit.MACsClientServer)
+ ctos.MAC, err = findCommon("client to server MAC", clientKexInit.MACsClientServer, serverKexInit.MACsClientServer)
if err != nil {
return
}
- result.r.MAC, err = findCommon("server to client MAC", clientKexInit.MACsServerClient, serverKexInit.MACsServerClient)
+ stoc.MAC, err = findCommon("server to client MAC", clientKexInit.MACsServerClient, serverKexInit.MACsServerClient)
if err != nil {
return
}
- result.w.Compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer)
+ ctos.Compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer)
if err != nil {
return
}
- result.r.Compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient)
+ stoc.Compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient)
if err != nil {
return
}
diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go
index 4f7912ec..2b10b05a 100644
--- a/vendor/golang.org/x/crypto/ssh/handshake.go
+++ b/vendor/golang.org/x/crypto/ssh/handshake.go
@@ -543,7 +543,8 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
clientInit := otherInit
serverInit := t.sentInitMsg
- if len(t.hostKeys) == 0 {
+ isClient := len(t.hostKeys) == 0
+ if isClient {
clientInit, serverInit = serverInit, clientInit
magics.clientKexInit = t.sentInitPacket
@@ -551,7 +552,7 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
}
var err error
- t.algorithms, err = findAgreedAlgorithms(clientInit, serverInit)
+ t.algorithms, err = findAgreedAlgorithms(isClient, clientInit, serverInit)
if err != nil {
return err
}
diff --git a/vendor/golang.org/x/crypto/ssh/messages.go b/vendor/golang.org/x/crypto/ssh/messages.go
index 08d28117..db914d80 100644
--- a/vendor/golang.org/x/crypto/ssh/messages.go
+++ b/vendor/golang.org/x/crypto/ssh/messages.go
@@ -275,6 +275,42 @@ type userAuthPubKeyOkMsg struct {
PubKey []byte
}
+// See RFC 4462, section 3
+const msgUserAuthGSSAPIResponse = 60
+
+type userAuthGSSAPIResponse struct {
+ SupportMech []byte `sshtype:"60"`
+}
+
+const msgUserAuthGSSAPIToken = 61
+
+type userAuthGSSAPIToken struct {
+ Token []byte `sshtype:"61"`
+}
+
+const msgUserAuthGSSAPIMIC = 66
+
+type userAuthGSSAPIMIC struct {
+ MIC []byte `sshtype:"66"`
+}
+
+// See RFC 4462, section 3.9
+const msgUserAuthGSSAPIErrTok = 64
+
+type userAuthGSSAPIErrTok struct {
+ ErrorToken []byte `sshtype:"64"`
+}
+
+// See RFC 4462, section 3.8
+const msgUserAuthGSSAPIError = 65
+
+type userAuthGSSAPIError struct {
+ MajorStatus uint32 `sshtype:"65"`
+ MinorStatus uint32
+ Message string
+ LanguageTag string
+}
+
// typeTags returns the possible type bytes for the given reflect.Type, which
// should be a struct. The possible values are separated by a '|' character.
func typeTags(structType reflect.Type) (tags []byte) {
@@ -756,6 +792,14 @@ func decode(packet []byte) (interface{}, error) {
msg = new(channelRequestSuccessMsg)
case msgChannelFailure:
msg = new(channelRequestFailureMsg)
+ case msgUserAuthGSSAPIToken:
+ msg = new(userAuthGSSAPIToken)
+ case msgUserAuthGSSAPIMIC:
+ msg = new(userAuthGSSAPIMIC)
+ case msgUserAuthGSSAPIErrTok:
+ msg = new(userAuthGSSAPIErrTok)
+ case msgUserAuthGSSAPIError:
+ msg = new(userAuthGSSAPIError)
default:
return nil, unexpectedMessageError(0, packet[0])
}
@@ -764,3 +808,29 @@ func decode(packet []byte) (interface{}, error) {
}
return msg, nil
}
+
+var packetTypeNames = map[byte]string{
+ msgDisconnect: "disconnectMsg",
+ msgServiceRequest: "serviceRequestMsg",
+ msgServiceAccept: "serviceAcceptMsg",
+ msgKexInit: "kexInitMsg",
+ msgKexDHInit: "kexDHInitMsg",
+ msgKexDHReply: "kexDHReplyMsg",
+ msgUserAuthRequest: "userAuthRequestMsg",
+ msgUserAuthSuccess: "userAuthSuccessMsg",
+ msgUserAuthFailure: "userAuthFailureMsg",
+ msgUserAuthPubKeyOk: "userAuthPubKeyOkMsg",
+ msgGlobalRequest: "globalRequestMsg",
+ msgRequestSuccess: "globalRequestSuccessMsg",
+ msgRequestFailure: "globalRequestFailureMsg",
+ msgChannelOpen: "channelOpenMsg",
+ msgChannelData: "channelDataMsg",
+ msgChannelOpenConfirm: "channelOpenConfirmMsg",
+ msgChannelOpenFailure: "channelOpenFailureMsg",
+ msgChannelWindowAdjust: "windowAdjustMsg",
+ msgChannelEOF: "channelEOFMsg",
+ msgChannelClose: "channelCloseMsg",
+ msgChannelRequest: "channelRequestMsg",
+ msgChannelSuccess: "channelRequestSuccessMsg",
+ msgChannelFailure: "channelRequestFailureMsg",
+}
diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go
index e86e8966..ac7f8073 100644
--- a/vendor/golang.org/x/crypto/ssh/server.go
+++ b/vendor/golang.org/x/crypto/ssh/server.go
@@ -45,6 +45,20 @@ type Permissions struct {
Extensions map[string]string
}
+type GSSAPIWithMICConfig struct {
+ // AllowLogin, must be set, is called when gssapi-with-mic
+ // authentication is selected (RFC 4462 section 3). The srcName is from the
+ // results of the GSS-API authentication. The format is username@DOMAIN.
+ // GSSAPI just guarantees to the server who the user is, but not if they can log in, and with what permissions.
+ // This callback is called after the user identity is established with GSSAPI to decide if the user can login with
+ // which permissions. If the user is allowed to login, it should return a nil error.
+ AllowLogin func(conn ConnMetadata, srcName string) (*Permissions, error)
+
+ // Server must be set. It's the implementation
+ // of the GSSAPIServer interface. See GSSAPIServer interface for details.
+ Server GSSAPIServer
+}
+
// ServerConfig holds server specific configuration data.
type ServerConfig struct {
// Config contains configuration shared between client and server.
@@ -99,6 +113,10 @@ type ServerConfig struct {
// BannerCallback, if present, is called and the return string is sent to
// the client after key exchange completed but before authentication.
BannerCallback func(conn ConnMetadata) string
+
+ // GSSAPIWithMICConfig includes gssapi server and callback, which if both non-nil, is used
+ // when gssapi-with-mic authentication is selected (RFC 4462 section 3).
+ GSSAPIWithMICConfig *GSSAPIWithMICConfig
}
// AddHostKey adds a private key as a host key. If an existing host
@@ -204,7 +222,9 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error)
return nil, errors.New("ssh: server has no host keys")
}
- if !config.NoClientAuth && config.PasswordCallback == nil && config.PublicKeyCallback == nil && config.KeyboardInteractiveCallback == nil {
+ if !config.NoClientAuth && config.PasswordCallback == nil && config.PublicKeyCallback == nil &&
+ config.KeyboardInteractiveCallback == nil && (config.GSSAPIWithMICConfig == nil ||
+ config.GSSAPIWithMICConfig.AllowLogin == nil || config.GSSAPIWithMICConfig.Server == nil) {
return nil, errors.New("ssh: no authentication methods configured but NoClientAuth is also false")
}
@@ -295,6 +315,55 @@ func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
return fmt.Errorf("ssh: remote address %v is not allowed because of source-address restriction", addr)
}
+func gssExchangeToken(gssapiConfig *GSSAPIWithMICConfig, firstToken []byte, s *connection,
+ sessionID []byte, userAuthReq userAuthRequestMsg) (authErr error, perms *Permissions, err error) {
+ gssAPIServer := gssapiConfig.Server
+ defer gssAPIServer.DeleteSecContext()
+ var srcName string
+ for {
+ var (
+ outToken []byte
+ needContinue bool
+ )
+ outToken, srcName, needContinue, err = gssAPIServer.AcceptSecContext(firstToken)
+ if err != nil {
+ return err, nil, nil
+ }
+ if len(outToken) != 0 {
+ if err := s.transport.writePacket(Marshal(&userAuthGSSAPIToken{
+ Token: outToken,
+ })); err != nil {
+ return nil, nil, err
+ }
+ }
+ if !needContinue {
+ break
+ }
+ packet, err := s.transport.readPacket()
+ if err != nil {
+ return nil, nil, err
+ }
+ userAuthGSSAPITokenReq := &userAuthGSSAPIToken{}
+ if err := Unmarshal(packet, userAuthGSSAPITokenReq); err != nil {
+ return nil, nil, err
+ }
+ }
+ packet, err := s.transport.readPacket()
+ if err != nil {
+ return nil, nil, err
+ }
+ userAuthGSSAPIMICReq := &userAuthGSSAPIMIC{}
+ if err := Unmarshal(packet, userAuthGSSAPIMICReq); err != nil {
+ return nil, nil, err
+ }
+ mic := buildMIC(string(sessionID), userAuthReq.User, userAuthReq.Service, userAuthReq.Method)
+ if err := gssAPIServer.VerifyMIC(mic, userAuthGSSAPIMICReq.MIC); err != nil {
+ return err, nil, nil
+ }
+ perms, authErr = gssapiConfig.AllowLogin(s, srcName)
+ return authErr, perms, nil
+}
+
// ServerAuthError represents server authentication errors and is
// sometimes returned by NewServerConn. It appends any authentication
// errors that may occur, and is returned if all of the authentication
@@ -496,6 +565,49 @@ userAuthLoop:
authErr = candidate.result
perms = candidate.perms
}
+ case "gssapi-with-mic":
+ gssapiConfig := config.GSSAPIWithMICConfig
+ userAuthRequestGSSAPI, err := parseGSSAPIPayload(userAuthReq.Payload)
+ if err != nil {
+ return nil, parseError(msgUserAuthRequest)
+ }
+ // OpenSSH supports Kerberos V5 mechanism only for GSS-API authentication.
+ if userAuthRequestGSSAPI.N == 0 {
+ authErr = fmt.Errorf("ssh: Mechanism negotiation is not supported")
+ break
+ }
+ var i uint32
+ present := false
+ for i = 0; i < userAuthRequestGSSAPI.N; i++ {
+ if userAuthRequestGSSAPI.OIDS[i].Equal(krb5Mesh) {
+ present = true
+ break
+ }
+ }
+ if !present {
+ authErr = fmt.Errorf("ssh: GSSAPI authentication must use the Kerberos V5 mechanism")
+ break
+ }
+ // Initial server response, see RFC 4462 section 3.3.
+ if err := s.transport.writePacket(Marshal(&userAuthGSSAPIResponse{
+ SupportMech: krb5OID,
+ })); err != nil {
+ return nil, err
+ }
+ // Exchange token, see RFC 4462 section 3.4.
+ packet, err := s.transport.readPacket()
+ if err != nil {
+ return nil, err
+ }
+ userAuthGSSAPITokenReq := &userAuthGSSAPIToken{}
+ if err := Unmarshal(packet, userAuthGSSAPITokenReq); err != nil {
+ return nil, err
+ }
+ authErr, perms, err = gssExchangeToken(gssapiConfig, userAuthGSSAPITokenReq.Token, s, sessionID,
+ userAuthReq)
+ if err != nil {
+ return nil, err
+ }
default:
authErr = fmt.Errorf("ssh: unknown method %q", userAuthReq.Method)
}
@@ -522,6 +634,10 @@ userAuthLoop:
if config.KeyboardInteractiveCallback != nil {
failureMsg.Methods = append(failureMsg.Methods, "keyboard-interactive")
}
+ if config.GSSAPIWithMICConfig != nil && config.GSSAPIWithMICConfig.Server != nil &&
+ config.GSSAPIWithMICConfig.AllowLogin != nil {
+ failureMsg.Methods = append(failureMsg.Methods, "gssapi-with-mic")
+ }
if len(failureMsg.Methods) == 0 {
return nil, errors.New("ssh: no authentication methods configured but NoClientAuth is also false")
diff --git a/vendor/golang.org/x/crypto/ssh/ssh_gss.go b/vendor/golang.org/x/crypto/ssh/ssh_gss.go
new file mode 100644
index 00000000..24bd7c8e
--- /dev/null
+++ b/vendor/golang.org/x/crypto/ssh/ssh_gss.go
@@ -0,0 +1,139 @@
+// Copyright 2011 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 ssh
+
+import (
+ "encoding/asn1"
+ "errors"
+)
+
+var krb5OID []byte
+
+func init() {
+ krb5OID, _ = asn1.Marshal(krb5Mesh)
+}
+
+// GSSAPIClient provides the API to plug-in GSSAPI authentication for client logins.
+type GSSAPIClient interface {
+ // InitSecContext initiates the establishment of a security context for GSS-API between the
+ // ssh client and ssh server. Initially the token parameter should be specified as nil.
+ // The routine may return a outputToken which should be transferred to
+ // the ssh server, where the ssh server will present it to
+ // AcceptSecContext. If no token need be sent, InitSecContext will indicate this by setting
+ // needContinue to false. To complete the context
+ // establishment, one or more reply tokens may be required from the ssh
+ // server;if so, InitSecContext will return a needContinue which is true.
+ // In this case, InitSecContext should be called again when the
+ // reply token is received from the ssh server, passing the reply
+ // token to InitSecContext via the token parameters.
+ // See RFC 2743 section 2.2.1 and RFC 4462 section 3.4.
+ InitSecContext(target string, token []byte, isGSSDelegCreds bool) (outputToken []byte, needContinue bool, err error)
+ // GetMIC generates a cryptographic MIC for the SSH2 message, and places
+ // the MIC in a token for transfer to the ssh server.
+ // The contents of the MIC field are obtained by calling GSS_GetMIC()
+ // over the following, using the GSS-API context that was just
+ // established:
+ // string session identifier
+ // byte SSH_MSG_USERAUTH_REQUEST
+ // string user name
+ // string service
+ // string "gssapi-with-mic"
+ // See RFC 2743 section 2.3.1 and RFC 4462 3.5.
+ GetMIC(micFiled []byte) ([]byte, error)
+ // Whenever possible, it should be possible for
+ // DeleteSecContext() calls to be successfully processed even
+ // if other calls cannot succeed, thereby enabling context-related
+ // resources to be released.
+ // In addition to deleting established security contexts,
+ // gss_delete_sec_context must also be able to delete "half-built"
+ // security contexts resulting from an incomplete sequence of
+ // InitSecContext()/AcceptSecContext() calls.
+ // See RFC 2743 section 2.2.3.
+ DeleteSecContext() error
+}
+
+// GSSAPIServer provides the API to plug in GSSAPI authentication for server logins.
+type GSSAPIServer interface {
+ // AcceptSecContext allows a remotely initiated security context between the application
+ // and a remote peer to be established by the ssh client. The routine may return a
+ // outputToken which should be transferred to the ssh client,
+ // where the ssh client will present it to InitSecContext.
+ // If no token need be sent, AcceptSecContext will indicate this
+ // by setting the needContinue to false. To
+ // complete the context establishment, one or more reply tokens may be
+ // required from the ssh client. if so, AcceptSecContext
+ // will return a needContinue which is true, in which case it
+ // should be called again when the reply token is received from the ssh
+ // client, passing the token to AcceptSecContext via the
+ // token parameters.
+ // The srcName return value is the authenticated username.
+ // See RFC 2743 section 2.2.2 and RFC 4462 section 3.4.
+ AcceptSecContext(token []byte) (outputToken []byte, srcName string, needContinue bool, err error)
+ // VerifyMIC verifies that a cryptographic MIC, contained in the token parameter,
+ // fits the supplied message is received from the ssh client.
+ // See RFC 2743 section 2.3.2.
+ VerifyMIC(micField []byte, micToken []byte) error
+ // Whenever possible, it should be possible for
+ // DeleteSecContext() calls to be successfully processed even
+ // if other calls cannot succeed, thereby enabling context-related
+ // resources to be released.
+ // In addition to deleting established security contexts,
+ // gss_delete_sec_context must also be able to delete "half-built"
+ // security contexts resulting from an incomplete sequence of
+ // InitSecContext()/AcceptSecContext() calls.
+ // See RFC 2743 section 2.2.3.
+ DeleteSecContext() error
+}
+
+var (
+ // OpenSSH supports Kerberos V5 mechanism only for GSS-API authentication,
+ // so we also support the krb5 mechanism only.
+ // See RFC 1964 section 1.
+ krb5Mesh = asn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2}
+)
+
+// The GSS-API authentication method is initiated when the client sends an SSH_MSG_USERAUTH_REQUEST
+// See RFC 4462 section 3.2.
+type userAuthRequestGSSAPI struct {
+ N uint32
+ OIDS []asn1.ObjectIdentifier
+}
+
+func parseGSSAPIPayload(payload []byte) (*userAuthRequestGSSAPI, error) {
+ n, rest, ok := parseUint32(payload)
+ if !ok {
+ return nil, errors.New("parse uint32 failed")
+ }
+ s := &userAuthRequestGSSAPI{
+ N: n,
+ OIDS: make([]asn1.ObjectIdentifier, n),
+ }
+ for i := 0; i < int(n); i++ {
+ var (
+ desiredMech []byte
+ err error
+ )
+ desiredMech, rest, ok = parseString(rest)
+ if !ok {
+ return nil, errors.New("parse string failed")
+ }
+ if rest, err = asn1.Unmarshal(desiredMech, &s.OIDS[i]); err != nil {
+ return nil, err
+ }
+
+ }
+ return s, nil
+}
+
+// See RFC 4462 section 3.6.
+func buildMIC(sessionID string, username string, service string, authMethod string) []byte {
+ out := make([]byte, 0, 0)
+ out = appendString(out, sessionID)
+ out = append(out, msgUserAuthRequest)
+ out = appendString(out, username)
+ out = appendString(out, service)
+ out = appendString(out, authMethod)
+ return out
+}
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
index 9d666ffc..2f04ee5b 100644
--- a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
+++ b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
@@ -7,6 +7,7 @@ package terminal
import (
"bytes"
"io"
+ "strconv"
"sync"
"unicode/utf8"
)
@@ -271,34 +272,44 @@ func (t *Terminal) moveCursorToPos(pos int) {
}
func (t *Terminal) move(up, down, left, right int) {
- movement := make([]rune, 3*(up+down+left+right))
- m := movement
- for i := 0; i < up; i++ {
- m[0] = keyEscape
- m[1] = '['
- m[2] = 'A'
- m = m[3:]
- }
- for i := 0; i < down; i++ {
- m[0] = keyEscape
- m[1] = '['
- m[2] = 'B'
- m = m[3:]
- }
- for i := 0; i < left; i++ {
- m[0] = keyEscape
- m[1] = '['
- m[2] = 'D'
- m = m[3:]
- }
- for i := 0; i < right; i++ {
- m[0] = keyEscape
- m[1] = '['
- m[2] = 'C'
- m = m[3:]
- }
-
- t.queue(movement)
+ m := []rune{}
+
+ // 1 unit up can be expressed as ^[[A or ^[A
+ // 5 units up can be expressed as ^[[5A
+
+ if up == 1 {
+ m = append(m, keyEscape, '[', 'A')
+ } else if up > 1 {
+ m = append(m, keyEscape, '[')
+ m = append(m, []rune(strconv.Itoa(up))...)
+ m = append(m, 'A')
+ }
+
+ if down == 1 {
+ m = append(m, keyEscape, '[', 'B')
+ } else if down > 1 {
+ m = append(m, keyEscape, '[')
+ m = append(m, []rune(strconv.Itoa(down))...)
+ m = append(m, 'B')
+ }
+
+ if right == 1 {
+ m = append(m, keyEscape, '[', 'C')
+ } else if right > 1 {
+ m = append(m, keyEscape, '[')
+ m = append(m, []rune(strconv.Itoa(right))...)
+ m = append(m, 'C')
+ }
+
+ if left == 1 {
+ m = append(m, keyEscape, '[', 'D')
+ } else if left > 1 {
+ m = append(m, keyEscape, '[')
+ m = append(m, []rune(strconv.Itoa(left))...)
+ m = append(m, 'D')
+ }
+
+ t.queue(m)
}
func (t *Terminal) clearLineToRight() {
diff --git a/vendor/golang.org/x/crypto/ssh/transport.go b/vendor/golang.org/x/crypto/ssh/transport.go
index f6fae1db..49ddc2e7 100644
--- a/vendor/golang.org/x/crypto/ssh/transport.go
+++ b/vendor/golang.org/x/crypto/ssh/transport.go
@@ -53,14 +53,14 @@ type transport struct {
// packetCipher represents a combination of SSH encryption/MAC
// protocol. A single instance should be used for one direction only.
type packetCipher interface {
- // writePacket encrypts the packet and writes it to w. The
+ // writeCipherPacket encrypts the packet and writes it to w. The
// contents of the packet are generally scrambled.
- writePacket(seqnum uint32, w io.Writer, rand io.Reader, packet []byte) error
+ writeCipherPacket(seqnum uint32, w io.Writer, rand io.Reader, packet []byte) error
- // readPacket reads and decrypts a packet of data. The
+ // readCipherPacket reads and decrypts a packet of data. The
// returned packet may be overwritten by future calls of
// readPacket.
- readPacket(seqnum uint32, r io.Reader) ([]byte, error)
+ readCipherPacket(seqnum uint32, r io.Reader) ([]byte, error)
}
// connectionState represents one side (read or write) of the
@@ -127,7 +127,7 @@ func (t *transport) readPacket() (p []byte, err error) {
}
func (s *connectionState) readPacket(r *bufio.Reader) ([]byte, error) {
- packet, err := s.packetCipher.readPacket(s.seqNum, r)
+ packet, err := s.packetCipher.readCipherPacket(s.seqNum, r)
s.seqNum++
if err == nil && len(packet) == 0 {
err = errors.New("ssh: zero length packet")
@@ -175,7 +175,7 @@ func (t *transport) writePacket(packet []byte) error {
func (s *connectionState) writePacket(w *bufio.Writer, rand io.Reader, packet []byte) error {
changeKeys := len(packet) > 0 && packet[0] == msgNewKeys
- err := s.packetCipher.writePacket(s.seqNum, w, rand, packet)
+ err := s.packetCipher.writeCipherPacket(s.seqNum, w, rand, packet)
if err != nil {
return err
}