gpgeez

package module
v0.0.0-...-555ce72 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

Gpgeez

license build

Small wrapper around golang.org/x/crypto/openpgp

See https://github.com/alokmenghrajani/gpgeez/blob/master/example/create_key.go for sample usage.

Documentation

Overview

Package gpgeez is a wrapper around golang.org/x/crypto/openpgp

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	packet.Config
	// Expiry is the duration that the generated key will be valid for.
	Expiry time.Duration
}

Config for generating keys.

type Key

type Key struct {
	openpgp.Entity
}

Key represents an OpenPGP key.

func CreateKey

func CreateKey(name, comment, email string, config *Config) (*Key, error)

CreateKey creates an OpenPGP key which is similar to running gpg --gen-key on the command line. In other words, this method returns a primary signing key and an encryption subkey with expected self-signatures.

There are a few differences:

• GnuPG sets key server preference to 0x80, no-modify (see https://tools.ietf.org/html/rfc4880#section-5.2.3.17).

• GnuPG sets features to 0x01, modification detection (see https://tools.ietf.org/html/rfc4880#page-36).

• GnuPG sets the digest algorithm to SHA1. Go defaults to SHA256.

• GnuPG includes Bzip2 as a compression method. Go currently doesn't support Bzip2, so that option isn't set.

• Issuer key ID is hashed subpkt instead of subpkt, and contains a primary user ID sub packet.

You can see these differences for yourself by comparing the output of:

go run example/create_key.go | gpg --homedir /tmp --list-packets

with:

gpg --homedir /tmp --gen-key
gpg --homedir /tmp -a --export | gpg --homedir /tmp --list-packets

Or just look at https://github.com/alokmenghrajani/gpgeez/blob/master/gpgeez_test.pl

Some useful links: https://godoc.org/golang.org/x/crypto/openpgp, https://davesteele.github.io/gpg/2014/09/20/anatomy-of-a-gpg-key, https://github.com/golang/go/issues/12153

func MakeKey

func MakeKey(key openpgp.Entity) *Key

MakeKey converts an OpenPGP Entity into a gpgeez Key

func (*Key) Armor

func (key *Key) Armor() (string, error)

Armor returns the public part of a key in armored format.

func (*Key) ArmorPrivate

func (key *Key) ArmorPrivate(config *Config) (string, error)

ArmorPrivate returns the private part of a key in armored format.

Note: if you want to protect the string against varous low-level attacks, you should look at https://github.com/stouset/go.secrets and https://github.com/worr/secstring and then re-implement this function.

func (*Key) Keyring

func (key *Key) Keyring() []byte

A keyring is simply one (or more) keys in binary format.

func (*Key) Secring

func (key *Key) Secring(config *Config) []byte

A secring is simply one (or more) keys in binary format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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