Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8929309228 | ||
|
|
4a75ba54c2 | ||
|
|
b4f1988a35 |
+1
-1
@@ -288,7 +288,7 @@ type Directory struct {
|
|||||||
// KeyChangeURL allows to perform account key rollover flow.
|
// KeyChangeURL allows to perform account key rollover flow.
|
||||||
KeyChangeURL string
|
KeyChangeURL string
|
||||||
|
|
||||||
// Term is a URI identifying the current terms of service.
|
// Terms is a URI identifying the current terms of service.
|
||||||
Terms string
|
Terms string
|
||||||
|
|
||||||
// Website is an HTTP or HTTPS URL locating a website
|
// Website is an HTTP or HTTPS URL locating a website
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ go 1.20
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
golang.org/x/net v0.21.0 // tagx:ignore
|
golang.org/x/net v0.21.0 // tagx:ignore
|
||||||
golang.org/x/sys v0.28.0
|
golang.org/x/sys v0.29.0
|
||||||
golang.org/x/term v0.27.0
|
golang.org/x/term v0.28.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/text v0.21.0 // indirect
|
require golang.org/x/text v0.21.0 // indirect
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ type pbeCipher interface {
|
|||||||
create(key []byte) (cipher.Block, error)
|
create(key []byte) (cipher.Block, error)
|
||||||
// deriveKey returns a key derived from the given password and salt.
|
// deriveKey returns a key derived from the given password and salt.
|
||||||
deriveKey(salt, password []byte, iterations int) []byte
|
deriveKey(salt, password []byte, iterations int) []byte
|
||||||
// deriveKey returns an IV derived from the given password and salt.
|
// deriveIV returns an IV derived from the given password and salt.
|
||||||
deriveIV(salt, password []byte, iterations int) []byte
|
deriveIV(salt, password []byte, iterations int) []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func tryAuth(t *testing.T, config *ClientConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryAuth runs a handshake with a given config against an SSH server
|
// tryAuthWithGSSAPIWithMICConfig runs a handshake with a given config against an SSH server
|
||||||
// with a given GSSAPIWithMICConfig and config serverConfig. Returns both client and server side errors.
|
// with a given GSSAPIWithMICConfig and config serverConfig. Returns both client and server side errors.
|
||||||
func tryAuthWithGSSAPIWithMICConfig(t *testing.T, clientConfig *ClientConfig, gssAPIWithMICConfig *GSSAPIWithMICConfig) error {
|
func tryAuthWithGSSAPIWithMICConfig(t *testing.T, clientConfig *ClientConfig, gssAPIWithMICConfig *GSSAPIWithMICConfig) error {
|
||||||
err, _ := tryAuthBothSides(t, clientConfig, gssAPIWithMICConfig)
|
err, _ := tryAuthBothSides(t, clientConfig, gssAPIWithMICConfig)
|
||||||
|
|||||||
+11
-4
@@ -149,7 +149,7 @@ func (s *ServerConfig) AddHostKey(key Signer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cachedPubKey contains the results of querying whether a public key is
|
// cachedPubKey contains the results of querying whether a public key is
|
||||||
// acceptable for a user.
|
// acceptable for a user. This is a FIFO cache.
|
||||||
type cachedPubKey struct {
|
type cachedPubKey struct {
|
||||||
user string
|
user string
|
||||||
pubKeyData []byte
|
pubKeyData []byte
|
||||||
@@ -157,7 +157,13 @@ type cachedPubKey struct {
|
|||||||
perms *Permissions
|
perms *Permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxCachedPubKeys = 16
|
// maxCachedPubKeys is the number of cache entries we store.
|
||||||
|
//
|
||||||
|
// Due to consistent misuse of the PublicKeyCallback API, we have reduced this
|
||||||
|
// to 1, such that the only key in the cache is the most recently seen one. This
|
||||||
|
// forces the behavior that the last call to PublicKeyCallback will always be
|
||||||
|
// with the key that is used for authentication.
|
||||||
|
const maxCachedPubKeys = 1
|
||||||
|
|
||||||
// pubKeyCache caches tests for public keys. Since SSH clients
|
// pubKeyCache caches tests for public keys. Since SSH clients
|
||||||
// will query whether a public key is acceptable before attempting to
|
// will query whether a public key is acceptable before attempting to
|
||||||
@@ -179,9 +185,10 @@ func (c *pubKeyCache) get(user string, pubKeyData []byte) (cachedPubKey, bool) {
|
|||||||
|
|
||||||
// add adds the given tuple to the cache.
|
// add adds the given tuple to the cache.
|
||||||
func (c *pubKeyCache) add(candidate cachedPubKey) {
|
func (c *pubKeyCache) add(candidate cachedPubKey) {
|
||||||
if len(c.keys) < maxCachedPubKeys {
|
if len(c.keys) >= maxCachedPubKeys {
|
||||||
c.keys = append(c.keys, candidate)
|
c.keys = c.keys[1:]
|
||||||
}
|
}
|
||||||
|
c.keys = append(c.keys, candidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerConn is an authenticated SSH connection, as seen from the
|
// ServerConn is an authenticated SSH connection, as seen from the
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -299,6 +300,54 @@ func TestBannerError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPublicKeyCallbackLastSeen(t *testing.T) {
|
||||||
|
var lastSeenKey PublicKey
|
||||||
|
|
||||||
|
c1, c2, err := netPipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("netPipe: %v", err)
|
||||||
|
}
|
||||||
|
defer c1.Close()
|
||||||
|
defer c2.Close()
|
||||||
|
serverConf := &ServerConfig{
|
||||||
|
PublicKeyCallback: func(conn ConnMetadata, key PublicKey) (*Permissions, error) {
|
||||||
|
lastSeenKey = key
|
||||||
|
fmt.Printf("seen %#v\n", key)
|
||||||
|
if _, ok := key.(*dsaPublicKey); !ok {
|
||||||
|
return nil, errors.New("nope")
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
serverConf.AddHostKey(testSigners["ecdsap256"])
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(done)
|
||||||
|
NewServerConn(c1, serverConf)
|
||||||
|
}()
|
||||||
|
|
||||||
|
clientConf := ClientConfig{
|
||||||
|
User: "user",
|
||||||
|
Auth: []AuthMethod{
|
||||||
|
PublicKeys(testSigners["rsa"], testSigners["dsa"], testSigners["ed25519"]),
|
||||||
|
},
|
||||||
|
HostKeyCallback: InsecureIgnoreHostKey(),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, _, err = NewClientConn(c2, "", &clientConf)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
<-done
|
||||||
|
|
||||||
|
expectedPublicKey := testSigners["dsa"].PublicKey().Marshal()
|
||||||
|
lastSeenMarshalled := lastSeenKey.Marshal()
|
||||||
|
if !bytes.Equal(lastSeenMarshalled, expectedPublicKey) {
|
||||||
|
t.Errorf("unexpected key: got %#v, want %#v", lastSeenKey, testSigners["dsa"].PublicKey())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type markerConn struct {
|
type markerConn struct {
|
||||||
closed uint32
|
closed uint32
|
||||||
used uint32
|
used uint32
|
||||||
|
|||||||
Reference in New Issue
Block a user