gpgutil

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTechnicalProblem occurs on all errors not related to cryptography.
	ErrTechnicalProblem = errors.New("Technical error")
	// ErrNoKeySpecified occurs when a mandatory key is not specified.
	ErrNoKeySpecified = errors.New("No key specified")
	// ErrNoPrivateKey occurs when a public key is supplied, but a private key is expected.
	ErrNoPrivateKey = errors.New("Require private key")
	// ErrWrongKey occurs when a wrong key is used for decrypting or signature checking.
	ErrWrongKey = errors.New("Wrong key")
	// ErrKeySourceNotAccepted occurs on importing a disabled key source (See gpgutil.AcceptFileKeySources and gpgutil.AcceptNamedKeySources)
	ErrKeySourceNotAccepted = errors.New("Key source %q not accepted")
	// ErrImportKeyFailed occurs when a specified key could not be imported.
	ErrImportKeyFailed = errors.New("Failed to import key")
	// ErrDecryptKeyFailed occurs when a specified key was imported but could not be decrypted.
	ErrDecryptKeyFailed = errors.New("Failed to decrypt key")
	// ErrWrongSignatureVerificationKey occurs when the key for signature verification does not match the signer.
	ErrWrongSignatureVerificationKey = errors.New("Wrong key for signature verification")
	// ErrWrongSignature occurs when a signature does not verify the given message.
	ErrWrongSignature = errors.New("Wrong signature")
	// ErrMissingSignature occurs when a signature was expected but does not exist.
	ErrMissingSignature = errors.New("Missing signature")
	// ErrGPG occurs on all cryptography related errors.
	ErrGPG = errors.New("A cryptographic method failed")
)
View Source
var (
	// GPGCommand can be used to override the command to execute gpg on this machine.
	GPGCommand string
	// AcceptFileKeySources determines whether file key sources are accepted.
	AcceptFileKeySources bool
	// AcceptNamedKeySources determines whether named key sources are accepted.
	AcceptNamedKeySources bool
)

Functions

func ComputeDetachedSignature

func ComputeDetachedSignature(inFile, outFile string, keySrc KeySource) errors.Error

ComputeDetachedSignature creates a detached signature of inFile and writes it to outFile using the given GPG key.

func DecryptFile

func DecryptFile(inFile, outFile string, keySrc KeySource, options *Options) errors.Error

DecryptFile decrypts a gpg file.

func DecryptFileAndCheckSignature

func DecryptFileAndCheckSignature(inFile, outFile string, decryptKeySrc, signKeySrc KeySource, options *Options) errors.Error

DecryptFileAndCheckSignature decrypts a gpg file and checks the signature.

DEPRECATED: Use DecryptFile(... &Options{SignatureKey: SignKeySource}) instead.

func DecryptFileToByteSlice added in v0.2.1

func DecryptFileToByteSlice(inFile string, keySrc KeySource, options *Options) ([]byte, errors.Error)

DecryptFileToByteSlice decrypts a gpg file and returns the data as byte slice.

func EncryptAndSignFile

func EncryptAndSignFile(inFile, outFile string, encryptKeySrc, signKeySrc KeySource, options *Options) errors.Error

EncryptAndSignFile encrypts and signs the given file using the given GPG keys and applies GZIP compression.

DEPRECATED: Use EncryptFile(... &Options{SignatureKey: SignKeySource}) instead.

func EncryptByteSliceToFile added in v0.2.1

func EncryptByteSliceToFile(data []byte, outFile string, keySrc KeySource, options *Options) errors.Error

EncryptByteSliceToFile encrypts a byte slice and writes the data to a file.

func EncryptFile

func EncryptFile(inFile, outFile string, encryptKeySrc KeySource, options *Options) errors.Error

EncryptFile encrypts the given file using the given GPG keys.

Types

type KeySource

type KeySource struct {
	File       string `json:"file"`
	Owner      string `json:"owner"`
	Passphrase string `json:"passphrase"`
}

KeySource describes a file or named source for protected and unprotected PGP keys.

func MakeEmptyKeySource

func MakeEmptyKeySource() KeySource

MakeEmptyKeySource returns a key source that does not describe a key. Can be used for optional keys.

func MakeFileKeySource

func MakeFileKeySource(file, password string) KeySource

MakeFileKeySource returns a file key source with passphrase. Leave empty for unencrypted keys.

func MakeNamedKeySource

func MakeNamedKeySource(owner, password string) KeySource

MakeNamedKeySource returns a named key source with passphrase. Leave empty for unencrypted keys.

func (KeySource) HasValue

func (obj KeySource) HasValue() bool

HasValue returns wether the key source contains a key.

func (KeySource) IsFileSource

func (obj KeySource) IsFileSource() bool

IsFileSource returns true, when the key source is a file.

func (KeySource) IsNamedSource

func (obj KeySource) IsNamedSource() bool

IsNamedSource returns true, when the key source denotes a key in local gpg store.

func (KeySource) String

func (obj KeySource) String() string

type Options added in v0.2.0

type Options struct {
	GZIP         bool
	SignatureKey KeySource
}

Options define additional parameters

Jump to

Keyboard shortcuts

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