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
- func MustReadPrivateKey(encodedPrivateKey []byte) crypto.PrivateKey
- func MustReadPrivateKeyFile(pkFile string) crypto.PrivateKey
- func MustReadPublicKeyFile(pubkeyFile string) crypto.PublicKey
- func ReadPrivateKey(encodedPrivateKey []byte) (crypto.PrivateKey, error)
- func ReadPrivateKeyFile(pkFile string) (crypto.PrivateKey, error)
- func ReadPublicKey(encodedPubkey []byte) (crypto.PublicKey, error)
- func ReadPublicKeyFile(pubkeyFile string) (crypto.PublicKey, error)
- type JWK
Constants ¶
const ( KeyTypeEC = "EC" KeyTypeOct = "oct" )
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 ¶
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 ¶
ReadPublicKey decodes a PEM encoded public key and parses into crypto.PublicKey
Types ¶
type JWK ¶ added in v1.0.3
type JWK struct { KeyType string // 'kty' - "EC", "RSA", "oct" 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)
FromPrivateKey creates a JWK from a crypto.PrivateKey. Use 'fields' to set additional fields like kty, and kid. alg is set based on the passed in PrivateKey.
func ReadJWKFile ¶ added in v1.0.3
func ReadJWKFromPEM ¶ added in v1.0.3
ReadJWKFromPEM converts a PEM encoded private key to JWK. Use 'fields' to set additional fields like kty, and kid. alg is set based on the passed in PrivateKey.
func (JWK) MarshalJSON ¶ added in v1.0.3
func (*JWK) PrivateKey ¶ added in v1.0.3
func (ji *JWK) PrivateKey() (crypto.PrivateKey, error)