keyutil

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Overview

Package keyutil implements utilities to generate cryptographic keys.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultKeyType is the default type of a private key.
	DefaultKeyType = "EC"
	// DefaultKeySize is the default size (in # of bits) of a private key.
	DefaultKeySize = 2048
	// DefaultKeyCurve is the default curve of a private key.
	DefaultKeyCurve = "P-256"
	// DefaultSignatureAlgorithm is the default signature algorithm used on a
	// certificate with the default key type.
	DefaultSignatureAlgorithm = x509.ECDSAWithSHA256
	// MinRSAKeyBytes is the minimum acceptable size (in bytes) for RSA keys
	// signed by the authority.
	MinRSAKeyBytes = 256
)

Functions

func ExtractKey

func ExtractKey(in interface{}) (interface{}, error)

ExtractKey returns the given public or private key or extracts the public key if a x509.Certificate or x509.CertificateRequest is given.

func GenerateDefaultKey

func GenerateDefaultKey() (crypto.PrivateKey, error)

GenerateDefaultKey generates a public/private key pair using sane defaults for key type, curve, and size.

func GenerateDefaultKeyPair

func GenerateDefaultKeyPair() (crypto.PublicKey, crypto.PrivateKey, error)

GenerateDefaultKeyPair generates a public/private key pair using configured default values for key type, curve, and size.

func GenerateDefaultSigner added in v0.8.0

func GenerateDefaultSigner() (crypto.Signer, error)

GenerateDefaultSigner returns an asymmetric crypto key that implements crypto.Signer using sane defaults.

func GenerateKey

func GenerateKey(kty, crv string, size int) (crypto.PrivateKey, error)

GenerateKey generates a key of the given type (kty).

func GenerateKeyPair

func GenerateKeyPair(kty, crv string, size int) (crypto.PublicKey, crypto.PrivateKey, error)

GenerateKeyPair creates an asymmetric crypto keypair using input configuration.

func GenerateSigner

func GenerateSigner(kty, crv string, size int) (crypto.Signer, error)

GenerateSigner creates an asymmetric crypto key that implements crypto.Signer.

func Insecure added in v0.18.0

func Insecure() (revert func())

Insecure enables the insecure mode in this package and returns a function to revert the configuration. The insecure mode removes the minimum limits when generating RSA keys.

func PublicKey

func PublicKey(priv interface{}) (crypto.PublicKey, error)

PublicKey extracts a public key from a private key.

func VerifyPair

func VerifyPair(pubkey crypto.PublicKey, key crypto.PrivateKey) error

VerifyPair that the public key matches the given private key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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