@@ -581,10 +581,10 @@ func fromEcPublicKey(pub *ecdsa.PublicKey) (*rawJSONWebKey, error) {
581581
582582func (key rawJSONWebKey ) edPrivateKey () (ed25519.PrivateKey , error ) {
583583 var missing []string
584- switch {
585- case key .D == nil :
584+ if key .D == nil {
586585 missing = append (missing , "D" )
587- case key .X == nil :
586+ }
587+ if key .X == nil {
588588 missing = append (missing , "X" )
589589 }
590590
@@ -611,19 +611,21 @@ func (key rawJSONWebKey) edPublicKey() (ed25519.PublicKey, error) {
611611
612612func (key rawJSONWebKey ) rsaPrivateKey () (* rsa.PrivateKey , error ) {
613613 var missing []string
614- switch {
615- case key .N == nil :
614+ if key .N == nil {
616615 missing = append (missing , "N" )
617- case key .E == nil :
616+ }
617+ if key .E == nil {
618618 missing = append (missing , "E" )
619- case key .D == nil :
619+ }
620+ if key .D == nil {
620621 missing = append (missing , "D" )
621- case key .P == nil :
622+ }
623+ if key .P == nil {
622624 missing = append (missing , "P" )
623- case key .Q == nil :
625+ }
626+ if key .Q == nil {
624627 missing = append (missing , "Q" )
625628 }
626-
627629 if len (missing ) > 0 {
628630 return nil , fmt .Errorf ("go-jose/go-jose: invalid RSA private key, missing %s value(s)" , strings .Join (missing , ", " ))
629631 }
@@ -698,8 +700,19 @@ func (key rawJSONWebKey) ecPrivateKey() (*ecdsa.PrivateKey, error) {
698700 return nil , fmt .Errorf ("go-jose/go-jose: unsupported elliptic curve '%s'" , key .Crv )
699701 }
700702
701- if key .X == nil || key .Y == nil || key .D == nil {
702- return nil , fmt .Errorf ("go-jose/go-jose: invalid EC private key, missing x/y/d values" )
703+ var missing []string
704+ if key .X == nil {
705+ missing = append (missing , "X" )
706+ }
707+ if key .Y == nil {
708+ missing = append (missing , "Y" )
709+ }
710+ if key .D == nil {
711+ missing = append (missing , "D" )
712+ }
713+
714+ if len (missing ) > 0 {
715+ return nil , fmt .Errorf ("go-jose/go-jose: invalid EC private key, missing %s value(s)" , strings .Join (missing , ", " ))
703716 }
704717
705718 // The length of this octet string MUST be the full size of a coordinate for
0 commit comments