ssh: use *rsa.PublicKey or *dsa.PublicKey in interfaces.
Everywhere else in the code base, when we have an interface{} which is
a stand in for a public key, we use *foo.PublicKey rather than
foo.PublicKey. This change makes ssh reflect that.
R=dave, r
CC=golang-dev
https://golang.org/cl/5686067
This commit is contained in:
+1
-2
@@ -135,7 +135,7 @@ func ClientAuthPassword(impl ClientPassword) ClientAuth {
|
||||
|
||||
// ClientKeyring implements access to a client key ring.
|
||||
type ClientKeyring interface {
|
||||
// Key returns the i'th rsa.Publickey or dsa.Publickey, or nil if
|
||||
// Key returns the i'th *rsa.Publickey or *dsa.Publickey, or nil if
|
||||
// no key exists at i.
|
||||
Key(i int) (key interface{}, err error)
|
||||
|
||||
@@ -163,7 +163,6 @@ type publickeyAuthMsg struct {
|
||||
}
|
||||
|
||||
func (p *publickeyAuth) auth(session []byte, user string, t *transport, rand io.Reader) (bool, []string, error) {
|
||||
|
||||
// Authentication is performed in two stages. The first stage sends an
|
||||
// enquiry to test if each key is acceptable to the remote. The second
|
||||
// stage attempts to authenticate with the valid keys obtained in the
|
||||
|
||||
@@ -69,9 +69,9 @@ func (k *keychain) Key(i int) (interface{}, error) {
|
||||
}
|
||||
switch key := k.keys[i].(type) {
|
||||
case *rsa.PrivateKey:
|
||||
return key.PublicKey, nil
|
||||
return &key.PublicKey, nil
|
||||
case *dsa.PrivateKey:
|
||||
return key.PublicKey, nil
|
||||
return &key.PublicKey, nil
|
||||
}
|
||||
panic("unknown key type")
|
||||
}
|
||||
@@ -123,7 +123,7 @@ var (
|
||||
return user == "testuser" && pass == string(clientPassword)
|
||||
},
|
||||
PublicKeyCallback: func(conn *ServerConn, user, algo string, pubkey []byte) bool {
|
||||
key := clientKeychain.keys[0].(*rsa.PrivateKey).PublicKey
|
||||
key := &clientKeychain.keys[0].(*rsa.PrivateKey).PublicKey
|
||||
expected := []byte(serializePublickey(key))
|
||||
algoname := algoName(key)
|
||||
return user == "testuser" && algo == algoname && bytes.Equal(pubkey, expected)
|
||||
|
||||
+5
-5
@@ -154,11 +154,11 @@ func serializeSignature(algoname string, sig []byte) []byte {
|
||||
return ret
|
||||
}
|
||||
|
||||
// serialize an rsa.PublicKey or dsa.PublicKey according to RFC 4253 6.6.
|
||||
// serialize a *rsa.PublicKey or *dsa.PublicKey according to RFC 4253 6.6.
|
||||
func serializePublickey(key interface{}) []byte {
|
||||
algoname := algoName(key)
|
||||
switch key := key.(type) {
|
||||
case rsa.PublicKey:
|
||||
case *rsa.PublicKey:
|
||||
e := new(big.Int).SetInt64(int64(key.E))
|
||||
length := stringLength([]byte(algoname))
|
||||
length += intLength(e)
|
||||
@@ -168,7 +168,7 @@ func serializePublickey(key interface{}) []byte {
|
||||
r = marshalInt(r, e)
|
||||
marshalInt(r, key.N)
|
||||
return ret
|
||||
case dsa.PublicKey:
|
||||
case *dsa.PublicKey:
|
||||
length := stringLength([]byte(algoname))
|
||||
length += intLength(key.P)
|
||||
length += intLength(key.Q)
|
||||
@@ -187,9 +187,9 @@ func serializePublickey(key interface{}) []byte {
|
||||
|
||||
func algoName(key interface{}) string {
|
||||
switch key.(type) {
|
||||
case rsa.PublicKey:
|
||||
case *rsa.PublicKey:
|
||||
return "ssh-rsa"
|
||||
case dsa.PublicKey:
|
||||
case *dsa.PublicKey:
|
||||
return "ssh-dss"
|
||||
}
|
||||
panic("unexpected key type")
|
||||
|
||||
Reference in New Issue
Block a user