Fixed bad curve ecdsa curve bug.

This commit is contained in:
Stephen Fox 2019-02-04 14:25:37 -05:00
parent 9328c9f9e0
commit d465231e63
2 changed files with 30 additions and 2 deletions

View File

@ -128,9 +128,9 @@ func (o *defaultKeyPairBuilder) newEcdsaKeyPair() (KeyPair, error) {
case 521:
curve = elliptic.P521()
case 384:
elliptic.P384()
curve = elliptic.P384()
case 256:
elliptic.P256()
curve = elliptic.P256()
case 224:
// Not supported by "golang.org/x/crypto/ssh".
return &defaultKeyPair{}, errors.New("golang.org/x/crypto/ssh does not support " +

View File

@ -176,6 +176,34 @@ func TestDefaultKeyPairBuilder_Build_EcdsaDefault(t *testing.T) {
}
}
func TestDefaultKeyPairBuilder_Build_EcdsaSupportedCurves(t *testing.T) {
supportedBits := []int{
521,
384,
256,
}
for _, bits := range supportedBits {
kp, err := NewKeyPairBuilder().
SetType(Ecdsa).
SetBits(bits).
Build()
if err != nil {
t.Fatal(err.Error())
}
err = expected{
kind: Ecdsa,
bits: bits,
desc: "ecdsa " + strconv.Itoa(bits),
data: []byte(uuid.TimeOrderedUUID()),
}.matches(kp)
if err != nil {
t.Fatal(err.Error())
}
}
}
func TestDefaultKeyPairBuilder_Build_RsaDefault(t *testing.T) {
kp, err := NewKeyPairBuilder().
SetType(Rsa).