go.crypto/ssh: remove misleading marshalPrivRSA.
Properly capitalize publicKey throughout.
R=golang-dev
CC=agl, dave, golang-dev, jpsugar
https://golang.org/cl/13415046
diff --git a/ssh/agent.go b/ssh/agent.go
index 34d084c..5d2175d 100644
--- a/ssh/agent.go
+++ b/ssh/agent.go
@@ -206,7 +206,7 @@
// as defined in [PROTOCOL.agent] section 2.6.2.
func (ac *AgentClient) SignRequest(key interface{}, data []byte) ([]byte, error) {
req := marshal(agentSignRequest, signRequestAgentMsg{
- KeyBlob: serializePublickey(key),
+ KeyBlob: serializePublicKey(key),
Data: data,
})
diff --git a/ssh/certs.go b/ssh/certs.go
index 82c120e..0094b3d 100644
--- a/ssh/certs.go
+++ b/ssh/certs.go
@@ -160,7 +160,7 @@
panic("ssh: unknown public key type in cert")
}
- sigKey := serializePublickey(cert.SignatureKey)
+ sigKey := serializePublicKey(cert.SignatureKey)
length := stringLength(len(cert.Nonce))
length += len(pubKey)
diff --git a/ssh/client_auth.go b/ssh/client_auth.go
index 5301d49..abdb24a 100644
--- a/ssh/client_auth.go
+++ b/ssh/client_auth.go
@@ -214,7 +214,7 @@
// methods that may continue if this auth is not successful.
var methods []string
for i, key := range validKeys {
- pubkey := serializePublickey(key)
+ pubkey := serializePublicKey(key)
algoname := algoName(key)
sign, err := p.Sign(i, rand, buildDataSignedForAuth(session, userAuthRequestMsg{
User: user,
@@ -254,7 +254,7 @@
// validateKey validates the key provided it is acceptable to the server.
func (p *publickeyAuth) validateKey(key interface{}, user string, t *transport) (bool, error) {
- pubkey := serializePublickey(key)
+ pubkey := serializePublicKey(key)
algoname := algoName(key)
msg := publickeyAuthMsg{
User: user,
@@ -272,7 +272,7 @@
}
func (p *publickeyAuth) confirmKeyAck(key interface{}, t *transport) (bool, error) {
- pubkey := serializePublickey(key)
+ pubkey := serializePublicKey(key)
algoname := algoName(key)
for {
diff --git a/ssh/client_auth_test.go b/ssh/client_auth_test.go
index ff64ad7..ba11949 100644
--- a/ssh/client_auth_test.go
+++ b/ssh/client_auth_test.go
@@ -135,7 +135,7 @@
},
PublicKeyCallback: func(conn *ServerConn, user, algo string, pubkey []byte) bool {
key := &clientKeychain.keys[0].(*rsa.PrivateKey).PublicKey
- expected := []byte(serializePublickey(key))
+ expected := []byte(serializePublicKey(key))
algoname := algoName(key)
return user == "testuser" && algo == algoname && bytes.Equal(pubkey, expected)
},
@@ -198,7 +198,7 @@
return l.Addr().String()
}
-func TestClientAuthPublickey(t *testing.T) {
+func TestClientAuthPublicKey(t *testing.T) {
config := &ClientConfig{
User: "testuser",
Auth: []ClientAuth{
@@ -283,7 +283,7 @@
}
// the mock server will only authenticate ssh-rsa keys
-func TestClientAuthInvalidPublickey(t *testing.T) {
+func TestClientAuthInvalidPublicKey(t *testing.T) {
kc := new(keychain)
kc.keys = append(kc.keys, dsakey)
config := &ClientConfig{
diff --git a/ssh/common.go b/ssh/common.go
index bbbb00e..3df556d 100644
--- a/ssh/common.go
+++ b/ssh/common.go
@@ -248,7 +248,7 @@
}
// serialize a *rsa.PublicKey or *dsa.PublicKey according to RFC 4253 6.6.
-func serializePublickey(key interface{}) []byte {
+func serializePublicKey(key interface{}) []byte {
var pubKeyBytes []byte
algoname := algoName(key)
switch key := key.(type) {
@@ -304,7 +304,7 @@
}
}
}
- panic("unexpected key type")
+ panic(fmt.Sprintf("unexpected key type %T", key))
}
// buildDataSignedForAuth returns the data that is signed in order to prove
diff --git a/ssh/keys.go b/ssh/keys.go
index d1b1c79..1dd6856 100644
--- a/ssh/keys.go
+++ b/ssh/keys.go
@@ -125,21 +125,6 @@
return key, in, ok
}
-// marshalPrivRSA serializes an RSA private key according to RFC 4253, section 6.6.
-func marshalPrivRSA(priv *rsa.PrivateKey) []byte {
- e := new(big.Int).SetInt64(int64(priv.E))
- length := stringLength(len(KeyAlgoRSA))
- length += intLength(e)
- length += intLength(priv.N)
-
- ret := make([]byte, length)
- r := marshalString(ret, []byte(KeyAlgoRSA))
- r = marshalInt(r, e)
- r = marshalInt(r, priv.N)
-
- return ret
-}
-
// marshalPubRSA serializes an RSA public key according to RFC 4253, section 6.6.
func marshalPubRSA(key *rsa.PublicKey) []byte {
e := new(big.Int).SetInt64(int64(key.E))
@@ -334,7 +319,7 @@
b.WriteString(algoName(key))
b.WriteByte(' ')
e := base64.NewEncoder(base64.StdEncoding, b)
- e.Write(serializePublickey(key))
+ e.Write(serializePublicKey(key))
e.Close()
b.WriteByte('\n')
return b.Bytes()
@@ -345,5 +330,5 @@
// of ServerConfig's PublicKeyCallback as well as for generating an
// authorized_keys or host_keys file.
func MarshalPublicKey(key interface{}) []byte {
- return serializePublickey(key)
+ return serializePublicKey(key)
}
diff --git a/ssh/server.go b/ssh/server.go
index 434932c..c172a09 100644
--- a/ssh/server.go
+++ b/ssh/server.go
@@ -82,7 +82,7 @@
return err
}
- s.rsaSerialized = marshalPrivRSA(s.rsa)
+ s.rsaSerialized = serializePublicKey(&s.rsa.PublicKey)
return nil
}