sypgp

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: 25 Imported by: 0

Documentation

Overview

Package sypgp implements the openpgp integration into the apptainer project.

Index

Constants

View Source
const (
	Directory       = "keys"
	LegacyDirectory = "sypgp"
	PublicFile      = "pgp-public"
	SecretFile      = "pgp-secret"
)

Variables

View Source
var (

	// ErrEmptyKeyring is the error when the public, or private keyring
	// empty.
	ErrEmptyKeyring = errors.New("keyring is empty")
)

Functions

func DecryptKey

func DecryptKey(k *openpgp.Entity, message string) error

DecryptKey decrypts a private key provided a pass phrase.

func EncryptKey

func EncryptKey(k *openpgp.Entity, pass string) error

EncryptKey encrypts a private key using a pass phrase

func FetchPubkey

func FetchPubkey(ctx context.Context, fingerprint string, noPrompt bool, opts ...client.Option) (openpgp.EntityList, error)

FetchPubkey pulls a public key from the Key Service.

func GetPrivateEntity

func GetPrivateEntity(f EntitySelector) (*openpgp.Entity, error)

GetPrivateEntity retrieves the entity selected by f from the Apptainer private keyring.

func GetTokenFile

func GetTokenFile() string

GetTokenFile returns a string describing the path to the stored token file

func NewHybridKeyRing

func NewHybridKeyRing(ctx context.Context, opts ...client.Option) (openpgp.KeyRing, error)

NewHybridKeyRing returns a keyring backed by both the local public keyring and the configured keyserver.

func NewMultiKeyRing

func NewMultiKeyRing(keyrings ...openpgp.KeyRing) openpgp.KeyRing

NewMultiKeyRing returns a keyring backed by different public keyring.

func PrintEntity

func PrintEntity(index int, e *openpgp.Entity)

PrintEntity pretty prints an entity entry

func PublicKeyRing

func PublicKeyRing() (openpgp.KeyRing, error)

PublicKeyRing retrieves the Apptainer public KeyRing.

func PushPubkey

func PushPubkey(ctx context.Context, e *openpgp.Entity, opts ...client.Option) error

PushPubkey pushes a public key to the Key Service and displays the service's response if provided.

func RecryptKey

func RecryptKey(k *openpgp.Entity, passphrase []byte) error

RecryptKey Will decrypt a entity, then recrypt it with the same password. This function seems pritty usless, but its not!

func SearchPubkey

func SearchPubkey(ctx context.Context, search string, longOutput bool, opts ...client.Option) error

SearchPubkey connects to a key server and searches for a specific key

func SelectPrivKey

func SelectPrivKey(el openpgp.EntityList) (*openpgp.Entity, error)

SelectPrivKey prints a secret key list to user and returns the choice

Types

type EntitySelector

type EntitySelector func(el openpgp.EntityList) (*openpgp.Entity, error)

EntitySelector selects an Entity given an EntityList.

type GenKeyPairOptions

type GenKeyPairOptions struct {
	Name      string
	Email     string
	Comment   string
	Password  string
	KeyLength int
}

GenKeyPairOptions parameters needed for generating new key pair.

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle is a structure representing a keyring

func NewHandle

func NewHandle(path string, opts ...HandleOpt) *Handle

NewHandle initializes a new keyring in path.

func (*Handle) CheckLocalPubKey

func (keyring *Handle) CheckLocalPubKey(ckey string) (bool, error)

CheckLocalPubKey will check if we have a local public key matching ckey string returns true if there's a match.

func (*Handle) ExportPrivateKey

func (keyring *Handle) ExportPrivateKey(kpath string, armor bool) error

ExportPrivateKey Will export a private key into a file (kpath).

func (*Handle) ExportPubKey

func (keyring *Handle) ExportPubKey(kpath string, armor bool) error

ExportPubKey Will export a public key into a file (kpath).

func (*Handle) GenKeyPair

func (keyring *Handle) GenKeyPair(opts GenKeyPairOptions) (*openpgp.Entity, error)

GenKeyPair generates an PGP key pair and store them in the sypgp home folder

func (*Handle) ImportKey

func (keyring *Handle) ImportKey(kpath string, setNewPassword bool) error

ImportKey imports one or more keys from the specified file. The keys can be either a public or private keys, and the file can be either in binary or ascii-armored format.

func (*Handle) LoadPrivKeyring

func (keyring *Handle) LoadPrivKeyring() (openpgp.EntityList, error)

LoadPrivKeyring loads the private keys from local store into an EntityList

func (*Handle) LoadPubKeyring

func (keyring *Handle) LoadPubKeyring() (openpgp.EntityList, error)

LoadPubKeyring loads the public keys from local store into an EntityList

func (*Handle) PathsCheck

func (keyring *Handle) PathsCheck() error

PathsCheck creates the sypgp home folder, secret and public keyring files for non global keyring.

func (*Handle) PrintPrivKeyring

func (keyring *Handle) PrintPrivKeyring() error

PrintPrivKeyring prints the secret keyring read from the public local store

func (*Handle) PrintPubKeyring

func (keyring *Handle) PrintPubKeyring() error

PrintPubKeyring prints the public keyring read from the public local store

func (*Handle) PublicPath

func (keyring *Handle) PublicPath() string

PublicPath returns a string describing the path to the public keys store

func (*Handle) RemovePrivKey

func (keyring *Handle) RemovePrivKey(toDelete string) error

RemovePrivKey will delete a private key matching toDelete

func (*Handle) RemovePubKey

func (keyring *Handle) RemovePubKey(toDelete string) error

RemovePubKey will delete a public key matching toDelete

func (*Handle) SecretPath

func (keyring *Handle) SecretPath() string

SecretPath returns a string describing the path to the private keys store

type HandleOpt

type HandleOpt func(*Handle)

HandleOpt is a type representing option which can be passed to NewHandle.

func GlobalHandleOpt

func GlobalHandleOpt() HandleOpt

GlobalHandleOpt is the option to set a keyring as global.

type KeyExistsError

type KeyExistsError struct {
	// contains filtered or unexported fields
}

KeyExistsError is a type representing an error associated to a specific key.

func (*KeyExistsError) Error

func (e *KeyExistsError) Error() string

Jump to

Keyboard shortcuts

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