jwk

package
v0.0.0-...-57cc1b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IANARegisteredAlg

func IANARegisteredAlg(alg string) bool

IANARegisteredAlg is a set of "JSON Web Signature and Encryption Algorithms" from https://www.iana.org/assignments/jose/jose.xhtml as defined in https://www.rfc-editor.org/rfc/rfc7518#section-7.1

func IANARegisteredCrv

func IANARegisteredCrv(crv string) bool

IANARegisteredCrv is a set of "JSON Web Key Elliptic Curve" from https://www.iana.org/assignments/jose/jose.xhtml as mentioned in https://www.rfc-editor.org/rfc/rfc7518.html#section-6.2.1.1

func IANARegisteredKeyops

func IANARegisteredKeyops(keyops string) bool

IANARegisteredKeyops is a set of "JSON Web Key Operations" from https://www.iana.org/assignments/jose/jose.xhtml as mentioned in https://www.rfc-editor.org/rfc/rfc7517#section-4.3

func IANARegisteredKty

func IANARegisteredKty(kty string) bool

IANARegisteredKty is a set of "JSON Web Key Types" from https://www.iana.org/assignments/jose/jose.xhtml as mentioned in https://www.rfc-editor.org/rfc/rfc7517#section-4.1

func IANARegisteredUse

func IANARegisteredUse(use string) bool

IANARegisteredUse is a set of "JSON Web Key Use" types from https://www.iana.org/assignments/jose/jose.xhtml as mentioned in https://www.rfc-editor.org/rfc/rfc7517#section-4.2

Types

type IJWK

type IJWK interface {
	ToPublicKey() (crypto.PublicKey, error)
	ToPrivateKey() (crypto.PublicKey, error)
}

Interface for the JWK type

type JWK

type JWK struct {
	KTY     string            `json:"kty,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.1
	USE     string            `json:"use,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.2
	KEYOPS  []string          `json:"key_ops,omitempty"`  // https://www.rfc-editor.org/rfc/rfc7517#section-4.3
	ALG     string            `json:"alg,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.4 and https://www.rfc-editor.org/rfc/rfc7518#section-4.1
	KID     string            `json:"kid,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.5
	X5U     string            `json:"x5u,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.6
	X5C     []string          `json:"x5c,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.7
	X5T     string            `json:"x5t,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7517#section-4.8
	X5TS256 string            `json:"x5t#S256,omitempty"` // https://www.rfc-editor.org/rfc/rfc7517#section-4.9
	CRV     string            `json:"crv,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7518#section-6.2.1.1 and https://www.rfc-editor.org/rfc/rfc8037.html#section-2
	X       string            `json:"x,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.2.1.2 and https://www.rfc-editor.org/rfc/rfc8037.html#section-2
	Y       string            `json:"y,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.2.1.3
	D       string            `json:"d,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.1 and https://www.rfc-editor.org/rfc/rfc7518#section-6.2.2.1 and https://www.rfc-editor.org/rfc/rfc8037.html#section-2
	N       string            `json:"n,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.1.1
	E       string            `json:"e,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.1.2
	P       string            `json:"p,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.2
	Q       string            `json:"q,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.3
	DP      string            `json:"dp,omitempty"`       // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.4
	DQ      string            `json:"dq,omitempty"`       // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.5
	QI      string            `json:"qi,omitempty"`       // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.6
	OTH     []OtherPrimes     `json:"oth,omitempty"`      // https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.7
	K       string            `json:"k,omitempty"`        // https://www.rfc-editor.org/rfc/rfc7518#section-6.4.1
	EXT     bool              `json:"ext,omitempty"`      // https://www.w3.org/TR/WebCryptoAPI
	IAT     types.NumericDate `json:"iat,omitempty"`      // https://openid.net/specs/openid-federation-1_0.html#name-federation-historical-keys-res
	NBF     string            `json:"nbf,omitempty"`      // https://openid.net/specs/openid-federation-1_0.html#name-federation-historical-keys-res
	EXP     types.NumericDate `json:"exp,omitempty"`      // https://openid.net/specs/openid-federation-1_0.html#name-federation-historical-keys-res
	Revoked Revoked           `json:"revoked,omitempty"`  // https://openid.net/specs/openid-federation-1_0.html#name-federation-historical-keys-res
}

JWK is used to marshal or unmarshal a JSON Web Key. https://www.rfc-editor.org/rfc/rfc7517 https://www.rfc-editor.org/rfc/rfc7518 https://www.rfc-editor.org/rfc/rfc8037

You can find the full list at https://www.iana.org/assignments/jose/jose.xhtml under "JSON Web Key Parameters".

func (*JWK) Equal

func (jwk *JWK) Equal(o *JWK) bool

Equal tests two JWKs for equality

func (*JWK) FromPrivateKey

func (jwk *JWK) FromPrivateKey(key crypto.PrivateKey, X5C ...*x509.Certificate) error

FromPrivateKey converts a crypto.PrivateKey and optional x509.Certificates to a JWK

func (*JWK) FromPublicKey

func (jwk *JWK) FromPublicKey(key crypto.PublicKey, X5C ...*x509.Certificate) error

ToPublicKey converts a crypto.PublicKey to a JWK

func (*JWK) ToPrivateKey

func (jwk *JWK) ToPrivateKey() (crypto.PrivateKey, error)

ToPublicKey converts the JWK to a crypto.PrivateKey

func (*JWK) ToPublicKey

func (jwk *JWK) ToPublicKey() (crypto.PublicKey, error)

ToPublicKey converts the JWK to a crypto.PublicKey

type OtherPrimes

OtherPrimes is for RSA private keys that have more than 2 primes. https://www.rfc-editor.org/rfc/rfc7518#section-6.3.2.7

type Revoked

type Revoked struct {
	RevokedAt types.NumericDate `json:"revoked_at,omitempty"`
	Reason    string            `json:"reason,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL