cryptkey

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unknown indicates the key material format is not known.
	Unknown = iota
	// Passphrase indicates the key material is formatted as a passphrase.
	Passphrase
	// PEM indicates the key material is formatted as a PEM file.
	PEM
	// ENV indicates PEM content saved in an environment variable.
	ENV
	// hash size for encryption (Bytes)
	Hash = 32
)
View Source
const (
	// DefaultKeySize is the default size of the key that is used when a
	// size is not explicitly specified
	DefaultKeySize = 2048
)

Variables

View Source
var (
	// ErrEncryptedKeyNotFound indicates the encrypted key is not found.
	ErrEncryptedKeyNotFound = errors.New("encrypted key not found")
	// ErrUnsupportedKeyURI indicates the key URI is not supported.
	ErrUnsupportedKeyURI = errors.New("unsupported key URI")
	// ErrNoEncryptedKeyData indicates there is no encrypted key data.
	ErrNoEncryptedKeyData = errors.New("no encrypted key data")
	// ErrNoPEMData indicates there is no PEM data.
	ErrNoPEMData = errors.New("no PEM data")
)

Functions

func EncryptKey

func EncryptKey(k KeyInfo, plaintext []byte) ([]byte, error)

func GenerateRSAKey

func GenerateRSAKey(keySize int) (*rsa.PrivateKey, error)

GenerateRSAKey creates a new RSA key of length keySize.

func LoadPEMPrivateKey

func LoadPEMPrivateKey(k KeyInfo) (*rsa.PrivateKey, error)

func LoadPEMPrivateKeyEnvVar added in v1.3.0

func LoadPEMPrivateKeyEnvVar(en string) (*rsa.PrivateKey, error)

func LoadPEMPrivateKeyFile added in v1.3.0

func LoadPEMPrivateKeyFile(fn string) (*rsa.PrivateKey, error)

func LoadPEMPublicKey

func LoadPEMPublicKey(k KeyInfo) (*rsa.PublicKey, error)

func LoadPEMPublicKeyEnvVar added in v1.3.0

func LoadPEMPublicKeyEnvVar(en string) (*rsa.PublicKey, error)

func LoadPEMPublicKeyFile added in v1.3.0

func LoadPEMPublicKeyFile(fn string) (*rsa.PublicKey, error)

func NewPlaintextKey

func NewPlaintextKey(k KeyInfo) ([]byte, error)

func PlaintextKey

func PlaintextKey(k KeyInfo, image string) ([]byte, error)

func SavePrivatePEM

func SavePrivatePEM(fileName string, key *rsa.PrivateKey) error

SavePrivatePEM saves a private PEM key into a file.

func SavePublicPEM

func SavePublicPEM(fileName string, key *rsa.PrivateKey) error

SavePublicPEM saves a public PEM key into a file.

Types

type KeyInfo

type KeyInfo struct {
	Format   int
	Material string
	Path     string
}

KeyInfo contains information for passing around or extracting a passphrase for an encrypted container

Jump to

Keyboard shortcuts

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