keyutil

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package keyutil provides some basic PEM and JWK key handling without dependencies. It is not meant as a replacement for a full key handling library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustReadPrivateKey

func MustReadPrivateKey(encodedPrivateKey []byte) crypto.PrivateKey

func MustReadPrivateKeyFile

func MustReadPrivateKeyFile(pkFile string) crypto.PrivateKey

MustReadPrivateKeyFile decodes a PEM encoded private key file and parses into a crypto.PrivateKey or panics.

func MustReadPublicKeyFile

func MustReadPublicKeyFile(pubkeyFile string) crypto.PublicKey

MustReadPublicKeyFile reads a PEM encoded public key file or panics

func ReadPrivateKey

func ReadPrivateKey(encodedPrivateKey []byte) (crypto.PrivateKey, error)

ReadPrivateKey decoded a PEM encoded private key and parses into a crypto.PrivateKey.

func ReadPrivateKeyFile

func ReadPrivateKeyFile(pkFile string) (crypto.PrivateKey, error)

ReadPrivateKeyFile opens the given file and calls ReadPrivateKey to return a crypto.PrivateKey

func ReadPublicKey

func ReadPublicKey(encodedPubkey []byte) (crypto.PublicKey, error)

ReadPublicKey decodes a PEM encoded public key and parses into crypto.PublicKey

func ReadPublicKeyFile

func ReadPublicKeyFile(pubkeyFile string) (crypto.PublicKey, error)

ReadPublicKeyFile reads a PEM encdoded public key file and parses into crypto.PublicKey

Types

type JWK added in v1.0.3

type JWK struct {
	KeyType   string // 'kty'
	Algorithm string // 'alg'
	KeyID     string // 'kid'
	// contains filtered or unexported fields
}

JWK provides basic data and usage for a JWK.

func FromPrivateKey added in v1.0.3

func FromPrivateKey(pkey crypto.PrivateKey) (JWK, error)

func ReadJWK added in v1.0.3

func ReadJWK(jwkBytes []byte) (JWK, error)

func ReadJWKFile added in v1.0.3

func ReadJWKFile(jwkFile string) (JWK, error)

func ReadJWKFromPEM added in v1.0.3

func ReadJWKFromPEM(pkeyBytes []byte) (JWK, error)

ReadJWKFromPEM converts a PEM encoded private key to JWK

func (JWK) MarshalJSON added in v1.0.3

func (jwk JWK) MarshalJSON() ([]byte, error)

func (*JWK) PrivateKey added in v1.0.3

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

func (*JWK) PublicKey added in v1.0.3

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

func (*JWK) SecretKey added in v1.0.3

func (ji *JWK) SecretKey() ([]byte, error)

Jump to

Keyboard shortcuts

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