pgp

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MPL-2.0 Imports: 8 Imported by: 5

Documentation

Overview

Package pgp contains the logic related to the PGP key management.

Index

Constants

View Source
const (
	DefaultMaxAllowedLifetime = 8 * time.Hour
	DefaultAllowedClockSkew   = 5 * time.Minute
	DefaultValidEmailAsName   = true
)

Key validation defaults.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

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

Key represents a PGP key. It can be a public key or a private & public key pair.

func GenerateKey

func GenerateKey(name, comment, email string, lifetime time.Duration) (*Key, error)

GenerateKey generates a new PGP key pair.

func NewKey

func NewKey(key *pgpcrypto.Key) (*Key, error)

NewKey returns a new PGP key from the given pgpcrypto.Key.

func (*Key) Armor

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

Armor returns the key in the armored format.

func (*Key) ArmorPublic

func (p *Key) ArmorPublic() (string, error)

ArmorPublic returns only the public key in armored format.

func (*Key) Fingerprint

func (p *Key) Fingerprint() string

Fingerprint returns the fingerprint of the key.

func (*Key) IsExpired added in v0.2.1

func (p *Key) IsExpired(clockSkew time.Duration) bool

IsExpired returns true if the key is expired with clock skew.

func (*Key) IsPrivate

func (p *Key) IsPrivate() bool

IsPrivate returns true if the key contains a private key.

func (*Key) IsUnlocked

func (p *Key) IsUnlocked() (bool, error)

IsUnlocked returns true if the private key is unlocked.

func (*Key) Sign

func (p *Key) Sign(data []byte) ([]byte, error)

Sign signs the given data using the private key.

func (*Key) Validate

func (p *Key) Validate(opt ...ValidationOption) error

Validate validates the key.

func (*Key) Verify

func (p *Key) Verify(data, signature []byte) error

Verify verifies the signature of the given data using the public key.

type ValidationOption added in v0.2.3

type ValidationOption func(*validationOptions)

ValidationOption represents a functional validation option.

func WithAllowedClockSkew added in v0.2.3

func WithAllowedClockSkew(allowedClockSkew time.Duration) ValidationOption

WithAllowedClockSkew sets the allowed clock skew in the key expiration validation.

func WithMaxAllowedLifetime added in v0.2.3

func WithMaxAllowedLifetime(maxAllowedLifetime time.Duration) ValidationOption

WithMaxAllowedLifetime customizes the max allowed key lifetime in the validation.

func WithValidEmailAsName added in v0.2.3

func WithValidEmailAsName(validEmailAsName bool) ValidationOption

WithValidEmailAsName sets whether the validation should be performed on the name to be a valid email address.

Directories

Path Synopsis
Package client provides utilities for handling client-side PGP keys.
Package client provides utilities for handling client-side PGP keys.

Jump to

Keyboard shortcuts

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