aboutsummaryrefslogtreecommitdiff
path: root/ssh/client_auth_test.go
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2013-09-13 14:25:14 -0400
committerAdam Langley <agl@golang.org>2013-09-13 14:25:14 -0400
commite62b2aead43494d8abe8c8be4cf9993beb379779 (patch)
tree2ebfc6dbd5c8f6c80439d5d308158fb278164f90 /ssh/client_auth_test.go
parent6a743c56c79964532cf81eb3e71013c7eaf286bc (diff)
downloadgo-x-crypto-e62b2aead43494d8abe8c8be4cf9993beb379779.tar.xz
go.crypto/ssh: introduce PublicKey interface type.
Public functions affected: -AgentKey.Key -AgentClient.SignRequest -ClientKeyring.Key -MarshalPublicKey -ParsePublicKey R=agl, jpsugar, jmpittman CC=golang-dev https://golang.org/cl/13642043
Diffstat (limited to 'ssh/client_auth_test.go')
-rw-r--r--ssh/client_auth_test.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/ssh/client_auth_test.go b/ssh/client_auth_test.go
index df6dbd6..4460b41 100644
--- a/ssh/client_auth_test.go
+++ b/ssh/client_auth_test.go
@@ -65,15 +65,15 @@ type keychain struct {
keys []interface{}
}
-func (k *keychain) Key(i int) (interface{}, error) {
+func (k *keychain) Key(i int) (PublicKey, error) {
if i < 0 || i >= len(k.keys) {
return nil, nil
}
switch key := k.keys[i].(type) {
case *rsa.PrivateKey:
- return &key.PublicKey, nil
+ return NewRSAPublicKey(&key.PublicKey), nil
case *dsa.PrivateKey:
- return &key.PublicKey, nil
+ return NewDSAPublicKey(&key.PublicKey), nil
}
panic("unknown key type")
}
@@ -135,9 +135,10 @@ var (
return user == "testuser" && pass == string(clientPassword)
},
PublicKeyCallback: func(conn *ServerConn, user, algo string, pubkey []byte) bool {
- key := &clientKeychain.keys[0].(*rsa.PrivateKey).PublicKey
- expected := []byte(serializePublicKey(key))
- algoname := algoName(key)
+ rsaKey := &clientKeychain.keys[0].(*rsa.PrivateKey).PublicKey
+ key := NewRSAPublicKey(rsaKey)
+ expected := MarshalPublicKey(key)
+ algoname := key.PublicKeyAlgo()
return user == "testuser" && algo == algoname && bytes.Equal(pubkey, expected)
},
KeyboardInteractiveCallback: func(conn *ServerConn, user string, client ClientKeyboardInteractive) bool {