diff --git a/helpers/derhelpers/derhelpers-legacy.go b/helpers/derhelpers/derhelpers-legacy.go deleted file mode 100644 index a634a46eb..000000000 --- a/helpers/derhelpers/derhelpers-legacy.go +++ /dev/null @@ -1,50 +0,0 @@ -// +build !go1.13 - -// Package derhelpers implements common functionality -// on DER encoded data -package derhelpers - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rsa" - "crypto/x509" - - cferr "github.com/cloudflare/cfssl/errors" - "golang.org/x/crypto/ed25519" -) - -// ParsePrivateKeyDER parses a PKCS #1, PKCS #8, ECDSA, or Ed25519 DER-encoded -// private key. The key must not be in PEM format. -func ParsePrivateKeyDER(keyDER []byte) (key crypto.Signer, err error) { - generalKey, err := x509.ParsePKCS8PrivateKey(keyDER) - if err != nil { - generalKey, err = x509.ParsePKCS1PrivateKey(keyDER) - if err != nil { - generalKey, err = x509.ParseECPrivateKey(keyDER) - if err != nil { - generalKey, err = ParseEd25519PrivateKey(keyDER) - if err != nil { - // We don't include the actual error into - // the final error. The reason might be - // we don't want to leak any info about - // the private key. - return nil, cferr.New(cferr.PrivateKeyError, - cferr.ParseFailed) - } - } - } - } - - switch generalKey.(type) { - case *rsa.PrivateKey: - return generalKey.(*rsa.PrivateKey), nil - case *ecdsa.PrivateKey: - return generalKey.(*ecdsa.PrivateKey), nil - case ed25519.PrivateKey: - return generalKey.(ed25519.PrivateKey), nil - } - - // should never reach here - return nil, cferr.New(cferr.PrivateKeyError, cferr.ParseFailed) -} diff --git a/helpers/derhelpers/derhelpers.go b/helpers/derhelpers/derhelpers.go index 25bda27a5..561691be2 100644 --- a/helpers/derhelpers/derhelpers.go +++ b/helpers/derhelpers/derhelpers.go @@ -1,5 +1,3 @@ -// +build go1.13 - // Package derhelpers implements common functionality // on DER encoded data package derhelpers diff --git a/helpers/derhelpers/ed25519.go b/helpers/derhelpers/ed25519.go index eb669ce93..bf20dc206 100644 --- a/helpers/derhelpers/ed25519.go +++ b/helpers/derhelpers/ed25519.go @@ -2,11 +2,10 @@ package derhelpers import ( "crypto" + "crypto/ed25519" "crypto/x509/pkix" "encoding/asn1" "errors" - - "golang.org/x/crypto/ed25519" ) var errEd25519WrongID = errors.New("incorrect object identifier") diff --git a/helpers/derhelpers/ed25519_test.go b/helpers/derhelpers/ed25519_test.go index 629d12eef..4a639de59 100644 --- a/helpers/derhelpers/ed25519_test.go +++ b/helpers/derhelpers/ed25519_test.go @@ -2,10 +2,9 @@ package derhelpers import ( "bytes" + "crypto/ed25519" "encoding/pem" "testing" - - "golang.org/x/crypto/ed25519" ) var testPubKey = `-----BEGIN PUBLIC KEY-----