package pgp

import "github.com/purpleidea/mgmt/pgp"

Package pgp contains the code related to both code and host signing and encryption.

Index

Constants

const DefaultKeyringFile = "keyring.pgp"

DefaultKeyringFile is the default file name for keyrings.

Variables

var CONFIG packet.Config

CONFIG set default Hash.

Functions

func ParseIdentity

func ParseIdentity(identity string) (name, comment, email string, err error)

ParseIdentity parses an identity into name, comment and email components.

Types

type PGP

type PGP struct {
	Entity *openpgp.Entity
}

PGP contains base entity.

func Generate

func Generate(name, comment, email string, hash *crypto.Hash) (*PGP, error)

Generate creates new key pair. This key pair must be saved or it will be lost.

func Import

func Import(privKeyPath string) (*PGP, error)

Import private key from defined path.

func (*PGP) Decrypt

func (obj *PGP) Decrypt(encString string) (string, error)

Decrypt an encrypted msg.

func (*PGP) Encrypt

func (obj *PGP) Encrypt(to *openpgp.Entity, msg string) (string, error)

Encrypt message for specified entity.

func (*PGP) EncryptMsg

func (obj *PGP) EncryptMsg(to *openpgp.Entity, msg string) (*bytes.Buffer, error)

EncryptMsg encrypts the message.

func (*PGP) GetIdentities

func (obj *PGP) GetIdentities() (string, error)

GetIdentities return the first identities from current object.

func (*PGP) SaveKey

func (obj *PGP) SaveKey(path string) error

SaveKey writes the whole entity (including private key!) to a .gpg file.

func (*PGP) WriteFile

func (obj *PGP) WriteFile(path string, buff *bytes.Buffer) error

WriteFile from given buffer in specified path.

Source Files

pgp.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
4 days ago

Tools for package owners.