cli

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package cli implements a GPG CLI crypto backend.

Index

Constants

This section is empty.

Variables

View Source
var (

	// Ext is the file extension used by this backend.
	Ext = "gpg"
	// IDFile is the name of the recipients file used by this backend.
	IDFile = ".gpg-id"
	// Name is the name of this backend.
	Name = "gpg"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Binary string
	Args   []string
	Umask  int
}

Config is the gpg wrapper config.

type GPG

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

GPG is a gpg wrapper.

func New

func New(ctx context.Context, cfg Config) (*GPG, error)

New creates a new GPG wrapper.

func (*GPG) Binary

func (g *GPG) Binary() string

Binary returns the GPG binary location.

func (*GPG) Concurrency

func (g *GPG) Concurrency() int

Concurrency returns 1 to avoid concurrency issues with many GPG setups.

func (*GPG) Decrypt

func (g *GPG) Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error)

Decrypt will try to decrypt the given file.

func (*GPG) Encrypt

func (g *GPG) Encrypt(ctx context.Context, plaintext []byte, recipients []string) ([]byte, error)

Encrypt will encrypt the given content for the recipients. If alwaysTrust is true the trust-model will be set to always as to avoid (annoying) "unusable public key" errors when encrypting.

func (*GPG) ExportPublicKey

func (g *GPG) ExportPublicKey(ctx context.Context, id string) ([]byte, error)

ExportPublicKey will export the named public key to the location given.

func (*GPG) Ext

func (g *GPG) Ext() string

Ext returns gpg.

func (*GPG) FindIdentities

func (g *GPG) FindIdentities(ctx context.Context, search ...string) ([]string, error)

FindIdentities searches for the given private keys.

func (*GPG) FindRecipients

func (g *GPG) FindRecipients(ctx context.Context, search ...string) ([]string, error)

FindRecipients searches for the given public keys.

func (*GPG) Fingerprint

func (g *GPG) Fingerprint(ctx context.Context, id string) string

Fingerprint returns the fingerprint.

func (*GPG) FormatKey

func (g *GPG) FormatKey(ctx context.Context, id, tpl string) string

FormatKey formats the details of a key id Examples: - NameFromKey: {{ .Name }} - EmailFromKey: {{ .Email }}.

func (*GPG) GenerateIdentity

func (g *GPG) GenerateIdentity(ctx context.Context, name, email, passphrase string) error

GenerateIdentity will create a new GPG keypair in batch mode.

func (*GPG) IDFile

func (g *GPG) IDFile() string

IDFile returns .gpg-id.

func (*GPG) ImportPublicKey

func (g *GPG) ImportPublicKey(ctx context.Context, buf []byte) error

ImportPublicKey will import a key from the given location into the keyring.

func (*GPG) Initialized

func (g *GPG) Initialized(ctx context.Context) error

Initialized always returns nil.

func (*GPG) ListIdentities

func (g *GPG) ListIdentities(ctx context.Context) ([]string, error)

ListIdentities returns a parsed list of GPG secret keys.

func (*GPG) ListRecipients

func (g *GPG) ListRecipients(ctx context.Context) ([]string, error)

ListRecipients returns a parsed list of GPG public keys.

func (*GPG) Name

func (g *GPG) Name() string

Name returns gpg.

func (*GPG) ReadNamesFromKey

func (g *GPG) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error)

ReadNamesFromKey unmarshals and returns the names associated with the given public key.

func (*GPG) RecipientIDs

func (g *GPG) RecipientIDs(ctx context.Context, buf []byte) ([]string, error)

RecipientIDs returns a list of recipient IDs for a given encrypted blob.

func (*GPG) Version

func (g *GPG) Version(ctx context.Context) semver.Version

Version will return GPG version information.

Jump to

Keyboard shortcuts

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