go.crypto/ssh: some cleanup

Simplify MarshalAuthorizedKey by using the algoName func.
Make the algoName func be very specific about supported key types in openssh certs.
Generalize some of the commentary that previously mentioned specific key types.

R=agl, dave
CC=golang-dev
https://golang.org/cl/6938067
This commit is contained in:
Jonathan Pittman
2012-12-16 10:47:10 -05:00
committed by Adam Langley
parent 2da167fbbe
commit d95b28330d
5 changed files with 77 additions and 51 deletions
+15 -1
View File
@@ -255,7 +255,21 @@ func algoName(key interface{}) string {
return KeyAlgoECDSA521
}
case *OpenSSHCertV01:
return algoName(key.(*OpenSSHCertV01).Key) + "-cert-v01@openssh.com"
switch key.(*OpenSSHCertV01).Key.(type) {
case *rsa.PublicKey:
return CertAlgoRSAv01
case *dsa.PublicKey:
return CertAlgoDSAv01
case *ecdsa.PublicKey:
switch key.(*OpenSSHCertV01).Key.(*ecdsa.PublicKey).Params().BitSize {
case 256:
return CertAlgoECDSA256v01
case 384:
return CertAlgoECDSA384v01
case 521:
return CertAlgoECDSA521v01
}
}
}
panic("unexpected key type")
}