gpg

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UnsupportedKeyIDLength is returned on invalid keyID lengths. See
	// ParseKeyID().
	UnsupportedKeyIDLength = Error("invalid keyID length")

	// InvalidKeyIDBytes is returned when a keyID contains nonhex characters.
	InvalidKeyIDBytes = Error("keyID contains invalid characters")

	// UnsupportedSchemeError is returned for keyserver addresses which have
	// an unsupported scheme.
	UnsupportedSchemeError = Error("unsupported scheme")

	// KeyNotFoundError is returned when the requested key does not exist on the
	// server.
	KeyNotFoundError = Error("key not found on server")

	// UnexpectedContentTypeError is returned when the server sets an invalid
	// Content-Type in its response.
	UnexpectedContentTypeError = Error("unexpected Content-Type in server response")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an OpenPGP HTTP Keyserver Protocol (HKP) client.

func NewClient

func NewClient(keyserver *Keyserver, client *http.Client) (*Client, error)

NewClient creates a new Client using the provided keyserver and http.Client. If client is nil a new one will be created. Panics if keyserver is nil.

func (*Client) GetKeysByID

func (c *Client) GetKeysByID(ctx context.Context, keyID *KeyID) (openpgp.EntityList, error)

GetKeysByID requests keys from the keyserver that match the provided keyID.

type Error

type Error string

Error represents an error constant. It implements the error interface.

func (Error) Error

func (e Error) Error() string

type GPG

type GPG struct {
	KeyID          string
	KeyServer      string
	PublicKeyPath  string
	PrivateKeyPath string
	Passphrase     string
}

GPG struct represents GPG (GnuPG) service

func New

func New(publicKeyPath, privateKeyPath, passphrase, keyID, keyServer string) (*GPG, error)

New creates GPG provider

func (*GPG) Decrypt

func (p *GPG) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt is responsible for decrypting ciphertext and returning plaintext in bytes using GPG (GnuPG). See Crypt.Decrypt

func (*GPG) Encrypt

func (p *GPG) Encrypt(plaintext []byte) ([]byte, error)

Encrypt is responsible for encrypting plaintext and returning ciphertext in bytes using GPG (GnuPG). It supports local and remote keys. See Crypt.Encrypt

type KeyID

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

KeyID represents an 8 digit (32-bit key ID), 16 digit (64-bit key ID), 32 digit (version 3 fingerprint), or 40 digit (version 4 fingerprint).

func ParseKeyID

func ParseKeyID(rawkeyid string) (*KeyID, error)

ParseKeyID parses rawkeyid into a KeyID structure. It accepts an 8, 16, 32, or 40 digit hexadecimal string without the leading "0x".

func (KeyID) String

func (k KeyID) String() string

type Keyserver

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

Keyserver is an OpenPGP HTTP Keyserver Protocol (HKP) keyserver.

func ParseKeyserver

func ParseKeyserver(rawurl string) (*Keyserver, error)

ParseKeyserver parses rawurl into a Keyserver structure. It supports schemes http, https, hkp, hkps. If no scheme is provided it is assumed to be hkp.

Jump to

Keyboard shortcuts

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