Documentation ¶
Overview ¶
On type wrangling in Go:
* Go doesn't allow "extension methods", ie we can't add methods to other package's types, so we can't add MarshalJSON to rsa.PublicKey * Hence, we alias those types and impl the marshal funcs on our aliases * Often you'll hold a variable typed as the crypto.[Public,Private]Key interface, and want to marshal that. * That iface doesn't include MarshalJSON, so again we wanna add it. * However we can't even alias the interface and do it that way, because you can't have iface receivers. * Hence, functions like these at the top that go from the stdlib iface to one of our concrete impls.
TODO
* - X test with istio demo master (move to containerimage) * - X rearrange to lib at top * - X to melange & apko; test * - X test all Just targets * - X tests stable * - X fix up test_keys dir * - X doc.go (explain the ortho of the funcs, eg to/from json vs to/from an [un]marshaler * - README.md * - api comments. Turn linting up to 11 * - X links in the readme like to godoc one * - X check gh action & its outputs * - X tag 0.2 (1.0?)
Index ¶
- func JWK2Key(j []byte) (any, error)
- func JWK2PEM(j []byte) ([]byte, error)
- func JWKS2Keys(j []byte) ([]any, error)
- func JWKS2KeysMap(j []byte) (map[string]any, error)
- func JWKS2PEM(j []byte) ([]byte, error)
- func Key2JWK(k any) (string, error)
- func KeyIsPrivate(key any) bool
- func KeyPublicPart(key any) crypto.PublicKey
- func Keys2JWKS(ks []any) (string, error)
- func Keys2PEM(ks []any) ([]byte, error)
- func PEM2JWK(p []byte) (string, error)
- func PEM2JWKS(p []byte) (string, error)
- func PEM2Keys(p []byte) ([]any, error)
- type JWK
- type JWKS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyIsPrivate ¶
func KeyPublicPart ¶
Types ¶
type JWK ¶
func Key2JWKMarshaler ¶
This does a bit more than the JWKS-version because - needs to check for JWK-unsupported key types. - does the public-part extraction. When we have generics we can do it at render time? No! If we want one type, that won't encode whether we should do it, so we need to do so here at ctor time.
- TODO factor out to inisial call
TODO: extra key types (wait for go 1.21; this API is being sorted apaz)