openpgp

package
v0.0.0-...-2879458 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_KEYRING = iota
)

OpenPGP error types constants

View Source
const PGP_MESSAGE_FOOTER string = "-----END PGP MESSAGE-----\n"
View Source
const PGP_MESSAGE_HEADER string = "-----BEGIN PGP MESSAGE-----\n\n"

PGP messages related constants

Variables

View Source
var DEFAULT_GNUPG_DIR = ".gnupg"
View Source
var DEFAULT_GNUPG_PUBRING = filepath.Join(
	os.Getenv("USER"),
	DEFAULT_GNUPG_DIR,
	DEFAULT_GNUPG_PUBRING_FILE,
)
View Source
var DEFAULT_GNUPG_PUBRING_FILE = "pubring.gpg"
View Source
var DEFAULT_GNUPG_SECRING = filepath.Join(
	os.Getenv("USER"),
	DEFAULT_GNUPG_DIR,
	DEFAULT_GNUPG_SECRING_FILE,
)
View Source
var DEFAULT_GNUPG_SECRING_FILE = "secring.gpg"
View Source
var DEFAULT_GNUPG_THRUSTDB_FILE = "thrustdb.gpg"

Functions

func ReadKeyRing

func ReadKeyRing(path string) (*openpgp.EntityList, error)

func ReadPubRing

func ReadPubRing(path string, keyIds []string) (*openpgp.EntityList, error)

func ReadSecRing

func ReadSecRing(path string) (*openpgp.EntityList, error)

func UserIds

func UserIds() []string

Types

type ErrorCode

type ErrorCode int
const (
	ERR_ENCRYPTION_ENCODING ErrorCode = iota
	ERR_ENCRYPTION_ENCRYPT
)

Encryption error types constants

const (
	ERR_DECRYPTION_KEYS ErrorCode = iota
	ERR_DECRYPTION_HASHES
	ERR_DECRYPTION_CIPHERS
)

Decryption error types constants

type OpenPGPDecrypter

type OpenPGPDecrypter struct {
	// Keys represents the collection of decryption keys
	// present in your gnupg secret ring
	Keys *openpgp.EntityList
	// contains filtered or unexported fields
}

func NewOpenPGPDecrypter

func NewOpenPGPDecrypter(secRingPath string, passphrase string) (*OpenPGPDecrypter, error)

NewOpenPGPDecrypter builds a new OpenPGPDecrypter object from a gnupg secring file path and a passphrase. The returned object can then be used against OpenPGP encrypted bytes using the Decrypt method.

See Decrypter interface.

func (*OpenPGPDecrypter) Decrypt

func (od *OpenPGPDecrypter) Decrypt(ed []byte) ([]byte, error)

Decrypt reads up the openpgp encrypted data bytes from ed, decrypts them and returns the resulting plain data bytes as well as any potential errors.

type OpenPGPEncrypter

type OpenPGPEncrypter struct {
	Keys *openpgp.EntityList
}

OpenPGPEncrypter implements the Encrypter interface. Provided an *openpgp.EntityList object it exposes an Encrypt method to encrypt provided plain bytes using OpenPGP algorithm.

func NewOpenPGPEncrypter

func NewOpenPGPEncrypter(pubRingPath string, recipients []string) (*OpenPGPEncrypter, error)

NewOpenPGPEncrypter builds a new OpenPGPEncrypter object from provided gnupg pubring file path and a list of recipients. The returned object can then be used against byte slices to encrypt them with the OpenPGP encryption algorithm using the Encrypt method.

See Encrypter interface.

func (*OpenPGPEncrypter) Encrypt

func (oe *OpenPGPEncrypter) Encrypt(pd []byte) ([]byte, error)

Encrypt reads up plain data bytes contained in pd, encrypts them using OpenPGP encryption algorithm, and returns the resulting bytes as well as any potential errors.

type OpenPGPError

type OpenPGPError struct {
	Code ErrorCode
	// contains filtered or unexported fields
}

func NewOpenPGPError

func NewOpenPGPError(code ErrorCode, msg string) *OpenPGPError

func (*OpenPGPError) Error

func (e *OpenPGPError) Error() string

Jump to

Keyboard shortcuts

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