| 1 | package ecdsascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/ |
| 2 | |
| 3 | import ( |
| 4 | "crypto/ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 6 | "syncscip-go gomod github.com/golang/go/src go1.24.0 sync/" |
| 7 | |
| 8 | "github.com/lestrrat-go/jwx/v3/jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/" |
| 9 | ) |
| 10 | |
| 11 | var muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves. syncscip-go gomod github.com/golang/go/src go1.24.0 sync/.RWMutexscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex# |
| 12 | var algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap. map[jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#]ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve# |
| 13 | var curveToAlgMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/curveToAlgMap. map[ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve#]jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm# |
| 14 | var algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList. []jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm# |
| 15 | |
| 16 | func initscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/init().() { |
| 17 | muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves..Lockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#Lock().() |
| 18 | algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap. = make(map[jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#]ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve#) |
| 19 | curveToAlgMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/curveToAlgMap. = make(map[ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve#]jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#) |
| 20 | muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves..Unlockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#Unlock().() |
| 21 | } |
| 22 | |
| 23 | // RegisterCurve registers a jwa.EllipticCurveAlgorithm constant and its |
| 24 | // corresponding elliptic.Curve object. Users do not need to call this unless |
| 25 | // they are registering a new ECDSA key type |
| 26 | func RegisterCurvescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/RegisterCurve().(alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#, crv ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve#) { |
| 27 | muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves..Lockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#Lock().() |
| 28 | defer muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves..Unlockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#Unlock().() |
| 29 | |
| 30 | algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap.[alg] = crv |
| 31 | curveToAlgMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/curveToAlgMap.[crv] = alg |
| 32 | rebuildCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/rebuildCurves().() |
| 33 | } |
| 34 | |
| 35 | func rebuildCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/rebuildCurves().() { |
| 36 | l := len(algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap.) |
| 37 | if cap(algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList.) < l { |
| 38 | algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList. = make([]jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#, 0, l) |
| 39 | } else { |
| 40 | algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList. = algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList.[:0] |
| 41 | } |
| 42 | |
| 43 | for alg := range algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap. { |
| 44 | algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList. = append(algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList., alg) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // Algorithms returns the list of registered jwa.EllipticCurveAlgorithms |
| 49 | // that ca be used for ECDSA keys. |
| 50 | func Algorithmsscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/Algorithms().() []jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm# { |
| 51 | muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves..RLockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#RLock().() |
| 52 | defer muCurvesscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/muCurves..RUnlockscip-go gomod github.com/golang/go/src go1.24.0 sync/RWMutex#RUnlock().() |
| 53 | |
| 54 | return algListscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algList. |
| 55 | } |
| 56 | |
| 57 | func AlgorithmFromCurvescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/AlgorithmFromCurve().(crv ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve#) (jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#, error) { |
| 58 | alg, ok := curveToAlgMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/curveToAlgMap.[crv] |
| 59 | if !ok { |
| 60 | return jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.InvalidEllipticCurvescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/InvalidEllipticCurve().(), fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`unknown elliptic curve: %q`, crv) |
| 61 | } |
| 62 | return alg, nil |
| 63 | } |
| 64 | |
| 65 | func CurveFromAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/CurveFromAlgorithm().(alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#) (ellipticscip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/.Curvescip-go gomod github.com/golang/go/src go1.24.0 `crypto/elliptic`/Curve#, error) { |
| 66 | crv, ok := algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap.[alg] |
| 67 | if !ok { |
| 68 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().(`unknown elliptic curve algorithm: %q`, alg) |
| 69 | } |
| 70 | return crv, nil |
| 71 | } |
| 72 | |
| 73 | func IsCurveAvailablescip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/IsCurveAvailable().(alg jwascip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/.EllipticCurveAlgorithmscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwa`/EllipticCurveAlgorithm#) bool { |
| 74 | _, ok := algToCurveMapscip-go gomod github.com/lestrrat-go/jwx/v3 . `github.com/lestrrat-go/jwx/v3/jwk/ecdsa`/algToCurveMap.[alg] |
| 75 | return ok |
| 76 | } |