jwk

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 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 = "P256"

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

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

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

Variables

This section is empty.

Functions

func Curve

func Curve(crv string) (elliptic.Curve, error)

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
	Kty string
	Use string
	Alg string

	// Elliptic curve, common to Public and Private keys
	Crv string
	X   string
	Y   string

	// RSA curve, common to Public and Private keys
	N string // Modulus. Base64urlUInt-encoded
	E string // Exponent. Base64urlUInt-encoded

	// For Private Keys, both Elliptic and RSA
	D string
}

func NewECDSA

func NewECDSA(crv string) (*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