jwk

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPublic = errors.New("public key")

ErrPublic is returned if no private part is present in the JWK

Functions

This section is empty.

Types

type JWK

type JWK struct {
	KeyType                         string   `json:"kty"`
	PublicKeyUse                    string   `json:"use,omitempty"`
	KeyOperations                   []string `json:"key_ops,omitempty"`
	Algorithm                       string   `json:"alg,omitempty"`
	KeyID                           string   `json:"kid,omitempty"`
	X509URL                         string   `json:"x5u,omitempty"`
	X509CertificateThumbprint       string   `json:"x5t,omitempty"`
	X509CertificateSHA256Thumbprint string   `json:"x5t#S256,omitempty"`
	X509CertificateChain            []string `json:"x5c,omitempty"`

	// Parameters for Elliptic Curve Keys
	Curve string `json:"crv,omitempty"`
	X     string `json:"x,omitempty"`
	Y     string `json:"y,omitempty"`

	// Parameters for RSA Keys
	N   string      `json:"n,omitempty"`
	E   string      `json:"e,omitempty"`
	P   string      `json:"p,omitempty"`
	Q   string      `json:"q,omitempty"`
	Dp  string      `json:"dp,omitempty"`
	Dq  string      `json:"dq,omitempty"`
	Qi  string      `json:"qi,omitempty"`
	Oth []*RSAPrime `json:"oth,omitempty"`

	// Same name, different meaning for EC and RSA
	D string `json:"d,omitempty"`

	// Symmetric
	K string `json:"k,omitempty"`

	// Microsoft extension?
	KeyHSM string `json:"key_hsm,omitempty"`
}

JWK represents a A JSON Web Key see https://tools.ietf.org/html/rfc7517

func EncodePrivateKey

func EncodePrivateKey(key crypto.PrivateKey) (jwk *JWK, err error)

EncodePrivateKey returns a JWT populated with data from the private key

func EncodePublicKey

func EncodePublicKey(key crypto.PublicKey) (jwk *JWK, err error)

EncodePublicKey returns a JWT populated with data from the private key

func (*JWK) PrivateKey

func (j *JWK) PrivateKey() (crypto.PrivateKey, error)

PrivateKey decodes a private key represented in JWK

func (*JWK) PublicKey

func (j *JWK) PublicKey() (crypto.PublicKey, error)

PublicKey decodes a public key represented in JWK

type RSAPrime

type RSAPrime struct {
	R string `json:"r,omitempty"`
	D string `json:"d,omitempty"`
	T string `json:"t,omitempty"`
}

RSAPrime represents RSA prime https://tools.ietf.org/html/rfc7518#section-6.3.2.7

Jump to

Keyboard shortcuts

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