pgp

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package pgp provides interface to signature generation and validation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GPGFinder added in v1.4.0

type GPGFinder interface {
	FindGPG() (gpg string, version GPGVersion, err error)
	FindGPGV() (gpgv string, version GPGVersion, err error)
}

GPGFinder implement search for gpg executables and returns version of discovered executables

func GPG1Finder added in v1.4.0

func GPG1Finder() GPGFinder

GPG1Finder looks for GnuPG1.x only

func GPG2Finder added in v1.4.0

func GPG2Finder() GPGFinder

GPG2Finder looks for GnuPG2.x only

func GPGDefaultFinder added in v1.4.0

func GPGDefaultFinder() GPGFinder

GPGDefaultFinder looks for GPG1 first, but falls back to GPG2 if GPG1 is not available

type GPGVersion added in v1.4.0

type GPGVersion int

GPGVersion stores discovered GPG version

const (
	GPG1x      GPGVersion = 1
	GPG20x     GPGVersion = 2
	GPG21xPlus GPGVersion = 3
)

GPG version as discovered

type GoSigner

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

GoSigner is implementation of Signer interface using Go internal OpenPGP library

func (*GoSigner) ClearSign

func (g *GoSigner) ClearSign(source string, destination string) error

ClearSign clear-signs the file

func (*GoSigner) DetachedSign

func (g *GoSigner) DetachedSign(source string, destination string) error

DetachedSign signs file with detached signature in ASCII format

func (*GoSigner) Init

func (g *GoSigner) Init() error

Init verifies availability of gpg & presence of keys

func (*GoSigner) SetBatch

func (g *GoSigner) SetBatch(batch bool)

SetBatch controls whether we allowed to interact with user

func (*GoSigner) SetKey

func (g *GoSigner) SetKey(keyRef string)

SetKey sets key ID to use when signing files

func (*GoSigner) SetKeyRing

func (g *GoSigner) SetKeyRing(keyring, secretKeyring string)

SetKeyRing allows to set custom keyring and secretkeyring

func (*GoSigner) SetPassphrase

func (g *GoSigner) SetPassphrase(passphrase, passphraseFile string)

SetPassphrase sets passhprase params

type GoVerifier

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

GoVerifier is implementation of Verifier interface using Go internal OpenPGP library

func (*GoVerifier) AddKeyring

func (g *GoVerifier) AddKeyring(keyring string)

AddKeyring adds custom keyrings to the list

func (*GoVerifier) ExtractClearsigned

func (g *GoVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)

ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification

func (*GoVerifier) InitKeyring

func (g *GoVerifier) InitKeyring() error

InitKeyring verifies that gpg is installed and some keys are trusted

func (*GoVerifier) IsClearSigned

func (g *GoVerifier) IsClearSigned(clearsigned io.Reader) (bool, error)

IsClearSigned returns true if file contains signature

func (*GoVerifier) VerifyClearsigned

func (g *GoVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error)

VerifyClearsigned verifies clearsigned file using gpgv

func (*GoVerifier) VerifyDetachedSignature

func (g *GoVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error

VerifyDetachedSignature verifies combination of signature and cleartext using gpgv

type GpgSigner

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

GpgSigner is implementation of Signer interface using gpg as external program

func NewGpgSigner added in v1.3.0

func NewGpgSigner(finder GPGFinder) *GpgSigner

NewGpgSigner creates a new gpg signer

func (*GpgSigner) ClearSign

func (g *GpgSigner) ClearSign(source string, destination string) error

ClearSign clear-signs the file

func (*GpgSigner) DetachedSign

func (g *GpgSigner) DetachedSign(source string, destination string) error

DetachedSign signs file with detached signature in ASCII format

func (*GpgSigner) Init

func (g *GpgSigner) Init() error

Init verifies availability of gpg & presence of keys

func (*GpgSigner) SetBatch

func (g *GpgSigner) SetBatch(batch bool)

SetBatch control --no-tty flag to gpg

func (*GpgSigner) SetKey

func (g *GpgSigner) SetKey(keyRef string)

SetKey sets key ID to use when signing files

func (*GpgSigner) SetKeyRing

func (g *GpgSigner) SetKeyRing(keyring, secretKeyring string)

SetKeyRing allows to set custom keyring and secretkeyring

func (*GpgSigner) SetPassphrase

func (g *GpgSigner) SetPassphrase(passphrase, passphraseFile string)

SetPassphrase sets passhprase params

type GpgVerifier

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

GpgVerifier is implementation of Verifier interface using gpgv as external program

func NewGpgVerifier added in v1.3.0

func NewGpgVerifier(finder GPGFinder) *GpgVerifier

NewGpgVerifier creates a new gpg verifier

func (*GpgVerifier) AddKeyring

func (g *GpgVerifier) AddKeyring(keyring string)

AddKeyring adds custom keyring to GPG parameters

func (*GpgVerifier) ExtractClearsigned

func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)

ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification

func (*GpgVerifier) InitKeyring

func (g *GpgVerifier) InitKeyring() error

InitKeyring verifies that gpg is installed and some keys are trusted

func (*GpgVerifier) IsClearSigned

func (g *GpgVerifier) IsClearSigned(clearsigned io.Reader) (bool, error)

IsClearSigned returns true if file contains signature

func (*GpgVerifier) VerifyClearsigned

func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error)

VerifyClearsigned verifies clearsigned file using gpgv

func (*GpgVerifier) VerifyDetachedSignature

func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error

VerifyDetachedSignature verifies combination of signature and cleartext using gpgv

type Key

type Key string

Key is key in PGP representation

func KeyFromUint64

func KeyFromUint64(key uint64) Key

KeyFromUint64 converts openpgp uint64 into hex human-readable

func (Key) Matches

func (key1 Key) Matches(key2 Key) bool

Matches checks two keys for equality

type KeyInfo

type KeyInfo struct {
	GoodKeys    []Key
	MissingKeys []Key
}

KeyInfo is response from signature verification

type Signer

type Signer interface {
	Init() error
	SetKey(keyRef string)
	SetKeyRing(keyring, secretKeyring string)
	SetPassphrase(passphrase, passphraseFile string)
	SetBatch(batch bool)
	DetachedSign(source string, destination string) error
	ClearSign(source string, destination string) error
}

Signer interface describes facility implementing signing of files

type Verifier

type Verifier interface {
	InitKeyring() error
	AddKeyring(keyring string)
	VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error
	IsClearSigned(clearsigned io.Reader) (bool, error)
	VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error)
	ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)
}

Verifier interface describes signature verification factility

Jump to

Keyboard shortcuts

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