cryptkey

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: BSD-3-Clause Imports: 14 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
)
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(fn string) (*rsa.PrivateKey, error)

func LoadPEMPublicKey

func LoadPEMPublicKey(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