Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONWebKey ¶
type JSONWebKey struct { // Cryptographic key, can be a symmetric or asymmetric key. Key interface{} // Key identifier, parsed from `kid` header. KeyID string // Key algorithm, parsed from `alg` header. Algorithm string // Key use, parsed from `use` header. Use string // X.509 certificate chain, parsed from `x5c` header. Certificates []*x509.Certificate // X.509 certificate URL, parsed from `x5u` header. CertificatesURL *url.URL // X.509 certificate thumbprint (SHA-1), parsed from `x5t` header. CertificateThumbprintSHA1 []byte // X.509 certificate thumbprint (SHA-256), parsed from `x5t#S256` header. CertificateThumbprintSHA256 []byte }
JSONWebKey represents a public or private key in JWK format.
func (*JSONWebKey) IsPublic ¶
func (k *JSONWebKey) IsPublic() bool
IsPublic returns true if the JWK represents a public key (not symmetric, not private).
func (JSONWebKey) MarshalJSON ¶
func (k JSONWebKey) MarshalJSON() ([]byte, error)
MarshalJSON serializes the given key to its JSON representation.
func (*JSONWebKey) Public ¶
func (k *JSONWebKey) Public() JSONWebKey
Public creates JSONWebKey with corresponding public key if JWK represents asymmetric private key.
func (*JSONWebKey) Thumbprint ¶
func (k *JSONWebKey) Thumbprint(hash crypto.Hash) ([]byte, error)
Thumbprint computes the JWK Thumbprint of a key using the indicated hash algorithm.
func (*JSONWebKey) UnmarshalJSON ¶
func (k *JSONWebKey) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON reads a key from its JSON representation.
func (*JSONWebKey) Valid ¶
func (k *JSONWebKey) Valid() bool
Valid checks that the key contains the expected parameters.
type JSONWebKeySet ¶
type JSONWebKeySet struct {
Keys []JSONWebKey `json:"keys"`
}
JSONWebKeySet represents a JWK Set object.
func (*JSONWebKeySet) Key ¶
func (s *JSONWebKeySet) Key(kid string) []JSONWebKey
Key convenience method returns keys by key ID. Specification states that a JWK Set "SHOULD" use distinct key IDs, but allows for some cases where they are not distinct. Hence method returns a slice of JSONWebKeys.