jwk

package
v0.0.0-...-3ebf473 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// P256 represents a 256-bit cryptographic elliptical curve type.
	P256 = "P-256"

	// P256K represents the Ethereum 256-bit cryptographic elliptical curve type.
	P256K = "P-256K"

	// P384 represents a 384-bit cryptographic elliptical curve type.
	P384 = "P-384"

	// P521 represents a 521-bit cryptographic elliptical curve type.
	P521 = "P-521"
)

Variables

This section is empty.

Functions

func JWK2PrivateECDSA

func JWK2PrivateECDSA(j JWK) (privateKey *ecdsa.PrivateKey, err error)

JWK2PrivateECDSA parses a jsonWebKey and turns it into an ECDSA private key.

func JWK2PublicECDSA

func JWK2PublicECDSA(j JWK) (publicKey *ecdsa.PublicKey, err error)

JWK2PublicECDSA parses a jsonWebKey and turns it into an ECDSA public key.

func LoadECPrivateKeyFromJWKFile

func LoadECPrivateKeyFromJWKFile(location string) crypto.PrivateKey

func LoadECPublicKeyFromJWKFile

func LoadECPublicKeyFromJWKFile(location string) crypto.PublicKey

Types

type JWK

type JWK struct {
	Kid string `json:"kid"`
	Kty string `json:"kty"`
	Use string `json:"use"`
	Alg string `json:"alg"`

	// Elliptic curve, common to Public and Private keys
	Crv string `json:"crv"`
	X   string `json:"x"`
	Y   string `json:"y"`

	// RSA curve, common to Public and Private keys
	N string `json:"n"` // Modulus. Base64urlUInt-encoded
	E string `json:"e"` // Exponent. Base64urlUInt-encoded

	// For Private Keys, both Elliptic and RSA
	D string `json:"d"`
}

func NewECDSA

func NewECDSA() (*JWK, error)

func NewEthereum

func NewEthereum() (*JWK, error)

func NewFromBytes

func NewFromBytes(b []byte) (k *JWK, err error)

func NewJWKFromFile

func NewJWKFromFile(location string) (*JWK, error)

func (*JWK) AsJSON

func (k *JWK) AsJSON() ([]byte, error)

func (*JWK) GetAlg

func (key *JWK) GetAlg() string

func (*JWK) GetKid

func (key *JWK) GetKid() string

func (*JWK) GetPrivateKey

func (key *JWK) GetPrivateKey() (privateKeyEC crypto.PrivateKey, err error)

func (*JWK) GetPublicKey

func (key *JWK) GetPublicKey() (publicKeyEC crypto.PublicKey, err error)

func (*JWK) PublicJWKKey

func (key *JWK) PublicJWKKey() (publicKey *JWK)

func (*JWK) String

func (k *JWK) String() (s string)

Jump to

Keyboard shortcuts

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