Remove 'Ssh' suffix from 'KeyPairType' constants.

This commit is contained in:
Stephen Fox 2019-02-04 12:23:42 -05:00
parent c6ae8654d9
commit 7f6b307dd6
2 changed files with 20 additions and 20 deletions

View File

@ -19,15 +19,15 @@ const (
// That's a lot of bits.
defaultRsaBits = 4096
// RsaSsh is a SSH key pair of RSA type.
RsaSsh KeyPairType = "rsa"
// Rsa is a SSH key pair of RSA type.
Rsa KeyPairType = "rsa"
// EcdsaSsh is a SSH key pair of ECDSA type.
EcdsaSsh KeyPairType = "ecdsa"
// Ecdsa is a SSH key pair of ECDSA type.
Ecdsa KeyPairType = "ecdsa"
)
// KeyPairType represents different types of SSH key pairs.
// For example, RSA.
// See the 'const' block for details.
type KeyPairType string
func (o KeyPairType) String() string {
@ -108,9 +108,9 @@ func (o *defaultKeyPairBuilder) SetName(name string) KeyPairBuilder {
func (o *defaultKeyPairBuilder) Build() (KeyPair, error) {
switch o.kind {
case RsaSsh:
case Rsa:
return o.newRsaSshKeyPair()
case EcdsaSsh:
case Ecdsa:
// Default case.
}
@ -156,7 +156,7 @@ func (o *defaultKeyPairBuilder) newEcdsaSshKeyPair() (KeyPair, error) {
}
return &defaultKeyPair{
kind: EcdsaSsh,
kind: Ecdsa,
bits: o.bits,
name: o.name,
privateKeyDerBytes: raw,
@ -181,7 +181,7 @@ func (o *defaultKeyPairBuilder) newRsaSshKeyPair() (KeyPair, error) {
}
return &defaultKeyPair{
kind: RsaSsh,
kind: Rsa,
bits: o.bits,
name: o.name,
privateKeyDerBytes: x509.MarshalPKCS1PrivateKey(privateKey),
@ -254,9 +254,9 @@ func (o defaultKeyPair) PrivateKeyPemBlock() []byte {
t := "UNKNOWN PRIVATE KEY"
switch o.kind {
case EcdsaSsh:
case Ecdsa:
t = "EC PRIVATE KEY"
case RsaSsh:
case Rsa:
t = "RSA PRIVATE KEY"
}

View File

@ -147,7 +147,7 @@ func TestDefaultKeyPairBuilder_Build_Default(t *testing.T) {
}
err = expected{
kind: EcdsaSsh,
kind: Ecdsa,
bits: 521,
desc: "ecdsa 521",
data: []byte(uuid.TimeOrderedUUID()),
@ -159,14 +159,14 @@ func TestDefaultKeyPairBuilder_Build_Default(t *testing.T) {
func TestDefaultKeyPairBuilder_Build_EcdsaDefault(t *testing.T) {
kp, err := NewKeyPairBuilder().
SetType(EcdsaSsh).
SetType(Ecdsa).
Build()
if err != nil {
t.Fatal(err.Error())
}
err = expected{
kind: EcdsaSsh,
kind: Ecdsa,
bits: 521,
desc: "ecdsa 521",
data: []byte(uuid.TimeOrderedUUID()),
@ -178,14 +178,14 @@ func TestDefaultKeyPairBuilder_Build_EcdsaDefault(t *testing.T) {
func TestDefaultKeyPairBuilder_Build_RsaDefault(t *testing.T) {
kp, err := NewKeyPairBuilder().
SetType(RsaSsh).
SetType(Rsa).
Build()
if err != nil {
t.Fatal(err.Error())
}
err = expected{
kind: RsaSsh,
kind: Rsa,
bits: 4096,
desc: "rsa 4096",
data: []byte(uuid.TimeOrderedUUID()),
@ -199,7 +199,7 @@ func TestDefaultKeyPairBuilder_Build_NamedEcdsa(t *testing.T) {
name := uuid.TimeOrderedUUID()
kp, err := NewKeyPairBuilder().
SetType(EcdsaSsh).
SetType(Ecdsa).
SetName(name).
Build()
if err != nil {
@ -207,7 +207,7 @@ func TestDefaultKeyPairBuilder_Build_NamedEcdsa(t *testing.T) {
}
err = expected{
kind: EcdsaSsh,
kind: Ecdsa,
bits: 521,
desc: "ecdsa 521",
data: []byte(uuid.TimeOrderedUUID()),
@ -222,7 +222,7 @@ func TestDefaultKeyPairBuilder_Build_NamedRsa(t *testing.T) {
name := uuid.TimeOrderedUUID()
kp, err := NewKeyPairBuilder().
SetType(RsaSsh).
SetType(Rsa).
SetName(name).
Build()
if err != nil {
@ -230,7 +230,7 @@ func TestDefaultKeyPairBuilder_Build_NamedRsa(t *testing.T) {
}
err = expected{
kind: RsaSsh,
kind: Rsa,
bits: 4096,
desc: "rsa 4096",
data: []byte(uuid.TimeOrderedUUID()),