summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-01-28 22:57:53 +0100
committerGitHub <noreply@github.com>2023-01-28 22:57:53 +0100
commit880586bac42817ffcfea5d9f746f503fa29915b8 (patch)
treea89374cba6f88975f12316ec8d1b8aa1d4c6ba79 /vendor/golang.org/x/crypto
parenteac2a8c8dc831f946970d327e2a80b26b0684255 (diff)
downloadmatterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.gz
matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.bz2
matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.zip
Update dependencies (#1951)
Diffstat (limited to 'vendor/golang.org/x/crypto')
-rw-r--r--vendor/golang.org/x/crypto/bcrypt/bcrypt.go2
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go66
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go66
-rw-r--r--vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go66
-rw-r--r--vendor/golang.org/x/crypto/ssh/common.go15
-rw-r--r--vendor/golang.org/x/crypto/ssh/handshake.go21
-rw-r--r--vendor/golang.org/x/crypto/ssh/messages.go2
-rw-r--r--vendor/golang.org/x/crypto/ssh/server.go13
8 files changed, 141 insertions, 110 deletions
diff --git a/vendor/golang.org/x/crypto/bcrypt/bcrypt.go b/vendor/golang.org/x/crypto/bcrypt/bcrypt.go
index aeb73f81..addf56b4 100644
--- a/vendor/golang.org/x/crypto/bcrypt/bcrypt.go
+++ b/vendor/golang.org/x/crypto/bcrypt/bcrypt.go
@@ -50,7 +50,7 @@ func (ih InvalidHashPrefixError) Error() string {
type InvalidCostError int
func (ic InvalidCostError) Error() string {
- return fmt.Sprintf("crypto/bcrypt: cost %d is outside allowed range (%d,%d)", int(ic), int(MinCost), int(MaxCost))
+ return fmt.Sprintf("crypto/bcrypt: cost %d is outside allowed range (%d,%d)", int(ic), MinCost, MaxCost)
}
const (
diff --git a/vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go b/vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go
index 4c96147c..3fd05b27 100644
--- a/vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go
@@ -5,6 +5,8 @@
// Package salsa provides low-level access to functions in the Salsa family.
package salsa // import "golang.org/x/crypto/salsa20/salsa"
+import "math/bits"
+
// Sigma is the Salsa20 constant for 256-bit keys.
var Sigma = [16]byte{'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k'}
@@ -31,76 +33,76 @@ func HSalsa20(out *[32]byte, in *[16]byte, k *[32]byte, c *[16]byte) {
for i := 0; i < 20; i += 2 {
u := x0 + x12
- x4 ^= u<<7 | u>>(32-7)
+ x4 ^= bits.RotateLeft32(u, 7)
u = x4 + x0
- x8 ^= u<<9 | u>>(32-9)
+ x8 ^= bits.RotateLeft32(u, 9)
u = x8 + x4
- x12 ^= u<<13 | u>>(32-13)
+ x12 ^= bits.RotateLeft32(u, 13)
u = x12 + x8
- x0 ^= u<<18 | u>>(32-18)
+ x0 ^= bits.RotateLeft32(u, 18)
u = x5 + x1
- x9 ^= u<<7 | u>>(32-7)
+ x9 ^= bits.RotateLeft32(u, 7)
u = x9 + x5
- x13 ^= u<<9 | u>>(32-9)
+ x13 ^= bits.RotateLeft32(u, 9)
u = x13 + x9
- x1 ^= u<<13 | u>>(32-13)
+ x1 ^= bits.RotateLeft32(u, 13)
u = x1 + x13
- x5 ^= u<<18 | u>>(32-18)
+ x5 ^= bits.RotateLeft32(u, 18)
u = x10 + x6
- x14 ^= u<<7 | u>>(32-7)
+ x14 ^= bits.RotateLeft32(u, 7)
u = x14 + x10
- x2 ^= u<<9 | u>>(32-9)
+ x2 ^= bits.RotateLeft32(u, 9)
u = x2 + x14
- x6 ^= u<<13 | u>>(32-13)
+ x6 ^= bits.RotateLeft32(u, 13)
u = x6 + x2
- x10 ^= u<<18 | u>>(32-18)
+ x10 ^= bits.RotateLeft32(u, 18)
u = x15 + x11
- x3 ^= u<<7 | u>>(32-7)
+ x3 ^= bits.RotateLeft32(u, 7)
u = x3 + x15
- x7 ^= u<<9 | u>>(32-9)
+ x7 ^= bits.RotateLeft32(u, 9)
u = x7 + x3
- x11 ^= u<<13 | u>>(32-13)
+ x11 ^= bits.RotateLeft32(u, 13)
u = x11 + x7
- x15 ^= u<<18 | u>>(32-18)
+ x15 ^= bits.RotateLeft32(u, 18)
u = x0 + x3
- x1 ^= u<<7 | u>>(32-7)
+ x1 ^= bits.RotateLeft32(u, 7)
u = x1 + x0
- x2 ^= u<<9 | u>>(32-9)
+ x2 ^= bits.RotateLeft32(u, 9)
u = x2 + x1
- x3 ^= u<<13 | u>>(32-13)
+ x3 ^= bits.RotateLeft32(u, 13)
u = x3 + x2
- x0 ^= u<<18 | u>>(32-18)
+ x0 ^= bits.RotateLeft32(u, 18)
u = x5 + x4
- x6 ^= u<<7 | u>>(32-7)
+ x6 ^= bits.RotateLeft32(u, 7)
u = x6 + x5
- x7 ^= u<<9 | u>>(32-9)
+ x7 ^= bits.RotateLeft32(u, 9)
u = x7 + x6
- x4 ^= u<<13 | u>>(32-13)
+ x4 ^= bits.RotateLeft32(u, 13)
u = x4 + x7
- x5 ^= u<<18 | u>>(32-18)
+ x5 ^= bits.RotateLeft32(u, 18)
u = x10 + x9
- x11 ^= u<<7 | u>>(32-7)
+ x11 ^= bits.RotateLeft32(u, 7)
u = x11 + x10
- x8 ^= u<<9 | u>>(32-9)
+ x8 ^= bits.RotateLeft32(u, 9)
u = x8 + x11
- x9 ^= u<<13 | u>>(32-13)
+ x9 ^= bits.RotateLeft32(u, 13)
u = x9 + x8
- x10 ^= u<<18 | u>>(32-18)
+ x10 ^= bits.RotateLeft32(u, 18)
u = x15 + x14
- x12 ^= u<<7 | u>>(32-7)
+ x12 ^= bits.RotateLeft32(u, 7)
u = x12 + x15
- x13 ^= u<<9 | u>>(32-9)
+ x13 ^= bits.RotateLeft32(u, 9)
u = x13 + x12
- x14 ^= u<<13 | u>>(32-13)
+ x14 ^= bits.RotateLeft32(u, 13)
u = x14 + x13
- x15 ^= u<<18 | u>>(32-18)
+ x15 ^= bits.RotateLeft32(u, 18)
}
out[0] = byte(x0)
out[1] = byte(x0 >> 8)
diff --git a/vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go b/vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go
index 9bfc0927..7ec7bb39 100644
--- a/vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go
@@ -4,6 +4,8 @@
package salsa
+import "math/bits"
+
// Core208 applies the Salsa20/8 core function to the 64-byte array in and puts
// the result into the 64-byte array out. The input and output may be the same array.
func Core208(out *[64]byte, in *[64]byte) {
@@ -29,76 +31,76 @@ func Core208(out *[64]byte, in *[64]byte) {
for i := 0; i < 8; i += 2 {
u := x0 + x12
- x4 ^= u<<7 | u>>(32-7)
+ x4 ^= bits.RotateLeft32(u, 7)
u = x4 + x0
- x8 ^= u<<9 | u>>(32-9)
+ x8 ^= bits.RotateLeft32(u, 9)
u = x8 + x4
- x12 ^= u<<13 | u>>(32-13)
+ x12 ^= bits.RotateLeft32(u, 13)
u = x12 + x8
- x0 ^= u<<18 | u>>(32-18)
+ x0 ^= bits.RotateLeft32(u, 18)
u = x5 + x1
- x9 ^= u<<7 | u>>(32-7)
+ x9 ^= bits.RotateLeft32(u, 7)
u = x9 + x5
- x13 ^= u<<9 | u>>(32-9)
+ x13 ^= bits.RotateLeft32(u, 9)
u = x13 + x9
- x1 ^= u<<13 | u>>(32-13)
+ x1 ^= bits.RotateLeft32(u, 13)
u = x1 + x13
- x5 ^= u<<18 | u>>(32-18)
+ x5 ^= bits.RotateLeft32(u, 18)
u = x10 + x6
- x14 ^= u<<7 | u>>(32-7)
+ x14 ^= bits.RotateLeft32(u, 7)
u = x14 + x10
- x2 ^= u<<9 | u>>(32-9)
+ x2 ^= bits.RotateLeft32(u, 9)
u = x2 + x14
- x6 ^= u<<13 | u>>(32-13)
+ x6 ^= bits.RotateLeft32(u, 13)
u = x6 + x2
- x10 ^= u<<18 | u>>(32-18)
+ x10 ^= bits.RotateLeft32(u, 18)
u = x15 + x11
- x3 ^= u<<7 | u>>(32-7)
+ x3 ^= bits.RotateLeft32(u, 7)
u = x3 + x15
- x7 ^= u<<9 | u>>(32-9)
+ x7 ^= bits.RotateLeft32(u, 9)
u = x7 + x3
- x11 ^= u<<13 | u>>(32-13)
+ x11 ^= bits.RotateLeft32(u, 13)
u = x11 + x7
- x15 ^= u<<18 | u>>(32-18)
+ x15 ^= bits.RotateLeft32(u, 18)
u = x0 + x3
- x1 ^= u<<7 | u>>(32-7)
+ x1 ^= bits.RotateLeft32(u, 7)
u = x1 + x0
- x2 ^= u<<9 | u>>(32-9)
+ x2 ^= bits.RotateLeft32(u, 9)
u = x2 + x1
- x3 ^= u<<13 | u>>(32-13)
+ x3 ^= bits.RotateLeft32(u, 13)
u = x3 + x2
- x0 ^= u<<18 | u>>(32-18)
+ x0 ^= bits.RotateLeft32(u, 18)
u = x5 + x4
- x6 ^= u<<7 | u>>(32-7)
+ x6 ^= bits.RotateLeft32(u, 7)
u = x6 + x5
- x7 ^= u<<9 | u>>(32-9)
+ x7 ^= bits.RotateLeft32(u, 9)
u = x7 + x6
- x4 ^= u<<13 | u>>(32-13)
+ x4 ^= bits.RotateLeft32(u, 13)
u = x4 + x7
- x5 ^= u<<18 | u>>(32-18)
+ x5 ^= bits.RotateLeft32(u, 18)
u = x10 + x9
- x11 ^= u<<7 | u>>(32-7)
+ x11 ^= bits.RotateLeft32(u, 7)
u = x11 + x10
- x8 ^= u<<9 | u>>(32-9)
+ x8 ^= bits.RotateLeft32(u, 9)
u = x8 + x11
- x9 ^= u<<13 | u>>(32-13)
+ x9 ^= bits.RotateLeft32(u, 13)
u = x9 + x8
- x10 ^= u<<18 | u>>(32-18)
+ x10 ^= bits.RotateLeft32(u, 18)
u = x15 + x14
- x12 ^= u<<7 | u>>(32-7)
+ x12 ^= bits.RotateLeft32(u, 7)
u = x12 + x15
- x13 ^= u<<9 | u>>(32-9)
+ x13 ^= bits.RotateLeft32(u, 9)
u = x13 + x12
- x14 ^= u<<13 | u>>(32-13)
+ x14 ^= bits.RotateLeft32(u, 13)
u = x14 + x13
- x15 ^= u<<18 | u>>(32-18)
+ x15 ^= bits.RotateLeft32(u, 18)
}
x0 += j0
x1 += j1
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 68169c6d..e5cdb9a2 100644
--- a/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
+++ b/vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go
@@ -4,6 +4,8 @@
package salsa
+import "math/bits"
+
const rounds = 20
// core applies the Salsa20 core function to 16-byte input in, 32-byte key k,
@@ -31,76 +33,76 @@ func core(out *[64]byte, in *[16]byte, k *[32]byte, c *[16]byte) {
for i := 0; i < rounds; i += 2 {
u := x0 + x12
- x4 ^= u<<7 | u>>(32-7)
+ x4 ^= bits.RotateLeft32(u, 7)
u = x4 + x0
- x8 ^= u<<9 | u>>(32-9)
+ x8 ^= bits.RotateLeft32(u, 9)
u = x8 + x4
- x12 ^= u<<13 | u>>(32-13)
+ x12 ^= bits.RotateLeft32(u, 13)
u = x12 + x8
- x0 ^= u<<18 | u>>(32-18)
+ x0 ^= bits.RotateLeft32(u, 18)
u = x5 + x1
- x9 ^= u<<7 | u>>(32-7)
+ x9 ^= bits.RotateLeft32(u, 7)
u = x9 + x5
- x13 ^= u<<9 | u>>(32-9)
+ x13 ^= bits.RotateLeft32(u, 9)
u = x13 + x9
- x1 ^= u<<13 | u>>(32-13)
+ x1 ^= bits.RotateLeft32(u, 13)
u = x1 + x13
- x5 ^= u<<18 | u>>(32-18)
+ x5 ^= bits.RotateLeft32(u, 18)
u = x10 + x6
- x14 ^= u<<7 | u>>(32-7)
+ x14 ^= bits.RotateLeft32(u, 7)
u = x14 + x10
- x2 ^= u<<9 | u>>(32-9)
+ x2 ^= bits.RotateLeft32(u, 9)
u = x2 + x14
- x6 ^= u<<13 | u>>(32-13)
+ x6 ^= bits.RotateLeft32(u, 13)
u = x6 + x2
- x10 ^= u<<18 | u>>(32-18)
+ x10 ^= bits.RotateLeft32(u, 18)
u = x15 + x11
- x3 ^= u<<7 | u>>(32-7)
+ x3 ^= bits.RotateLeft32(u, 7)
u = x3 + x15
- x7 ^= u<<9 | u>>(32-9)
+ x7 ^= bits.RotateLeft32(u, 9)
u = x7 + x3
- x11 ^= u<<13 | u>>(32-13)
+ x11 ^= bits.RotateLeft32(u, 13)
u = x11 + x7
- x15 ^= u<<18 | u>>(32-18)
+ x15 ^= bits.RotateLeft32(u, 18)
u = x0 + x3
- x1 ^= u<<7 | u>>(32-7)
+ x1 ^= bits.RotateLeft32(u, 7)
u = x1 + x0
- x2 ^= u<<9 | u>>(32-9)
+ x2 ^= bits.RotateLeft32(u, 9)
u = x2 + x1
- x3 ^= u<<13 | u>>(32-13)
+ x3 ^= bits.RotateLeft32(u, 13)
u = x3 + x2
- x0 ^= u<<18 | u>>(32-18)
+ x0 ^= bits.RotateLeft32(u, 18)
u = x5 + x4
- x6 ^= u<<7 | u>>(32-7)
+ x6 ^= bits.RotateLeft32(u, 7)
u = x6 + x5
- x7 ^= u<<9 | u>>(32-9)
+ x7 ^= bits.RotateLeft32(u, 9)
u = x7 + x6
- x4 ^= u<<13 | u>>(32-13)
+ x4 ^= bits.RotateLeft32(u, 13)
u = x4 + x7
- x5 ^= u<<18 | u>>(32-18)
+ x5 ^= bits.RotateLeft32(u, 18)
u = x10 + x9
- x11 ^= u<<7 | u>>(32-7)
+ x11 ^= bits.RotateLeft32(u, 7)
u = x11 + x10
- x8 ^= u<<9 | u>>(32-9)
+ x8 ^= bits.RotateLeft32(u, 9)
u = x8 + x11
- x9 ^= u<<13 | u>>(32-13)
+ x9 ^= bits.RotateLeft32(u, 13)
u = x9 + x8
- x10 ^= u<<18 | u>>(32-18)
+ x10 ^= bits.RotateLeft32(u, 18)
u = x15 + x14
- x12 ^= u<<7 | u>>(32-7)
+ x12 ^= bits.RotateLeft32(u, 7)
u = x12 + x15
- x13 ^= u<<9 | u>>(32-9)
+ x13 ^= bits.RotateLeft32(u, 9)
u = x13 + x12
- x14 ^= u<<13 | u>>(32-13)
+ x14 ^= bits.RotateLeft32(u, 13)
u = x14 + x13
- x15 ^= u<<18 | u>>(32-18)
+ x15 ^= bits.RotateLeft32(u, 18)
}
x0 += j0
x1 += j1
diff --git a/vendor/golang.org/x/crypto/ssh/common.go b/vendor/golang.org/x/crypto/ssh/common.go
index 7a5ff2d2..c7964275 100644
--- a/vendor/golang.org/x/crypto/ssh/common.go
+++ b/vendor/golang.org/x/crypto/ssh/common.go
@@ -10,6 +10,7 @@ import (
"fmt"
"io"
"math"
+ "strings"
"sync"
_ "crypto/sha1"
@@ -118,6 +119,20 @@ func algorithmsForKeyFormat(keyFormat string) []string {
}
}
+// supportedPubKeyAuthAlgos specifies the supported client public key
+// authentication algorithms. Note that this doesn't include certificate types
+// since those use the underlying algorithm. This list is sent to the client if
+// it supports the server-sig-algs extension. Order is irrelevant.
+var supportedPubKeyAuthAlgos = []string{
+ KeyAlgoED25519,
+ KeyAlgoSKED25519, KeyAlgoSKECDSA256,
+ KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
+ KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoRSA,
+ KeyAlgoDSA,
+}
+
+var supportedPubKeyAuthAlgosList = strings.Join(supportedPubKeyAuthAlgos, ",")
+
// unexpectedMessageError results when the SSH message that we received didn't
// match what we wanted.
func unexpectedMessageError(expected, got uint8) error {
diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go
index 653dc4d2..2b84c357 100644
--- a/vendor/golang.org/x/crypto/ssh/handshake.go
+++ b/vendor/golang.org/x/crypto/ssh/handshake.go
@@ -615,7 +615,8 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
return err
}
- if t.sessionID == nil {
+ firstKeyExchange := t.sessionID == nil
+ if firstKeyExchange {
t.sessionID = result.H
}
result.SessionID = t.sessionID
@@ -626,6 +627,24 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
if err = t.conn.writePacket([]byte{msgNewKeys}); err != nil {
return err
}
+
+ // On the server side, after the first SSH_MSG_NEWKEYS, send a SSH_MSG_EXT_INFO
+ // message with the server-sig-algs extension if the client supports it. See
+ // RFC 8308, Sections 2.4 and 3.1.
+ if !isClient && firstKeyExchange && contains(clientInit.KexAlgos, "ext-info-c") {
+ extInfo := &extInfoMsg{
+ NumExtensions: 1,
+ Payload: make([]byte, 0, 4+15+4+len(supportedPubKeyAuthAlgosList)),
+ }
+ extInfo.Payload = appendInt(extInfo.Payload, len("server-sig-algs"))
+ extInfo.Payload = append(extInfo.Payload, "server-sig-algs"...)
+ extInfo.Payload = appendInt(extInfo.Payload, len(supportedPubKeyAuthAlgosList))
+ extInfo.Payload = append(extInfo.Payload, supportedPubKeyAuthAlgosList...)
+ if err := t.conn.writePacket(Marshal(extInfo)); err != nil {
+ return err
+ }
+ }
+
if packet, err := t.conn.readPacket(); err != nil {
return err
} else if packet[0] != msgNewKeys {
diff --git a/vendor/golang.org/x/crypto/ssh/messages.go b/vendor/golang.org/x/crypto/ssh/messages.go
index 19bc67c4..922032d9 100644
--- a/vendor/golang.org/x/crypto/ssh/messages.go
+++ b/vendor/golang.org/x/crypto/ssh/messages.go
@@ -68,7 +68,7 @@ type kexInitMsg struct {
// See RFC 4253, section 8.
-// Diffie-Helman
+// Diffie-Hellman
const msgKexDHInit = 30
type kexDHInitMsg struct {
diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go
index 2260b20a..9e387029 100644
--- a/vendor/golang.org/x/crypto/ssh/server.go
+++ b/vendor/golang.org/x/crypto/ssh/server.go
@@ -291,15 +291,6 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error)
return perms, err
}
-func isAcceptableAlgo(algo string) bool {
- switch algo {
- case KeyAlgoRSA, KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoDSA, KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521, KeyAlgoSKECDSA256, KeyAlgoED25519, KeyAlgoSKED25519,
- CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01:
- return true
- }
- return false
-}
-
func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
if addr == nil {
return errors.New("ssh: no address known for client, but source-address match required")
@@ -514,7 +505,7 @@ userAuthLoop:
return nil, parseError(msgUserAuthRequest)
}
algo := string(algoBytes)
- if !isAcceptableAlgo(algo) {
+ if !contains(supportedPubKeyAuthAlgos, underlyingAlgo(algo)) {
authErr = fmt.Errorf("ssh: algorithm %q not accepted", algo)
break
}
@@ -572,7 +563,7 @@ userAuthLoop:
// algorithm name that corresponds to algo with
// sig.Format. This is usually the same, but
// for certs, the names differ.
- if !isAcceptableAlgo(sig.Format) {
+ if !contains(supportedPubKeyAuthAlgos, sig.Format) {
authErr = fmt.Errorf("ssh: algorithm %q not accepted", sig.Format)
break
}