go.crypto/ssh: remove misleading marshalPrivRSA.

Properly capitalize publicKey throughout.

R=golang-dev
CC=agl, dave, golang-dev, jpsugar
https://golang.org/cl/13415046
This commit is contained in:
Han-Wen Nienhuys
2013-09-05 11:36:51 -04:00
committed by Adam Langley
parent 58b09dec0e
commit f17d130281
7 changed files with 13 additions and 28 deletions
+1 -1
View File
@@ -206,7 +206,7 @@ func (ac *AgentClient) RequestIdentities() ([]*AgentKey, error) {
// 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,
})
+1 -1
View File
@@ -160,7 +160,7 @@ func marshalOpenSSHCertV01(cert *OpenSSHCertV01) []byte {
panic("ssh: unknown public key type in cert")
}
sigKey := serializePublickey(cert.SignatureKey)
sigKey := serializePublicKey(cert.SignatureKey)
length := stringLength(len(cert.Nonce))
length += len(pubKey)
+3 -3
View File
@@ -214,7 +214,7 @@ func (p *publickeyAuth) auth(session []byte, user string, t *transport, rand io.
// 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 @@ func (p *publickeyAuth) auth(session []byte, user string, t *transport, rand io.
// 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) validateKey(key interface{}, user string, t *transport)
}
func (p *publickeyAuth) confirmKeyAck(key interface{}, t *transport) (bool, error) {
pubkey := serializePublickey(key)
pubkey := serializePublicKey(key)
algoname := algoName(key)
for {
+3 -3
View File
@@ -135,7 +135,7 @@ var (
},
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 @@ func newMockAuthServer(t *testing.T) string {
return l.Addr().String()
}
func TestClientAuthPublickey(t *testing.T) {
func TestClientAuthPublicKey(t *testing.T) {
config := &ClientConfig{
User: "testuser",
Auth: []ClientAuth{
@@ -283,7 +283,7 @@ func TestClientAuthWrongKeyboardInteractive(t *testing.T) {
}
// 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{
+2 -2
View File
@@ -248,7 +248,7 @@ func serializeSignature(algoname string, sig []byte) []byte {
}
// 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 @@ func algoName(key interface{}) string {
}
}
}
panic("unexpected key type")
panic(fmt.Sprintf("unexpected key type %T", key))
}
// buildDataSignedForAuth returns the data that is signed in order to prove
+2 -17
View File
@@ -125,21 +125,6 @@ func parseECDSA(in []byte) (out *ecdsa.PublicKey, rest []byte, ok bool) {
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 @@ func MarshalAuthorizedKey(key interface{}) []byte {
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 @@ func MarshalAuthorizedKey(key interface{}) []byte {
// 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)
}
+1 -1
View File
@@ -82,7 +82,7 @@ func (s *ServerConfig) SetRSAPrivateKey(pemBytes []byte) error {
return err
}
s.rsaSerialized = marshalPrivRSA(s.rsa)
s.rsaSerialized = serializePublicKey(&s.rsa.PublicKey)
return nil
}