Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Oliver committed May 29, 2023
1 parent 8b69f5b commit da690a8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ func tryReadPrivateKey(key []byte) (*rsa.PrivateKey, error) {
func tryParsePKCS8(key []byte) (*rsa.PrivateKey, error) {
if parsed, err := x509.ParsePKCS8PrivateKey(key); err != nil {
return nil, ErrMalformedPrivateKey
} else if parsed, ok := parsed.(*rsa.PrivateKey); !ok {
} else if parsedRSA, ok := parsed.(*rsa.PrivateKey); !ok {
return nil, ErrUnsupportedPrivateKey // e.g. ecdsa.PrivateKey
} else {
return parsed, nil
return parsedRSA, nil
}
}

Expand All @@ -125,6 +125,8 @@ func (this *PrivateKey) Sign(raw []byte) ([]byte, error) {
return rsa.SignPKCS1v15(this.random, this.inner, crypto.SHA256, sum[:])
}

var ErrMalformedPrivateKey = errors.New("malformed private key")
var ErrUnsupportedPrivateKey = errors.New("unsupported private key type")
var ErrMalformedJSON = errors.New("malformed JSON")
var (
ErrMalformedPrivateKey = errors.New("malformed private key")
ErrUnsupportedPrivateKey = errors.New("unsupported private key type")
ErrMalformedJSON = errors.New("malformed JSON")
)

0 comments on commit da690a8

Please sign in to comment.